resend_msg(): CID 1379029
[s-mailx.git] / make-config.sh
blob9c42614f67e117e3ef5d4b37b106c71dba94f3dc
1 #!/bin/sh -
2 #@ Please see INSTALL and make.rc instead.
4 LC_ALL=C
5 export LC_ALL
7 # The feature set, to be kept in sync with make.rc
8 # If no documentation given, the option is used as such; if doc is a hyphen,
9 # entry is suppressed when configuration overview is printed, and also in the
10 # *features* string: most likely for obsolete features etc.
11 XOPTIONS="\
12 ICONV='Character set conversion using iconv(3)' \
13 SOCKETS='Network support' \
14 SSL='SSL/TLS (OpenSSL / LibreSSL)' \
15 SSL_ALL_ALGORITHMS='Support of all digest and cipher algorithms' \
16 SMTP='Simple Mail Transfer Protocol client' \
17 POP3='Post Office Protocol Version 3 client' \
18 IMAP='IMAP v4r1 client' \
19 GSSAPI='Generic Security Service authentication' \
20 NETRC='.netrc file support' \
21 AGENT='-' \
22 MD5='MD5 message digest (APOP, CRAM-MD5)' \
23 IDNA='Internationalized Domain Names for Applications (encode only)' \
24 IMAP_SEARCH='IMAP-style search expressions' \
25 REGEX='Regular expressions' \
26 MLE='Mailx Line Editor' \
27 HISTORY='Line editor history management' \
28 KEY_BINDINGS='Configurable key bindings' \
29 TERMCAP='Terminal capability queries (termcap(5))' \
30 TERMCAP_VIA_TERMINFO='Terminal capability queries use terminfo(5)' \
31 ERRORS='Error log message ring' \
32 SPAM_SPAMC='Spam management via spamc(1) of spamassassin(1)' \
33 SPAM_SPAMD='-' \
34 SPAM_FILTER='Freely configurable *spam-filter-..*s' \
35 DOCSTRINGS='Command documentation help strings' \
36 QUOTE_FOLD='Extended *quote-fold*ing' \
37 FILTER_HTML_TAGSOUP='Simple built-in HTML-to-text display filter' \
38 COLOUR='Coloured message display' \
39 DOTLOCK='Dotlock files and privilege-separated dotlock program' \
42 # Options which are automatically deduced from host environment, i.e., these
43 # need special treatment all around here to warp from/to OPT_ stuff
44 # setlocale, C90AMEND1, NL_LANGINFO, wcwidth
45 XOPTIONS_DETECT="\
46 LOCALES='Locale support - printable characters etc. depend on environment' \
47 MULTIBYTE_CHARSETS='Multibyte character sets' \
48 TERMINAL_CHARSET='Automatic detection of terminal character set' \
49 WIDE_GLYPHS='Wide glyph support' \
52 # Rather special options, for custom building, or which always exist.
53 # Mostly for generating the visual overview and the *features* string
54 XOPTIONS_XTRA="\
55 MIME='Multipurpose Internet Mail Extensions' \
56 SMIME='S/MIME message signing, verification, en- and decryption' \
57 CROSS_BUILD='Cross-compilation: trust any detected environment' \
58 DEBUG='Debug enabled binary, not for end-users: THANKS!' \
59 DEVEL='Computers do not blunder' \
62 # The problem is that we don't have any tools we can use right now, so
63 # encapsulate stuff in functions which get called in right order later on
65 option_reset() {
66 set -- ${OPTIONS}
67 for i
69 eval OPT_${i}=0
70 done
73 option_maximal() {
74 set -- ${OPTIONS}
75 for i
77 eval OPT_${i}=1
78 done
79 OPT_ICONV=require
80 OPT_REGEX=require
81 OPT_DOTLOCK=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 case "${CONFIG}" in
93 [nN][uU][lL][lL])
94 option_reset
96 [nN][uU][lL][lL][iI])
97 option_reset
98 OPT_ICONV=require
100 [mM][iI][nN][iI][mM][aA][lL])
101 option_reset
102 OPT_ICONV=1
103 OPT_REGEX=1
104 OPT_DOTLOCK=require
106 [mM][eE][dD][iI][uU][mM])
107 option_reset
108 OPT_ICONV=require
109 OPT_IDNA=1
110 OPT_REGEX=1
111 OPT_MLE=1
112 OPT_HISTORY=1 OPT_KEY_BINDINGS=1
113 OPT_ERRORS=1
114 OPT_SPAM_FILTER=1
115 OPT_DOCSTRINGS=1
116 OPT_COLOUR=1
117 OPT_DOTLOCK=require
119 [nN][eE][tT][sS][eE][nN][dD])
120 option_reset
121 OPT_ICONV=require
122 OPT_SOCKETS=1
123 OPT_SSL=require
124 OPT_SMTP=require
125 OPT_GSSAPI=1 OPT_NETRC=1 OPT_AGENT=1
126 OPT_IDNA=1
127 OPT_REGEX=1
128 OPT_MLE=1
129 OPT_HISTORY=1 OPT_KEY_BINDINGS=1
130 OPT_DOCSTRINGS=1
131 OPT_COLOUR=1
132 OPT_DOTLOCK=require
134 [mM][aA][xX][iI][mM][aA][lL])
135 option_reset
136 option_maximal
138 [dD][eE][vV][eE][lL])
139 OPT_DEVEL=1 OPT_DEBUG=1 OPT_NYD2=1
140 option_maximal
142 [oO][dD][eE][vV][eE][lL])
143 OPT_DEVEL=1
144 option_maximal
147 echo >&2 "Unknown CONFIG= setting: ${CONFIG}"
148 echo >&2 ' NULL, NULLI, MINIMAL, MEDIUM, NETSEND, MAXIMAL'
149 exit 1
151 esac
152 msg_nonl "CONFIG=${CONFIG} ... "
156 # Inter-relationships
157 option_update() {
158 if feat_no SMTP && feat_no POP3 && feat_no IMAP; then
159 OPT_SOCKETS=0
161 if feat_no SOCKETS; then
162 if feat_require SMTP; then
163 msg 'ERROR: need SOCKETS for required feature SMTP'
164 config_exit 13
166 if feat_require POP3; then
167 msg 'ERROR: need SOCKETS for required feature POP3'
168 config_exit 13
170 if feat_require IMAP; then
171 msg 'ERROR: need SOCKETS for required feature IMAP'
172 config_exit 13
174 OPT_SSL=0 OPT_SSL_ALL_ALGORITHMS=0
175 OPT_SMTP=0 OPT_POP3=0 OPT_IMAP=0
176 OPT_GSSAPI=0 OPT_NETRC=0 OPT_AGENT=0
178 if feat_no SMTP && feat_no IMAP; then
179 OPT_GSSAPI=0
182 if feat_no ICONV; then
183 if feat_yes IMAP; then
184 if feat_require IMAP; then
185 msg 'ERROR: need ICONV for required feature IMAP'
186 config_exit 13
188 msg 'ERROR: disabling IMAP due to missing ICONV'
189 OPT_IMAP=0
192 if feat_yes IDNA; then
193 if feat_require IDNA; then
194 msg 'ERROR: need ICONV for required feature IDNA'
195 config_exit 13
197 msg 'ERROR: disabling IDNA due to missing ICONV'
198 OPT_IDNA=0
202 if feat_no MLE; then
203 OPT_HISTORY=0 OPT_KEY_BINDINGS=0
206 # If we don't need MD5 leave it alone
207 if feat_no SOCKETS; then
208 OPT_MD5=0
211 if feat_no TERMCAP; then
212 OPT_TERMCAP_VIA_TERMINFO=0
215 if feat_yes DEVEL; then
216 OPT_DEBUG=1
220 rc=./make.rc
221 lst=./mk-config.lst
222 ev=./mk-config.ev
223 h=./mk-config.h h_name=mk-config.h
224 mk=./mk-config.mk
226 newlst=./mk-nconfig.lst
227 newmk=./mk-nconfig.mk
228 newev=./mk-nconfig.ev
229 newh=./mk-nconfig.h
230 tmp0=___tmp
231 tmp=./${tmp0}1$$
232 tmp2=./${tmp0}2$$
234 ## -- >8 - << OPTIONS | OS/CC >> - 8< -- ##
236 # Note that potential duplicates in PATH, C_INCLUDE_PATH etc. will be cleaned
237 # via path_check() later on once possible
239 # TODO cc_maxopt is brute simple, we should compile test program and dig real
240 # compiler versions for known compilers, then be more specific
241 cc_maxopt=100
242 _CFLAGS= _LDFLAGS=
244 os_early_setup() {
245 # We don't "have any utility": only path adjustments and such in here!
246 i="${OS:-`uname -s`}"
248 if [ ${i} = SunOS ]; then
249 msg 'SunOS / Solaris? Applying some "early setup" rules ...'
250 _os_early_setup_sunos
254 _os_early_setup_sunos() {
255 # According to standards(5), this is what we need to do
256 if [ -d /usr/xpg4 ]; then :; else
257 msg 'ERROR: On SunOS / Solaris we need /usr/xpg4 environment! Sorry.'
258 config_exit 1
260 PATH="/usr/xpg4/bin:/usr/ccs/bin:/usr/bin:${PATH}"
261 [ -d /usr/xpg6 ] && PATH="/usr/xpg6/bin:${PATH}"
262 export PATH
265 os_setup() {
266 # OSENV ends up in *build-osenv*
267 # OSFULLSPEC is used to recognize changes (i.e., machine type, updates etc.)
268 : ${OS:=`uname -s | ${tr} '[A-Z]' '[a-z]'`}
269 : ${OSENV:=`uname -srm`}
270 : ${OSFULLSPEC:=`uname -a`}
271 msg 'Operating system is %s' ${OS}
273 if [ ${OS} = sunos ]; then
274 msg ' . have special SunOS / Solaris "setup" rules ...'
275 _os_setup_sunos
276 elif [ ${OS} = unixware ]; then
277 msg ' . have special UnixWare environmental rules ...'
278 if feat_yes AUTOCC && command -v cc >/dev/null 2>&1; then
279 CC=cc
280 feat_yes DEBUG && _CFLAGS='-v -Xa -g' || _CFLAGS='-Xa -O'
282 CFLAGS="${_CFLAGS} ${EXTRA_CFLAGS}"
283 LDFLAGS="${_LDFLAGS} ${EXTRA_LDFLAGS}"
284 export CC CFLAGS LDFLAGS
285 OPT_AUTOCC=0 had_want_autocc=1 need_R_ldflags=-R
287 elif [ -n "${VERBOSE}" ]; then
288 msg ' . no special treatment for this system necessary or known'
291 # Sledgehammer: better set _GNU_SOURCE
292 # And in general: oh, boy!
293 OS_DEFINES="${OS_DEFINES}#define _GNU_SOURCE\n"
294 #OS_DEFINES="${OS_DEFINES}#define _POSIX_C_SOURCE 200809L\n"
295 #OS_DEFINES="${OS_DEFINES}#define _XOPEN_SOURCE 700\n"
296 #[ ${OS} = darwin ] && OS_DEFINES="${OS_DEFINES}#define _DARWIN_C_SOURCE\n"
298 # On pkgsrc(7) systems automatically add /usr/pkg/*
299 if [ -d /usr/pkg ]; then
300 C_INCLUDE_PATH="${C_INCLUDE_PATH}:/usr/pkg/include"
301 LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:/usr/pkg/lib"
305 _os_setup_sunos() {
306 C_INCLUDE_PATH="/usr/xpg4/include:${C_INCLUDE_PATH}"
307 LD_LIBRARY_PATH="/usr/xpg4/lib:${LD_LIBRARY_PATH}"
309 # Include packages
310 if [ -d /opt/csw ]; then
311 C_INCLUDE_PATH="${C_INCLUDE_PATH}:/opt/csw/include"
312 LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:/opt/csw/lib"
315 OS_DEFINES="${OS_DEFINES}#define __EXTENSIONS__\n"
316 #OS_DEFINES="${OS_DEFINES}#define _POSIX_C_SOURCE 200112L\n"
318 [ -n "${cksum}" ] || cksum=/opt/csw/gnu/cksum
319 if [ -x "${cksum}" ]; then :; else
320 msg 'ERROR: Not an executable program: %s' "${cksum}"
321 msg 'ERROR: We need a CRC-32 cksum(1), as specified in POSIX.'
322 msg 'ERROR: However, we do so only for tests.'
323 msg 'ERROR: If that is ok, set "cksum=/usr/bin/true", then rerun'
324 config_exit 1
327 if feat_yes AUTOCC; then
328 if command -v cc >/dev/null 2>&1; then
329 CC=cc
330 feat_yes DEBUG && _CFLAGS="-v -Xa -g" || _CFLAGS="-Xa -O"
332 CFLAGS="${_CFLAGS} ${EXTRA_CFLAGS}"
333 LDFLAGS="${_LDFLAGS} ${EXTRA_LDFLAGS}"
334 export CC CFLAGS LDFLAGS
335 OPT_AUTOCC=0 had_want_autocc=1 need_R_ldflags=-R
336 else
337 # Assume gcc(1), which supports -R for compat
338 cc_maxopt=2 force_no_stackprot=1 need_R_ldflags=-Wl,-R
343 # Check out compiler ($CC) and -flags ($CFLAGS)
344 cc_setup() {
345 # Even though it belongs into cc_flags we will try to compile and link
346 # something, so ensure we have a clean state regarding CFLAGS/LDFLAGS or
347 # EXTRA_CFLAGS/EXTRA_LDFLAGS
348 if feat_no AUTOCC; then
349 _cc_default
350 # Ensure those don't do any harm
351 EXTRA_CFLAGS= EXTRA_LDFLAGS=
352 export EXTRA_CFLAGS EXTRA_LDFLAGS
353 return
354 else
355 CFLAGS= LDFLAGS=
356 export CFLAGS LDFLAGS
359 [ -n "${CC}" ] && [ "${CC}" != cc ] && { _cc_default; return; }
361 msg_nonl 'Searching for a usable C compiler .. $CC='
362 if { i="`command -v clang`"; }; then
363 CC=${i}
364 elif { i="`command -v gcc`"; }; then
365 CC=${i}
366 elif { i="`command -v c99`"; }; then
367 CC=${i}
368 elif { i="`command -v tcc`"; }; then
369 CC=${i}
370 elif { i="`command -v pcc`"; }; then
371 CC=${i}
372 else
373 if [ "${CC}" = cc ]; then
375 elif { i="`command -v c89`"; }; then
376 CC=${i}
377 else
378 msg 'boing booom tschak'
379 msg 'ERROR: I cannot find a compiler!'
380 msg ' Neither of clang(1), gcc(1), tcc(1), pcc(1), c89(1) and c99(1).'
381 msg ' Please set ${CC} environment variable, maybe ${CFLAGS}, rerun.'
382 config_exit 1
385 msg '%s' "${CC}"
386 export CC
389 _cc_default() {
390 if [ -z "${CC}" ]; then
391 msg 'To go on like you have chosen, please set $CC, rerun.'
392 config_exit 1
395 if [ -z "${VERBOSE}" ] && [ -f ${lst} ] && feat_no DEBUG; then
397 else
398 msg 'Using C compiler ${CC}=%s' "${CC}"
402 cc_flags() {
403 if feat_yes AUTOCC; then
404 if [ -f ${lst} ] && feat_no DEBUG && [ -z "${VERBOSE}" ]; then
405 cc_check_silent=1
406 msg 'Detecting ${CFLAGS}/${LDFLAGS} for ${CC}=%s, just a second..' \
407 "${CC}"
408 else
409 cc_check_silent=
410 msg 'Testing usable ${CFLAGS}/${LDFLAGS} for ${CC}=%s' "${CC}"
413 i=`echo "${CC}" | ${awk} 'BEGIN{FS="/"}{print $NF}'`
414 if { echo "${i}" | ${grep} tcc; } >/dev/null 2>&1; then
415 msg ' . have special tcc(1) environmental rules ...'
416 _cc_flags_tcc
417 else
418 # As of pcc CVS 2016-04-02, stack protection support is announced but
419 # will break if used on Linux
420 if { echo "${i}" | ${grep} pcc; } >/dev/null 2>&1; then
421 force_no_stackprot=1
423 _cc_flags_generic
426 feat_no DEBUG && _CFLAGS="-DNDEBUG ${_CFLAGS}"
427 CFLAGS="${_CFLAGS} ${EXTRA_CFLAGS}"
428 LDFLAGS="${_LDFLAGS} ${EXTRA_LDFLAGS}"
429 else
430 if feat_no DEBUG; then
431 CFLAGS="-DNDEBUG ${CFLAGS}"
434 msg ''
435 export CFLAGS LDFLAGS
438 _cc_flags_tcc() {
439 __cflags=${_CFLAGS} __ldflags=${_LDFLAGS}
440 _CFLAGS= _LDFLAGS=
442 cc_check -Wall
443 cc_check -Wextra
444 cc_check -pedantic
446 if feat_yes DEBUG; then
447 # May have problems to find libtcc cc_check -b
448 cc_check -g
451 if ld_check -Wl,-rpath =./ no; then
452 need_R_ldflags=-Wl,-rpath=
453 ld_check -Wl,--enable-new-dtags
454 ld_runtime_flags # update!
457 _CFLAGS="${_CFLAGS} ${__cflags}" _LDFLAGS="${_LDFLAGS} ${__ldflags}"
458 unset __cflags __ldflags
461 _cc_flags_generic() {
462 __cflags=${_CFLAGS} __ldflags=${_LDFLAGS}
463 _CFLAGS= _LDFLAGS=
464 feat_yes DEVEL && cc_check -std=c89 || cc_check -std=c99
466 # Check -g first since some others may rely upon -g / optim. level
467 if feat_yes DEBUG; then
468 cc_check -O
469 cc_check -g
470 elif [ ${cc_maxopt} -gt 2 ] && cc_check -O3; then
472 elif [ ${cc_maxopt} -gt 1 ] && cc_check -O2; then
474 elif [ ${cc_maxopt} -gt 0 ] && cc_check -O1; then
476 else
477 cc_check -O
480 if feat_yes AMALGAMATION; then
481 cc_check -pipe
484 #if feat_yes DEVEL && cc_check -Weverything; then
486 #else
487 cc_check -Wall
488 cc_check -Wextra
489 cc_check -Wbad-function-cast
490 cc_check -Wcast-align
491 cc_check -Wcast-qual
492 cc_check -Winit-self
493 cc_check -Wmissing-prototypes
494 cc_check -Wshadow
495 cc_check -Wunused
496 cc_check -Wwrite-strings
497 cc_check -Wno-long-long
499 cc_check -pedantic
501 if feat_yes AMALGAMATION && feat_no DEVEL; then
502 cc_check -Wno-unused-function
504 feat_no DEVEL && cc_check -Wno-unused-result # XXX do right way (pragma too)
506 cc_check -fno-unwind-tables
507 cc_check -fno-asynchronous-unwind-tables
508 cc_check -fstrict-aliasing
509 if cc_check -fstrict-overflow && feat_yes DEVEL; then
510 cc_check -Wstrict-overflow=5
513 if feat_yes DEBUG || feat_yes FORCED_STACKPROT; then
514 if [ -z "${force_no_stackprot}" ]; then
515 if cc_check -fstack-protector-strong ||
516 cc_check -fstack-protector-all; then
517 cc_check -D_FORTIFY_SOURCE=2
519 else
520 msg 'Not checking for -fstack-protector compiler option,'
521 msg 'since that caused errors in a "similar" configuration.'
522 msg 'You may turn off OPT_AUTOCC and use your own settings, rerun'
526 # LD (+ dependend CC)
528 if feat_yes ASAN_ADDRESS; then
529 _ccfg=${_CFLAGS}
530 if cc_check -fsanitize=address &&
531 ld_check -fsanitize=address; then
533 else
534 feat_bail_required ASAN_ADDRESS
535 _CFLAGS=${_ccfg}
539 if feat_yes ASAN_MEMORY; then
540 _ccfg=${_CFLAGS}
541 if cc_check -fsanitize=memory &&
542 ld_check -fsanitize=memory &&
543 cc_check -fsanitize-memory-track-origins=2 &&
544 ld_check -fsanitize-memory-track-origins=2; then
546 else
547 feat_bail_required ASAN_MEMORY
548 _CFLAGS=${_ccfg}
552 ld_check -Wl,-z,relro
553 ld_check -Wl,-z,now
554 ld_check -Wl,-z,noexecstack
555 if ld_check -Wl,-rpath =./ no; then
556 need_R_ldflags=-Wl,-rpath=
557 # Choose DT_RUNPATH (after $LD_LIBRARY_PATH) over DT_RPATH (before)
558 ld_check -Wl,--enable-new-dtags
559 ld_runtime_flags # update!
560 elif ld_check -Wl,-R ./ no; then
561 need_R_ldflags=-Wl,-R
562 ld_check -Wl,--enable-new-dtags
563 ld_runtime_flags # update!
566 # Address randomization
567 _ccfg=${_CFLAGS}
568 if cc_check -fPIE || cc_check -fpie; then
569 ld_check -pie || _CFLAGS=${_ccfg}
571 unset _ccfg
573 _CFLAGS="${_CFLAGS} ${__cflags}" _LDFLAGS="${_LDFLAGS} ${__ldflags}"
574 unset __cflags __ldflags
577 ## -- >8 - <<OS/CC | SUPPORT FUNS>> - 8< -- ##
579 ## Notes:
580 ## - Heirloom sh(1) (and same origin) have _sometimes_ problems with ': >'
581 ## redirection, so use "printf '' >" instead
583 ## Very first: we undergo several states regarding I/O redirection etc.,
584 ## but need to deal with option updates from within all. Since all the
585 ## option stuff should be above the scissor line, define utility functions
586 ## and redefine them as necessary.
587 ## And, since we have those functions, simply use them for whatever
589 config_exit() {
590 exit ${1}
593 msg() {
594 fmt=${1}
595 shift
596 printf >&2 -- "${fmt}\\n" "${@}"
599 msg_nonl() {
600 fmt=${1}
601 shift
602 printf >&2 -- "${fmt}" "${@}"
605 t1=ten10one1ten10one1
606 if ( [ ${t1##*ten10} = one1 ] && [ ${t1#*ten10} = one1ten10one1 ] &&
607 [ ${t1%%one1*} = ten10 ] && [ ${t1%one1*} = ten10one1ten10 ]
608 ) > /dev/null 2>&1; then
609 good_shell=1
610 else
611 unset good_shell
613 unset t1
615 # We need some standard utilities
616 unset -f command
617 check_tool() {
618 n=${1} i=${2} opt=${3:-0}
619 # Evaluate, just in case user comes in with shell snippets (..well..)
620 eval i="${i}"
621 if type "${i}" >/dev/null 2>&1; then # XXX why have i type not command -v?
622 [ -n "${VERBOSE}" ] && msg ' . ${%s} ... %s' "${n}" "${i}"
623 eval ${n}=${i}
624 return 0
626 if [ ${opt} -eq 0 ]; then
627 msg 'ERROR: no trace of utility %s' "${n}"
628 config_exit 1
630 return 1
633 # Our feature check environment
634 feat_val_no() {
635 [ "x${1}" = x0 ] || [ "x${1}" = xn ] ||
636 [ "x${1}" = xfalse ] || [ "x${1}" = xno ] || [ "x${1}" = xoff ]
639 feat_val_yes() {
640 [ "x${1}" = x1 ] || [ "x${1}" = xy ] ||
641 [ "x${1}" = xtrue ] || [ "x${1}" = xyes ] || [ "x${1}" = xon ] ||
642 [ "x${1}" = xrequire ]
645 feat_val_require() {
646 [ "x${1}" = xrequire ]
649 _feat_check() {
650 eval i=\$OPT_${1}
651 i="`echo ${i} | ${tr} '[A-Z]' '[a-z]'`"
652 if feat_val_no "${i}"; then
653 return 1
654 elif feat_val_yes "${i}"; then
655 return 0
656 else
657 msg "ERROR: %s: 0/n/false/no/off or 1/y/true/yes/on/require, got: %s" \
658 "${1}" "${i}"
659 config_exit 11
663 feat_yes() {
664 _feat_check ${1}
667 feat_no() {
668 _feat_check ${1} && return 1
669 return 0
672 feat_require() {
673 eval i=\$OPT_${1}
674 i="`echo ${i} | ${tr} '[A-Z]' '[a-z]'`"
675 [ "x${i}" = xrequire ] || [ "x${i}" = xrequired ]
678 feat_bail_required() {
679 if feat_require ${1}; then
680 msg 'ERROR: feature OPT_%s is required but not available' "${1}"
681 config_exit 13
683 eval OPT_${1}=0
684 option_update # XXX this is rather useless here (dependency chain..)
687 option_parse() {
688 # Parse one of our XOPTIONS* in $2 and assign the sh(1) compatible list of
689 # options, without documentation, to $1
690 j=\'
691 i="`${awk} -v input=\"${2}\" '
692 BEGIN{
693 for(i = 0;;){
694 voff = match(input, /[[:alnum:]_]+(='${j}'[^'${j}']+)?/)
695 if(voff == 0)
696 break
697 v = substr(input, voff, RLENGTH)
698 input = substr(input, voff + RLENGTH)
699 doff = index(v, "=")
700 if(doff > 0){
701 d = substr(v, doff + 2, length(v) - doff - 1)
702 v = substr(v, 1, doff - 1)
704 print v
708 eval ${1}=\"${i}\"
711 option_doc_of() {
712 # Return the "documentation string" for option $1, itself if none such
713 j=\'
714 ${awk} -v want="${1}" \
715 -v input="${XOPTIONS_DETECT}${XOPTIONS}${XOPTIONS_XTRA}" '
716 BEGIN{
717 for(;;){
718 voff = match(input, /[[:alnum:]_]+(='${j}'[^'${j}']+)?/)
719 if(voff == 0)
720 break
721 v = substr(input, voff, RLENGTH)
722 input = substr(input, voff + RLENGTH)
723 doff = index(v, "=")
724 if(doff > 0){
725 d = substr(v, doff + 2, length(v) - doff - 1)
726 v = substr(v, 1, doff - 1)
727 }else
728 d = v
729 if(v == want){
730 if(d != "-")
731 print d
732 exit
739 option_join_rc() {
740 # Join the values from make.rc into what currently is defined, not
741 # overwriting yet existing settings
742 ${rm} -f ${tmp}
743 # We want read(1) to perform reverse solidus escaping in order to be able to
744 # use multiline values in make.rc; the resulting sh(1)/sed(1) code was very
745 # slow in VMs (see [fa2e248]), Aharon Robbins suggested the following
746 < ${rc} ${awk} 'BEGIN{line = ""}{
747 gsub(/^[[:space:]]+/, "", $0)
748 gsub(/[[:space:]]+$/, "", $0)
749 if(gsub(/\\$/, "", $0)){
750 line = line $0
751 next
752 }else
753 line = line $0
754 if(index(line, "#") == 1){
755 line = ""
756 }else if(length(line)){
757 print line
758 line = ""
760 }' |
761 while read line; do
762 if [ -n "${good_shell}" ]; then
763 i=${line%%=*}
764 else
765 i=`${awk} -v LINE="${line}" 'BEGIN{
766 gsub(/=.*$/, "", LINE)
767 print LINE
770 if [ "${i}" = "${line}" ]; then
771 msg 'ERROR: invalid syntax in: %s' "${line}"
772 continue
775 eval j="\$${i}" jx="\${${i}+x}"
776 if [ -n "${j}" ] || [ "${jx}" = x ]; then
777 : # Yet present
778 else
779 j=`${awk} -v LINE="${line}" 'BEGIN{
780 gsub(/^[^=]*=/, "", LINE)
781 gsub(/^\"*/, "", LINE)
782 gsub(/\"*$/, "", LINE)
783 print LINE
786 [ "${i}" = "DESTDIR" ] && continue
787 echo "${i}=\"${j}\""
788 done > ${tmp}
789 # Reread the mixed version right now
790 . ./${tmp}
793 option_evaluate() {
794 # Expand the option values, which may contain shell snippets
795 ${rm} -f ${newlst} ${newmk} ${newh}
796 exec 5<&0 6>&1 <${tmp} >${newlst}
797 while read line; do
799 if [ -n "${good_shell}" ]; then
800 i=${line%%=*}
801 [ "${i}" != "${i#OPT_}" ] && z=1
802 else
803 i=`${awk} -v LINE="${line}" 'BEGIN{
804 gsub(/=.*$/, "", LINE);\
805 print LINE
807 if echo "${i}" | ${grep} '^OPT_' >/dev/null 2>&1; then
812 eval j=\$${i}
813 if [ -n "${z}" ]; then
814 j="`echo ${j} | ${tr} '[A-Z]' '[a-z]'`"
815 if [ -z "${j}" ] || feat_val_no "${j}"; then
817 printf " /* #undef ${i} */\n" >> ${newh}
818 elif feat_val_yes "${j}"; then
819 if feat_val_require "${j}"; then
820 j=require
821 else
824 printf " /* #define ${i} */\n" >> ${newh}
825 else
826 msg 'ERROR: cannot parse <%s>' "${line}"
827 config_exit 1
829 else
830 printf "#define ${i} \"${j}\"\n" >> ${newh}
832 printf "${i} = ${j}\n" >> ${newmk}
833 printf "${i}=${j}\n"
834 eval "${i}=\"${j}\""
835 done
836 exec 0<&5 1>&6 5<&- 6<&-
839 path_check() {
840 # "path_check VARNAME" or "path_check VARNAME FLAG VARNAME"
841 varname=${1} addflag=${2} flagvarname=${3}
842 j=${IFS}
843 IFS=:
844 eval "set -- \$${1}"
845 IFS=${j}
846 j= k= y= z=
847 for i
849 [ -z "${i}" ] && continue
850 [ -d "${i}" ] || continue
851 if [ -n "${j}" ]; then
852 if { z=${y}; echo "${z}"; } | ${grep} ":${i}:" >/dev/null 2>&1; then
854 else
855 y="${y} :${i}:"
856 j="${j}:${i}"
857 # But do not link any fakeroot path into our binaries!
858 if [ -n "${addflag}" ]; then
859 case "${i}" in *fakeroot*) continue;; esac
860 k="${k} ${addflag}${i}"
863 else
864 y=" :${i}:"
865 j="${i}"
866 # But do not link any fakeroot path into our binaries!
867 if [ -n "${addflag}" ]; then
868 case "${i}" in *fakeroot*) continue;; esac
869 k="${k} ${addflag}${i}"
872 done
873 eval "${varname}=\"${j}\""
874 [ -n "${addflag}" ] && eval "${flagvarname}=\"${k}\""
875 unset varname
878 ld_runtime_flags() {
879 if [ -n "${need_R_ldflags}" ]; then
880 i=${IFS}
881 IFS=:
882 set -- ${LD_LIBRARY_PATH}
883 IFS=${i}
884 for i
886 # But do not link any fakeroot path into our binaries!
887 case "${i}" in *fakeroot*) continue;; esac
888 LDFLAGS="${LDFLAGS} ${need_R_ldflags}${i}"
889 _LDFLAGS="${_LDFLAGS} ${need_R_ldflags}${i}"
890 done
891 export LDFLAGS
893 # Disable it for a possible second run.
894 need_R_ldflags=
897 cc_check() {
898 [ -n "${cc_check_silent}" ] || msg_nonl ' . CC %s .. ' "${1}"
899 if "${CC}" ${INCS} \
900 ${_CFLAGS} ${1} ${EXTRA_CFLAGS} ${_LDFLAGS} ${EXTRA_LDFLAGS} \
901 -o ${tmp2} ${tmp}.c ${LIBS} >/dev/null 2>&1; then
902 _CFLAGS="${_CFLAGS} ${1}"
903 [ -n "${cc_check_silent}" ] || msg 'yes'
904 return 0
906 [ -n "${cc_check_silent}" ] || msg 'no'
907 return 1
910 ld_check() {
911 # $1=option [$2=option argument] [$3=if set, shall NOT be added to _LDFLAGS]
912 [ -n "${cc_check_silent}" ] || msg_nonl ' . LD %s .. ' "${1}"
913 if "${CC}" ${INCS} ${_CFLAGS} ${_LDFLAGS} ${1}${2} ${EXTRA_LDFLAGS} \
914 -o ${tmp2} ${tmp}.c ${LIBS} >/dev/null 2>&1; then
915 [ -n "${3}" ] || _LDFLAGS="${_LDFLAGS} ${1}"
916 [ -n "${cc_check_silent}" ] || msg 'yes'
917 return 0
919 [ -n "${cc_check_silent}" ] || msg 'no'
920 return 1
923 _check_preface() {
924 variable=$1 topic=$2 define=$3
926 echo '**********'
927 msg_nonl ' . %s ... ' "${topic}"
928 echo "/* checked ${topic} */" >> ${h}
929 ${rm} -f ${tmp} ${tmp}.o
930 echo '*** test program is'
931 { echo '#include <'"${h_name}"'>'; cat; } | ${tee} ${tmp}.c
932 #echo '*** the preprocessor generates'
933 #${make} -f ${makefile} ${tmp}.x
934 #${cat} ${tmp}.x
935 echo '*** results are'
938 without_check() {
939 yesno=$1 variable=$2 topic=$3 define=$4 libs=$5 incs=$6
941 echo '**********'
942 msg_nonl ' . %s ... ' "${topic}"
944 echo '*** enforced unchecked results are'
945 if feat_val_yes ${yesno}; then
946 if [ -n "${incs}" ] || [ -n "${libs}" ]; then
947 echo "*** adding INCS<${incs}> LIBS<${libs}>"
948 LIBS="${LIBS} ${libs}"
949 echo "${libs}" >> ${lib}
950 INCS="${INCS} ${incs}"
951 echo "${incs}" >> ${inc}
953 msg 'yes (deduced)'
954 echo "${define}" >> ${h}
955 eval have_${variable}=yes
956 return 0
957 else
958 echo "/* ${define} */" >> ${h}
959 msg 'no (deduced)'
960 eval unset have_${variable}
961 return 1
965 compile_check() {
966 variable=$1 topic=$2 define=$3
968 _check_preface "${variable}" "${topic}" "${define}"
970 if ${make} -f ${makefile} XINCS="${INCS}" \
971 CFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}" \
972 ./${tmp}.o &&
973 [ -f ./${tmp}.o ]; then
974 msg 'yes'
975 echo "${define}" >> ${h}
976 eval have_${variable}=yes
977 return 0
978 else
979 echo "/* ${define} */" >> ${h}
980 msg 'no'
981 eval unset have_${variable}
982 return 1
986 _link_mayrun() {
987 run=$1 variable=$2 topic=$3 define=$4 libs=$5 incs=$6
989 _check_preface "${variable}" "${topic}" "${define}"
991 if feat_yes CROSS_BUILD; then
992 if [ ${run} = 1 ]; then
993 run=0
997 if ${make} -f ${makefile} XINCS="${INCS} ${incs}" \
998 CFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}" \
999 XLIBS="${LIBS} ${libs}" \
1000 ./${tmp} &&
1001 [ -f ./${tmp} ] &&
1002 { [ ${run} -eq 0 ] || ./${tmp}; }; then
1003 echo "*** adding INCS<${incs}> LIBS<${libs}>; executed: ${run}"
1004 msg 'yes'
1005 echo "${define}" >> ${h}
1006 LIBS="${LIBS} ${libs}"
1007 echo "${libs}" >> ${lib}
1008 INCS="${INCS} ${incs}"
1009 echo "${incs}" >> ${inc}
1010 eval have_${variable}=yes
1011 return 0
1012 else
1013 msg 'no'
1014 echo "/* ${define} */" >> ${h}
1015 eval unset have_${variable}
1016 return 1
1020 link_check() {
1021 _link_mayrun 0 "${1}" "${2}" "${3}" "${4}" "${5}"
1024 run_check() {
1025 _link_mayrun 1 "${1}" "${2}" "${3}" "${4}" "${5}"
1028 xrun_check() {
1029 _link_mayrun 2 "${1}" "${2}" "${3}" "${4}" "${5}"
1032 feat_def() {
1033 if feat_yes ${1}; then
1034 echo '#define HAVE_'${1}'' >> ${h}
1035 return 0
1036 else
1037 echo '/* OPT_'${1}'=0 */' >> ${h}
1038 return 1
1042 squeeze_em() {
1043 < "${1}" > "${2}" ${awk} \
1044 'BEGIN {ORS = " "} /^[^#]/ {print} {next} END {ORS = ""; print "\n"}'
1047 ## -- >8 - <<SUPPORT FUNS | RUNNING>> - 8< -- ##
1049 # First of all, create new configuration and check whether it changed
1051 # Very easy checks for the operating system in order to be able to adjust paths
1052 # or similar very basic things which we need to be able to go at all
1053 os_early_setup
1055 # Check those tools right now that we need before including $rc
1056 msg 'Checking for basic utility set'
1057 check_tool awk "${awk:-`command -v awk`}"
1058 check_tool rm "${rm:-`command -v rm`}"
1059 check_tool tr "${tr:-`command -v tr`}"
1061 # Initialize the option set
1062 msg_nonl 'Setting up configuration options ... '
1063 option_setup
1064 msg 'done'
1066 # Include $rc, but only take from it what wasn't overwritten by the user from
1067 # within the command line or from a chosen fixed CONFIG=
1068 # Note we leave alone the values
1069 trap "exit 1" HUP INT TERM
1070 trap "${rm} -f ${tmp}" EXIT
1072 msg_nonl 'Joining in %s ... ' ${rc}
1073 option_join_rc
1074 msg 'done'
1076 # We need to know about that now, in order to provide utility overwrites etc.
1077 os_setup
1079 msg 'Checking for remaining set of utilities'
1080 check_tool grep "${grep:-`command -v grep`}"
1082 # Before we step ahead with the other utilities perform a path cleanup first.
1083 path_check PATH
1085 # awk(1) above
1086 check_tool cat "${cat:-`command -v cat`}"
1087 check_tool chmod "${chmod:-`command -v chmod`}"
1088 check_tool cp "${cp:-`command -v cp`}"
1089 check_tool cmp "${cmp:-`command -v cmp`}"
1090 # grep(1) above
1091 check_tool mkdir "${mkdir:-`command -v mkdir`}"
1092 check_tool mv "${mv:-`command -v mv`}"
1093 # rm(1) above
1094 check_tool sed "${sed:-`command -v sed`}"
1095 check_tool sort "${sort:-`command -v sort`}"
1096 check_tool tee "${tee:-`command -v tee`}"
1098 check_tool chown "${chown:-`command -v chown`}" 1 ||
1099 check_tool chown "/sbin/chown" 1 ||
1100 check_tool chown "/usr/sbin/chown"
1102 check_tool make "${MAKE:-`command -v make`}"
1103 MAKE=${make}
1104 check_tool strip "${STRIP:-`command -v strip`}" 1 &&
1105 HAVE_STRIP=1 || HAVE_STRIP=0
1107 # For ./cc-test.sh only
1108 check_tool cksum "${cksum:-`command -v cksum`}"
1110 # Update OPT_ options now, in order to get possible inter-dependencies right
1111 option_update
1113 # (No functions since some shells loose non-exported variables in traps)
1114 trap "trap \"\" HUP INT TERM; exit 1" HUP INT TERM
1115 trap "trap \"\" HUP INT TERM EXIT;\
1116 ${rm} -rf ${newlst} ${tmp0}.* ${tmp0}* ${newmk} ${newev} ${newh}" EXIT
1118 # Our configuration options may at this point still contain shell snippets,
1119 # we need to evaluate them in order to get them expanded, and we need those
1120 # evaluated values not only in our new configuration file, but also at hand..
1121 msg_nonl 'Evaluating all configuration items ... '
1122 option_evaluate
1123 msg 'done'
1125 # Add the known utility and some other variables
1126 printf "#define VAL_UAGENT \"${VAL_SID}${VAL_MAILX}\"\n" >> ${newh}
1127 printf "VAL_UAGENT = ${VAL_SID}${VAL_MAILX}\n" >> ${newmk}
1129 printf "#define VAL_PRIVSEP \"${VAL_SID}${VAL_MAILX}-privsep\"\n" >> ${newh}
1130 printf "VAL_PRIVSEP = \$(VAL_UAGENT)-privsep\n" >> ${newmk}
1131 if feat_yes DOTLOCK; then
1132 printf "OPTIONAL_PRIVSEP = \$(VAL_PRIVSEP)\n" >> ${newmk}
1133 else
1134 printf "OPTIONAL_PRIVSEP =\n" >> ${newmk}
1137 for i in \
1138 awk cat chmod chown cp cmp grep mkdir mv rm sed sort tee tr \
1139 MAKE MAKEFLAGS make SHELL strip \
1140 cksum; do
1141 eval j=\$${i}
1142 printf "${i} = ${j}\n" >> ${newmk}
1143 printf "${i}=${j}\n" >> ${newlst}
1144 printf "${i}=\"${j}\";export ${i}; " >> ${newev}
1145 done
1146 printf "\n" >> ${newev}
1148 # Build a basic set of INCS and LIBS according to user environment.
1149 path_check C_INCLUDE_PATH -I _INCS
1150 INCS="${INCS} ${_INCS}"
1151 path_check LD_LIBRARY_PATH -L _LIBS
1152 LIBS="${LIBS} ${_LIBS}"
1153 unset _INCS _LIBS
1154 export C_INCLUDE_PATH LD_LIBRARY_PATH
1156 # Some environments need runtime path flags to be able to go at all
1157 ld_runtime_flags
1159 ## Detect CC, whether we can use it, and possibly which CFLAGS we can use
1161 cc_setup
1163 ${cat} > ${tmp}.c << \!
1164 #include <stdio.h>
1165 #include <string.h>
1166 static void doit(char const *s);
1168 main(int argc, char **argv){
1169 (void)argc;
1170 (void)argv;
1171 doit("Hello world");
1172 return 0;
1174 static void
1175 doit(char const *s){
1176 char buf[12];
1177 memcpy(buf, s, strlen(s) +1);
1178 puts(s);
1182 if "${CC}" ${INCS} ${CFLAGS} ${EXTRA_CFLAGS} ${LDFLAGS} ${EXTRA_LDFLAGS} \
1183 -o ${tmp2} ${tmp}.c ${LIBS}; then
1185 else
1186 msg 'ERROR: i cannot compile a "Hello world" via'
1187 msg ' %s' \
1188 "${CC} ${INCS} ${CFLAGS} ${EXTRA_CFLAGS} ${LDFLAGS} ${EXTRA_LDFLAGS} ${LIBS}"
1189 msg 'ERROR: Please read INSTALL, rerun'
1190 config_exit 1
1193 # This may also update ld_runtime_flags() (again)
1194 cc_flags
1196 for i in \
1197 INCS LIBS \
1198 ; do
1199 eval j=\$${i}
1200 printf -- "${i}=${j}\n" >> ${newlst}
1201 done
1202 for i in \
1203 CC \
1204 CFLAGS \
1205 LDFLAGS \
1206 PATH C_INCLUDE_PATH LD_LIBRARY_PATH \
1207 OSFULLSPEC \
1208 ; do
1209 eval j=\$${i}
1210 printf -- "${i} = ${j}\n" >> ${newmk}
1211 printf -- "${i}=${j}\n" >> ${newlst}
1212 done
1214 # Now finally check whether we already have a configuration and if so, whether
1215 # all those parameters are still the same.. or something has actually changed
1216 if [ -f ${lst} ] && ${cmp} ${newlst} ${lst} >/dev/null 2>&1; then
1217 echo 'Configuration is up-to-date'
1218 exit 0
1219 elif [ -f ${lst} ]; then
1220 echo 'Configuration has been updated..'
1221 ( eval "${MAKE} -f ./mk-config.mk clean" )
1222 echo
1223 else
1224 echo 'Shiny configuration..'
1227 # Time to redefine helper 1
1228 config_exit() {
1229 ${rm} -f ${lst} ${h} ${mk}
1230 exit ${1}
1233 ${mv} -f ${newlst} ${lst}
1234 ${mv} -f ${newev} ${ev}
1235 ${mv} -f ${newh} ${h}
1236 ${mv} -f ${newmk} ${mk}
1238 if [ -z "${VERBOSE}" ]; then
1239 printf -- "ECHO_CC = @echo ' 'CC \$(@);\n" >> ${mk}
1240 printf -- "ECHO_LINK = @echo ' 'LINK \$(@);\n" >> ${mk}
1241 printf -- "ECHO_GEN = @echo ' 'GEN \$(@);\n" >> ${mk}
1242 printf -- "ECHO_TEST = @\n" >> ${mk}
1243 printf -- "ECHO_CMD = @echo ' CMD';\n" >> ${mk}
1244 printf -- "ECHO_BLOCK_BEGIN = @( \n" >> ${mk}
1245 printf -- "ECHO_BLOCK_END = ) >/dev/null\n" >> ${mk}
1248 ## Compile and link checking
1250 tmp3=./${tmp0}3$$
1251 log=./mk-config.log
1252 lib=./mk-config.lib
1253 inc=./mk-config.inc
1254 makefile=./${tmp0}.mk
1256 # (No function since some shells loose non-exported variables in traps)
1257 trap "trap \"\" HUP INT TERM;\
1258 ${rm} -f ${lst} ${h} ${mk} ${lib} ${inc}; exit 1" HUP INT TERM
1259 trap "trap \"\" HUP INT TERM EXIT;\
1260 ${rm} -rf ${tmp0}.* ${tmp0}*" EXIT
1262 # Time to redefine helper 2
1263 msg() {
1264 fmt=${1}
1265 shift
1266 printf "*** ${fmt}\\n" "${@}"
1267 printf -- "${fmt}\\n" "${@}" >&5
1269 msg_nonl() {
1270 fmt=${1}
1271 shift
1272 printf "*** ${fmt}\\n" "${@}"
1273 printf -- "${fmt}" "${@}" >&5
1276 # !!
1277 exec 5>&2 > ${log} 2>&1
1279 echo "${LIBS}" > ${lib}
1280 echo "${INCS}" > ${inc}
1281 ${cat} > ${makefile} << \!
1282 .SUFFIXES: .o .c .x .y
1283 .c.o:
1284 $(CC) -I./ $(XINCS) $(CFLAGS) -c $(<)
1285 .c.x:
1286 $(CC) -I./ $(XINCS) -E $(<) > $(@)
1288 $(CC) -I./ $(XINCS) $(CFLAGS) $(LDFLAGS) -o $(@) $(<) $(XLIBS)
1291 ## Generics
1293 # May be multiline..
1294 echo >> ${h}
1295 [ -n "${OS_DEFINES}" ] && printf -- "${OS_DEFINES}" >> ${h}
1296 echo '#define VAL_BUILD_OS "'"${OS}"'"' >> ${h}
1297 echo '#define VAL_BUILD_OSENV "'"${OSENV}"'"' >> ${h}
1299 # Generate n_err_number OS mappings
1301 feat_yes DEVEL && NV= || NV=noverbose
1302 TARGET="${h}" awk="${awk}" ./make-errors.sh ${NV} config
1304 xrun_check oserrno 'OS error mapping table generated' || config_exit 1
1306 feat_def ALWAYS_UNICODE_LOCALE
1307 feat_def AMALGAMATION
1308 feat_def CROSS_BUILD
1309 feat_def DOCSTRINGS
1310 feat_def ERRORS
1312 feat_def ASAN_ADDRESS
1313 feat_def ASAN_MEMORY
1314 feat_def DEBUG
1315 feat_def DEVEL
1316 feat_def NYD2
1317 feat_def NOMEMDBG
1319 if xrun_check inline 'inline functions' \
1320 '#define HAVE_INLINE
1321 #define n_INLINE static inline' << \!
1322 static inline int ilf(int i){return ++i;}
1323 int main(void){return ilf(-1);}
1325 then
1327 elif xrun_check inline 'inline functions (via __inline)' \
1328 '#define HAVE_INLINE
1329 #define n_INLINE static __inline' << \!
1330 static __inline int ilf(int i){return ++i;}
1331 int main(void){return ilf(-1);}
1333 then
1337 ## Test for "basic" system-calls / functionality that is used by all parts
1338 ## of our program. Once this is done fork away BASE_LIBS and other BASE_*
1339 ## macros to be used by only the subprograms (potentially).
1341 if run_check clock_gettime 'clock_gettime(2)' \
1342 '#define HAVE_CLOCK_GETTIME' << \!
1343 #include <time.h>
1344 # include <errno.h>
1345 int main(void){
1346 struct timespec ts;
1348 if(!clock_gettime(CLOCK_REALTIME, &ts) || errno != ENOSYS)
1349 return 0;
1350 return 1;
1353 then
1355 elif run_check clock_gettime 'clock_gettime(2) (via -lrt)' \
1356 '#define HAVE_CLOCK_GETTIME' '-lrt' << \!
1357 #include <time.h>
1358 # include <errno.h>
1359 int main(void){
1360 struct timespec ts;
1362 if(!clock_gettime(CLOCK_REALTIME, &ts) || errno != ENOSYS)
1363 return 0;
1364 return 1;
1367 then
1369 elif run_check gettimeofday 'gettimeofday(2)' \
1370 '#define HAVE_GETTIMEOFDAY' << \!
1371 #include <stdio.h> /* For C89 NULL */
1372 #include <sys/time.h>
1373 # include <errno.h>
1374 int main(void){
1375 struct timeval tv;
1377 if(!gettimeofday(&tv, NULL) || errno != ENOSYS)
1378 return 0;
1379 return 1;
1382 then
1384 else
1385 have_no_subsecond_time=1
1388 if run_check nanosleep 'nanosleep(2)' \
1389 '#define HAVE_NANOSLEEP' << \!
1390 #include <time.h>
1391 # include <errno.h>
1392 int main(void){
1393 struct timespec ts;
1395 ts.tv_sec = 1;
1396 ts.tv_nsec = 100000;
1397 if(!nanosleep(&ts, NULL) || errno != ENOSYS)
1398 return 0;
1399 return 1;
1402 then
1404 elif run_check nanosleep 'nanosleep(2) (via -lrt)' \
1405 '#define HAVE_NANOSLEEP' '-lrt' << \!
1406 #include <time.h>
1407 # include <errno.h>
1408 int main(void){
1409 struct timespec ts;
1411 ts.tv_sec = 1;
1412 ts.tv_nsec = 100000;
1413 if(!nanosleep(&ts, NULL) || errno != ENOSYS)
1414 return 0;
1415 return 1;
1418 then
1420 # link_check is enough for this, that function is so old, trust the proto
1421 elif link_check sleep 'sleep(3)' \
1422 '#define HAVE_SLEEP' << \!
1423 #include <unistd.h>
1424 # include <errno.h>
1425 int main(void){
1426 if(!sleep(1) || errno != ENOSYS)
1427 return 0;
1428 return 1;
1431 then
1433 else
1434 msg 'ERROR: we require one of nanosleep(2) and sleep(3).'
1435 config_exit 1
1438 if run_check userdb 'gete?[gu]id(2), getpwuid(3), getpwnam(3)' << \!
1439 #include <pwd.h>
1440 #include <unistd.h>
1441 # include <errno.h>
1442 int main(void){
1443 struct passwd *pw;
1444 gid_t gid;
1445 uid_t uid;
1447 if((gid = getgid()) != 0)
1448 gid = getegid();
1449 if((uid = getuid()) != 0)
1450 uid = geteuid();
1451 if((pw = getpwuid(uid)) == NULL && errno == ENOSYS)
1452 return 1;
1453 if((pw = getpwnam("root")) == NULL && errno == ENOSYS)
1454 return 1;
1455 return 0;
1458 then
1460 else
1461 msg 'ERROR: we require user and group info / database searches.'
1462 msg 'That much Unix we indulge ourselfs.'
1463 config_exit 1
1466 if link_check ftruncate 'ftruncate(2)' \
1467 '#define HAVE_FTRUNCATE' << \!
1468 #include <unistd.h>
1469 #include <sys/types.h>
1470 int main(void){
1471 return (ftruncate(0, 0) != 0);
1474 then
1476 else
1477 msg 'ERROR: we require the ftruncate(2) system call.'
1478 config_exit 1
1481 if run_check sa_restart 'SA_RESTART (for sigaction(2))' << \!
1482 #include <signal.h>
1483 # include <errno.h>
1484 int main(void){
1485 struct sigaction nact, oact;
1487 nact.sa_handler = SIG_DFL;
1488 sigemptyset(&nact.sa_mask);
1489 nact.sa_flags = SA_RESTART;
1490 return !(!sigaction(SIGCHLD, &nact, &oact) || errno != ENOSYS);
1493 then
1495 else
1496 msg 'ERROR: we (yet) require the SA_RESTART flag for sigaction(2).'
1497 config_exit 1
1500 if link_check snprintf 'snprintf(3)' << \!
1501 #include <stdio.h>
1502 int main(void){
1503 char b[20];
1505 snprintf(b, sizeof b, "%s", "string");
1506 return 0;
1509 then
1511 else
1512 msg 'ERROR: we require the snprintf(3) function.'
1513 config_exit 1
1516 if link_check environ 'environ(3)' << \!
1517 #include <stdio.h> /* For C89 NULL */
1518 int main(void){
1519 extern char **environ;
1521 return environ[0] == NULL;
1524 then
1526 else
1527 msg 'ERROR: we require the environ(3) array for subprocess control.'
1528 config_exit 1
1531 if link_check setenv '(un)?setenv(3)' '#define HAVE_SETENV' << \!
1532 #include <stdlib.h>
1533 int main(void){
1534 setenv("s-mailx", "i want to see it cute!", 1);
1535 unsetenv("s-mailx");
1536 return 0;
1539 then
1541 elif link_check setenv 'putenv(3)' '#define HAVE_PUTENV' << \!
1542 #include <stdlib.h>
1543 int main(void){
1544 putenv("s-mailx=i want to see it cute!");
1545 return 0;
1548 then
1550 else
1551 msg 'ERROR: we require either the setenv(3) or putenv(3) functions.'
1552 config_exit 1
1555 if link_check termios 'termios.h and tc*(3) family' << \!
1556 #include <termios.h>
1557 int main(void){
1558 struct termios tios;
1560 tcgetattr(0, &tios);
1561 tcsetattr(0, TCSANOW | TCSADRAIN | TCSAFLUSH, &tios);
1562 return 0;
1565 then
1567 else
1568 msg 'ERROR: we require termios.h and the tc*() family of functions.'
1569 msg 'That much Unix we indulge ourselfs.'
1570 config_exit 1
1573 ## optional stuff
1575 if link_check vsnprintf 'vsnprintf(3)' << \!
1576 #include <stdarg.h>
1577 #include <stdio.h>
1578 static void dome(char *buf, size_t blen, ...){
1579 va_list ap;
1581 va_start(ap, blen);
1582 vsnprintf(buf, blen, "%s", ap);
1583 va_end(ap);
1585 int main(void){
1586 char b[20];
1588 dome(b, sizeof b, "string");
1589 return 0;
1592 then
1594 else
1595 feat_bail_required ERRORS
1598 if [ "${have_vsnprintf}" = yes ]; then
1599 __va_copy() {
1600 link_check va_copy "va_copy(3) (as ${2})" \
1601 "#define HAVE_N_VA_COPY
1602 #define n_va_copy ${2}" <<_EOT
1603 #include <stdarg.h>
1604 #include <stdio.h>
1605 #if ${1}
1606 # if defined __va_copy && !defined va_copy
1607 # define va_copy __va_copy
1608 # endif
1609 #endif
1610 static void dome2(char *buf, size_t blen, va_list src){
1611 va_list ap;
1613 va_copy(ap, src);
1614 vsnprintf(buf, blen, "%s", ap);
1615 va_end(ap);
1617 static void dome(char *buf, size_t blen, ...){
1618 va_list ap;
1620 va_start(ap, blen);
1621 dome2(buf, blen, ap);
1622 va_end(ap);
1624 int main(void){
1625 char b[20];
1627 dome(b, sizeof b, "string");
1628 return 0;
1630 _EOT
1632 __va_copy 0 va_copy || __va_copy 1 __va_copy
1635 run_check pathconf 'f?pathconf(2)' '#define HAVE_PATHCONF' << \!
1636 #include <unistd.h>
1637 #include <errno.h>
1638 int main(void){
1639 int rv = 0;
1641 errno = 0;
1642 rv |= !(pathconf(".", _PC_NAME_MAX) >= 0 || errno == 0 || errno != ENOSYS);
1643 errno = 0;
1644 rv |= !(pathconf(".", _PC_PATH_MAX) >= 0 || errno == 0 || errno != ENOSYS);
1646 /* Only link check */
1647 fpathconf(0, _PC_NAME_MAX);
1649 return rv;
1653 run_check pipe2 'pipe2(2)' '#define HAVE_PIPE2' << \!
1654 #include <fcntl.h>
1655 #include <unistd.h>
1656 # include <errno.h>
1657 int main(void){
1658 int fds[2];
1660 if(!pipe2(fds, O_CLOEXEC) || errno != ENOSYS)
1661 return 0;
1662 return 1;
1666 # We use this only then for now (need NOW+1)
1667 run_check utimensat 'utimensat(2)' '#define HAVE_UTIMENSAT' << \!
1668 #include <fcntl.h> /* For AT_* */
1669 #include <sys/stat.h>
1670 # include <errno.h>
1671 int main(void){
1672 struct timespec ts[2];
1674 ts[0].tv_nsec = UTIME_NOW;
1675 ts[1].tv_nsec = UTIME_OMIT;
1676 if(!utimensat(AT_FDCWD, "", ts, 0) || errno != ENOSYS)
1677 return 0;
1678 return 1;
1684 # XXX Add POSIX check once standardized
1685 if link_check posix_random 'arc4random(3)' '#define HAVE_POSIX_RANDOM 0' << \!
1686 #include <stdlib.h>
1687 int main(void){
1688 arc4random();
1689 return 0;
1692 then
1694 elif link_check getrandom 'getrandom(2) (in sys/random.h)' \
1695 '#define HAVE_GETRANDOM(B,S) getrandom(B, S, 0)
1696 #define HAVE_GETRANDOM_HEADER <sys/random.h>' <<\!
1697 #include <sys/random.h>
1698 int main(void){
1699 char buf[256];
1700 getrandom(buf, sizeof buf, 0);
1701 return 0;
1704 then
1706 elif link_check getrandom 'getrandom(2) (via syscall(2))' \
1707 '#define HAVE_GETRANDOM(B,S) syscall(SYS_getrandom, B, S, 0)
1708 #define HAVE_GETRANDOM_HEADER <sys/syscall.h>' <<\!
1709 #include <sys/syscall.h>
1710 int main(void){
1711 char buf[256];
1712 syscall(SYS_getrandom, buf, sizeof buf, 0);
1713 return 0;
1716 then
1718 elif [ -n "${have_no_subsecond_time}" ]; then
1719 msg 'ERROR: %s %s' 'without a native random' \
1720 'one of clock_gettime(2) and gettimeofday(2) is required.'
1721 config_exit 1
1725 link_check putc_unlocked 'putc_unlocked(3)' '#define HAVE_PUTC_UNLOCKED' <<\!
1726 #include <stdio.h>
1727 int main(void){
1728 putc_unlocked('@', stdout);
1729 return 0;
1733 link_check fchdir 'fchdir(3)' '#define HAVE_FCHDIR' << \!
1734 #include <unistd.h>
1735 int main(void){
1736 fchdir(0);
1737 return 0;
1741 if run_check realpath 'realpath(3)' '#define HAVE_REALPATH' << \!
1742 #include <stdlib.h>
1743 int main(void){
1744 char x_buf[4096], *x = realpath(".", x_buf);
1746 return (x != NULL) ? 0 : 1;
1749 then
1750 if run_check realpath_malloc 'realpath(3) takes NULL' \
1751 '#define HAVE_REALPATH_NULL' << \!
1752 #include <stdlib.h>
1753 int main(void){
1754 char *x = realpath(".", NULL);
1756 if(x != NULL)
1757 free(x);
1758 return (x != NULL) ? 0 : 1;
1761 then
1766 ## optional and selectable
1768 if feat_yes DOTLOCK; then
1769 if run_check readlink 'readlink(2)' << \!
1770 #include <unistd.h>
1771 # include <errno.h>
1772 int main(void){
1773 char buf[128];
1775 if(!readlink("here", buf, sizeof buf) || errno != ENOSYS)
1776 return 0;
1777 return 1;
1780 then
1782 else
1783 feat_bail_required DOTLOCK
1787 if feat_yes DOTLOCK; then
1788 if run_check fchown 'fchown(2)' << \!
1789 #include <unistd.h>
1790 # include <errno.h>
1791 int main(void){
1792 if(!fchown(0, 0, 0) || errno != ENOSYS)
1793 return 0;
1794 return 1;
1797 then
1799 else
1800 feat_bail_required DOTLOCK
1804 ## Now it is the time to fork away the BASE_ series
1806 ${rm} -f ${tmp}
1807 squeeze_em ${inc} ${tmp}
1808 ${mv} ${tmp} ${inc}
1809 squeeze_em ${lib} ${tmp}
1810 ${mv} ${tmp} ${lib}
1812 echo "BASE_LIBS = `${cat} ${lib}`" >> ${mk}
1813 echo "BASE_INCS = `${cat} ${inc}`" >> ${mk}
1815 ## The remains are expected to be used only by the main MUA binary!
1817 OPT_LOCALES=0
1818 link_check setlocale 'setlocale(3)' '#define HAVE_SETLOCALE' << \!
1819 #include <locale.h>
1820 int main(void){
1821 setlocale(LC_ALL, "");
1822 return 0;
1825 [ -n "${have_setlocale}" ] && OPT_LOCALES=1
1827 OPT_MULTIBYTE_CHARSETS=0
1828 OPT_WIDE_GLYPHS=0
1829 OPT_TERMINAL_CHARSET=0
1830 if [ -n "${have_setlocale}" ]; then
1831 link_check c90amend1 'ISO/IEC 9899:1990/Amendment 1:1995' \
1832 '#define HAVE_C90AMEND1' << \!
1833 #include <limits.h>
1834 #include <stdlib.h>
1835 #include <wchar.h>
1836 #include <wctype.h>
1837 int main(void){
1838 char mbb[MB_LEN_MAX + 1];
1839 wchar_t wc;
1841 iswprint(L'c');
1842 towupper(L'c');
1843 mbtowc(&wc, "x", 1);
1844 mbrtowc(&wc, "x", 1, NULL);
1845 wctomb(mbb, wc);
1846 return (mblen("\0", 1) == 0);
1849 [ -n "${have_c90amend1}" ] && OPT_MULTIBYTE_CHARSETS=1
1851 if [ -n "${have_c90amend1}" ]; then
1852 link_check wcwidth 'wcwidth(3)' '#define HAVE_WCWIDTH' << \!
1853 #include <wchar.h>
1854 int main(void){
1855 wcwidth(L'c');
1856 return 0;
1859 [ -n "${have_wcwidth}" ] && OPT_WIDE_GLYPHS=1
1862 link_check nl_langinfo 'nl_langinfo(3)' '#define HAVE_NL_LANGINFO' << \!
1863 #include <langinfo.h>
1864 #include <stdlib.h>
1865 int main(void){
1866 nl_langinfo(DAY_1);
1867 return (nl_langinfo(CODESET) == NULL);
1870 [ -n "${have_nl_langinfo}" ] && OPT_TERMINAL_CHARSET=1
1871 fi # have_setlocale
1873 link_check fnmatch 'fnmatch(3)' '#define HAVE_FNMATCH' << \!
1874 #include <fnmatch.h>
1875 int main(void){
1876 return (fnmatch("*", ".", FNM_PATHNAME | FNM_PERIOD) == FNM_NOMATCH);
1880 link_check dirent_d_type 'struct dirent.d_type' '#define HAVE_DIRENT_TYPE' << \!
1881 #include <dirent.h>
1882 int main(void){
1883 struct dirent de;
1884 return !(de.d_type == DT_UNKNOWN ||
1885 de.d_type == DT_DIR || de.d_type == DT_LNK);
1889 ## optional and selectable
1891 if feat_yes ICONV; then
1892 ${cat} > ${tmp2}.c << \!
1893 #include <stdio.h> /* For C89 NULL */
1894 #include <iconv.h>
1895 int main(void){
1896 iconv_t id;
1898 id = iconv_open("foo", "bar");
1899 iconv(id, NULL, NULL, NULL, NULL);
1900 iconv_close(id);
1901 return 0;
1904 < ${tmp2}.c link_check iconv 'iconv(3) functionality' \
1905 '#define HAVE_ICONV' ||
1906 < ${tmp2}.c link_check iconv 'iconv(3) functionality (via -liconv)' \
1907 '#define HAVE_ICONV' '-liconv' ||
1908 feat_bail_required ICONV
1909 else
1910 echo '/* OPT_ICONV=0 */' >> ${h}
1911 fi # feat_yes ICONV
1913 if feat_yes SOCKETS || feat_yes SPAM_SPAMD; then
1914 ${cat} > ${tmp2}.c << \!
1915 #include <sys/types.h>
1916 #include <sys/socket.h>
1917 #include <sys/un.h>
1918 # include <errno.h>
1919 int main(void){
1920 struct sockaddr_un soun;
1922 if(socket(AF_UNIX, SOCK_STREAM, 0) == -1 && errno == ENOSYS)
1923 return 1;
1924 if(connect(0, (struct sockaddr*)&soun, 0) == -1 && errno == ENOSYS)
1925 return 1;
1926 if(shutdown(0, SHUT_RD | SHUT_WR | SHUT_RDWR) == -1 && errno == ENOSYS)
1927 return 1;
1928 return 0;
1932 < ${tmp2}.c run_check af_unix 'AF_UNIX sockets' \
1933 '#define HAVE_UNIX_SOCKETS' ||
1934 < ${tmp2}.c run_check af_unix 'AF_UNIX sockets (via -lnsl)' \
1935 '#define HAVE_UNIX_SOCKETS' '-lnsl' ||
1936 < ${tmp2}.c run_check af_unix 'AF_UNIX sockets (via -lsocket -lnsl)' \
1937 '#define HAVE_UNIX_SOCKETS' '-lsocket -lnsl'
1940 if feat_yes SOCKETS; then
1941 ${cat} > ${tmp2}.c << \!
1942 #include <sys/types.h>
1943 #include <sys/socket.h>
1944 #include <netinet/in.h>
1945 # include <errno.h>
1946 int main(void){
1947 struct sockaddr s;
1949 if(socket(AF_INET, SOCK_STREAM, 0) == -1 && errno == ENOSYS)
1950 return 1;
1951 if(connect(0, &s, 0) == -1 && errno == ENOSYS)
1952 return 1;
1953 return 0;
1957 < ${tmp2}.c run_check sockets 'sockets' \
1958 '#define HAVE_SOCKETS' ||
1959 < ${tmp2}.c run_check sockets 'sockets (via -lnsl)' \
1960 '#define HAVE_SOCKETS' '-lnsl' ||
1961 < ${tmp2}.c run_check sockets 'sockets (via -lsocket -lnsl)' \
1962 '#define HAVE_SOCKETS' '-lsocket -lnsl' ||
1963 feat_bail_required SOCKETS
1964 else
1965 echo '/* OPT_SOCKETS=0 */' >> ${h}
1966 fi # feat_yes SOCKETS
1968 if feat_yes SOCKETS; then
1969 link_check getaddrinfo 'getaddrinfo(3)' \
1970 '#define HAVE_GETADDRINFO' << \!
1971 #include <sys/types.h>
1972 #include <sys/socket.h>
1973 #include <stdio.h>
1974 #include <netdb.h>
1975 int main(void){
1976 struct addrinfo a, *ap;
1977 int lrv;
1979 switch((lrv = getaddrinfo("foo", "0", &a, &ap))){
1980 case EAI_NONAME:
1981 case EAI_SERVICE:
1982 default:
1983 fprintf(stderr, "%s\n", gai_strerror(lrv));
1984 case 0:
1985 break;
1987 return 0;
1992 if feat_yes SOCKETS && [ -z "${have_getaddrinfo}" ]; then
1993 compile_check arpa_inet_h '<arpa/inet.h>' \
1994 '#define HAVE_ARPA_INET_H' << \!
1995 #include <sys/types.h>
1996 #include <sys/socket.h>
1997 #include <netdb.h>
1998 #include <netinet/in.h>
1999 #include <arpa/inet.h>
2002 ${cat} > ${tmp2}.c << \!
2003 #include <sys/types.h>
2004 #include <sys/socket.h>
2005 #include <stdio.h>
2006 #include <string.h>
2007 #include <netdb.h>
2008 #include <netinet/in.h>
2009 #ifdef HAVE_ARPA_INET_H
2010 #include <arpa/inet.h>
2011 #endif
2012 int main(void){
2013 struct sockaddr_in servaddr;
2014 unsigned short portno;
2015 struct servent *ep;
2016 struct hostent *hp;
2017 struct in_addr **pptr;
2019 portno = 0;
2020 if((ep = getservbyname("POPPY-PORT", "tcp")) != NULL)
2021 portno = (unsigned short)ep->s_port;
2023 if((hp = gethostbyname("POPPY-HOST")) != NULL){
2024 pptr = (struct in_addr**)hp->h_addr_list;
2025 if(hp->h_addrtype != AF_INET)
2026 fprintf(stderr, "au\n");
2027 }else{
2028 switch(h_errno){
2029 case HOST_NOT_FOUND:
2030 case TRY_AGAIN:
2031 case NO_RECOVERY:
2032 case NO_DATA:
2033 break;
2034 default:
2035 fprintf(stderr, "au\n");
2036 break;
2040 memset(&servaddr, 0, sizeof servaddr);
2041 servaddr.sin_family = AF_INET;
2042 servaddr.sin_port = htons(portno);
2043 memcpy(&servaddr.sin_addr, *pptr, sizeof(struct in_addr));
2044 fprintf(stderr, "Would connect to %s:%d ...\n",
2045 inet_ntoa(**pptr), (int)portno);
2046 return 0;
2050 < ${tmp2}.c link_check gethostbyname 'get(serv|host)byname(3)' ||
2051 < ${tmp2}.c link_check gethostbyname \
2052 'get(serv|host)byname(3) (via -nsl)' '' '-lnsl' ||
2053 < ${tmp2}.c link_check gethostbyname \
2054 'get(serv|host)byname(3) (via -lsocket -nsl)' \
2055 '' '-lsocket -lnsl' ||
2056 feat_bail_required SOCKETS
2059 feat_yes SOCKETS &&
2060 run_check setsockopt 'setsockopt(2)' '#define HAVE_SETSOCKOPT' << \!
2061 #include <sys/socket.h>
2062 #include <stdlib.h>
2063 # include <errno.h>
2064 int main(void){
2065 int sockfd = 3;
2067 if(setsockopt(sockfd, SOL_SOCKET, SO_KEEPALIVE, NULL, 0) == -1 &&
2068 errno == ENOSYS)
2069 return 1;
2070 return 0;
2074 feat_yes SOCKETS && [ -n "${have_setsockopt}" ] &&
2075 link_check so_sndtimeo 'SO_SNDTIMEO' '#define HAVE_SO_SNDTIMEO' << \!
2076 #include <sys/socket.h>
2077 #include <stdlib.h>
2078 int main(void){
2079 struct timeval tv;
2080 int sockfd = 3;
2082 tv.tv_sec = 42;
2083 tv.tv_usec = 21;
2084 setsockopt(sockfd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof tv);
2085 setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof tv);
2086 return 0;
2090 feat_yes SOCKETS && [ -n "${have_setsockopt}" ] &&
2091 link_check so_linger 'SO_LINGER' '#define HAVE_SO_LINGER' << \!
2092 #include <sys/socket.h>
2093 #include <stdlib.h>
2094 int main(void){
2095 struct linger li;
2096 int sockfd = 3;
2098 li.l_onoff = 1;
2099 li.l_linger = 42;
2100 setsockopt(sockfd, SOL_SOCKET, SO_LINGER, &li, sizeof li);
2101 return 0;
2105 if feat_yes SSL; then # {{{
2106 # {{{ LibreSSL decided to define OPENSSL_VERSION_NUMBER with a useless value
2107 # instead of keeping it at the one that corresponds to the OpenSSL at fork
2108 # time: we need to test it first in order to get things right
2109 if compile_check _xssl 'TLS/SSL (LibreSSL)' \
2110 '#define HAVE_SSL
2111 #define HAVE_XSSL
2112 #define HAVE_XSSL_RESSL
2113 #define HAVE_XSSL_OPENSSL 0' << \!
2114 #include <openssl/opensslv.h>
2115 #ifdef LIBRESSL_VERSION_NUMBER
2116 #else
2117 # error nope
2118 #endif
2120 then
2121 ossl_v1_1=
2122 # TODO OPENSSL_IS_BORINGSSL, but never tried that one!
2123 elif compile_check _xssl 'TLS/SSL (OpenSSL >= v1.1.0)' \
2124 '#define HAVE_SSL
2125 #define HAVE_XSSL
2126 #define HAVE_XSSL_OPENSSL 0x10100' << \!
2127 #include <openssl/opensslv.h>
2128 #if OPENSSL_VERSION_NUMBER + 0 >= 0x10100000L
2129 #else
2130 # error nope
2131 #endif
2133 then
2134 ossl_v1_1=1
2135 elif compile_check _xssl 'TLS/SSL (OpenSSL)' \
2136 '#define HAVE_SSL
2137 #define HAVE_XSSL
2138 #define HAVE_XSSL_OPENSSL 0x10000' << \!
2139 #include <openssl/opensslv.h>
2140 #ifdef OPENSSL_VERSION_NUMBER
2141 #else
2142 # error nope
2143 #endif
2145 then
2146 ossl_v1_1=
2147 else
2148 feat_bail_required SSL
2149 fi # }}}
2151 if feat_yes SSL; then # {{{
2152 if [ -n "${ossl_v1_1}" ]; then
2153 without_check yes xssl 'TLS/SSL (new style *_client_method(3ssl))' \
2154 '#define n_XSSL_CLIENT_METHOD TLS_client_method' \
2155 '-lssl -lcrypto'
2156 elif link_check xssl 'TLS/SSL (new style *_client_method(3ssl))' \
2157 '#define n_XSSL_CLIENT_METHOD TLS_client_method' \
2158 '-lssl -lcrypto' << \!
2159 #include <openssl/ssl.h>
2160 #include <openssl/err.h>
2161 #include <openssl/x509v3.h>
2162 #include <openssl/x509.h>
2163 #include <openssl/rand.h>
2164 #ifdef OPENSSL_NO_TLS1 /* TODO only deduced from OPENSSL_NO_SSL[23]! */
2165 # error We need TLSv1.
2166 #endif
2167 int main(void){
2168 SSL_CTX *ctx = SSL_CTX_new(TLS_client_method());
2170 SSL_CTX_free(ctx);
2171 PEM_read_PrivateKey(0, 0, 0, 0);
2172 return 0;
2175 then
2177 elif link_check xssl 'TLS/SSL (old style *_client_method(3ssl))' \
2178 '#define n_XSSL_CLIENT_METHOD SSLv23_client_method' \
2179 '-lssl -lcrypto' << \!
2180 #include <openssl/ssl.h>
2181 #include <openssl/err.h>
2182 #include <openssl/x509v3.h>
2183 #include <openssl/x509.h>
2184 #include <openssl/rand.h>
2185 #if defined OPENSSL_NO_SSL3 &&\
2186 defined OPENSSL_NO_TLS1 /* TODO only deduced from OPENSSL_NO_SSL[23]! */
2187 # error We need one of SSLv3 and TLSv1.
2188 #endif
2189 int main(void){
2190 SSL_CTX *ctx = SSL_CTX_new(SSLv23_client_method());
2192 SSL_CTX_free(ctx);
2193 PEM_read_PrivateKey(0, 0, 0, 0);
2194 return 0;
2197 then
2199 else
2200 feat_bail_required SSL
2202 fi # }}}
2204 if feat_yes SSL; then # {{{
2205 if [ -n "${ossl_v1_1}" ]; then
2206 without_check yes xssl_stack_of 'TLS/SSL STACK_OF()' \
2207 '#define HAVE_XSSL_STACK_OF'
2208 elif compile_check xssl_stack_of 'TLS/SSL STACK_OF()' \
2209 '#define HAVE_XSSL_STACK_OF' << \!
2210 #include <stdio.h> /* For C89 NULL */
2211 #include <openssl/ssl.h>
2212 #include <openssl/err.h>
2213 #include <openssl/x509v3.h>
2214 #include <openssl/x509.h>
2215 #include <openssl/rand.h>
2216 int main(void){
2217 STACK_OF(GENERAL_NAME) *gens = NULL;
2219 printf("%p", gens); /* to use it */
2220 return 0;
2223 then
2227 if [ -n "${ossl_v1_1}" ]; then
2228 without_check yes xssl_conf 'TLS/SSL OpenSSL_modules_load_file()' \
2229 '#define HAVE_XSSL_CONFIG'
2230 elif link_check xssl_conf 'TLS/SSL OpenSSL_modules_load_file() support' \
2231 '#define HAVE_XSSL_CONFIG' << \!
2232 #include <stdio.h> /* For C89 NULL */
2233 #include <openssl/conf.h>
2234 int main(void){
2235 CONF_modules_load_file(NULL, NULL, CONF_MFLAGS_IGNORE_MISSING_FILE);
2236 CONF_modules_free();
2237 return 0;
2240 then
2244 if [ -n "${ossl_v1_1}" ]; then
2245 without_check yes xssl_conf_ctx 'TLS/SSL SSL_CONF_CTX support' \
2246 '#define HAVE_XSSL_CONF_CTX'
2247 elif link_check xssl_conf_ctx 'TLS/SSL SSL_CONF_CTX support' \
2248 '#define HAVE_XSSL_CONF_CTX' << \!
2249 #include <openssl/ssl.h>
2250 #include <openssl/err.h>
2251 int main(void){
2252 SSL_CTX *ctx = SSL_CTX_new(n_XSSL_CLIENT_METHOD());
2253 SSL_CONF_CTX *cctx = SSL_CONF_CTX_new();
2255 SSL_CONF_CTX_set_flags(cctx,
2256 SSL_CONF_FLAG_FILE | SSL_CONF_FLAG_CLIENT |
2257 SSL_CONF_FLAG_CERTIFICATE | SSL_CONF_FLAG_SHOW_ERRORS);
2258 SSL_CONF_CTX_set_ssl_ctx(cctx, ctx);
2259 SSL_CONF_cmd(cctx, "Protocol", "ALL");
2260 SSL_CONF_CTX_finish(cctx);
2261 SSL_CONF_CTX_free(cctx);
2262 SSL_CTX_free(ctx);
2263 return 0;
2266 then
2270 if [ -n "${ossl_v1_1}" ]; then
2271 without_check no xssl_rand_egd 'TLS/SSL RAND_egd(3ssl)' \
2272 '#define HAVE_XSSL_RAND_EGD'
2273 elif link_check xssl_rand_egd 'TLS/SSL RAND_egd(3ssl)' \
2274 '#define HAVE_XSSL_RAND_EGD' << \!
2275 #include <openssl/rand.h>
2276 int main(void){
2277 return RAND_egd("some.where") > 0;
2280 then
2284 if feat_yes SSL_ALL_ALGORITHMS; then
2285 if [ -n "${ossl_v1_1}" ]; then
2286 without_check yes ssl_all_algo 'TLS/SSL all-algorithms support' \
2287 '#define HAVE_SSL_ALL_ALGORITHMS'
2288 elif link_check ssl_all_algo 'TLS/SSL all-algorithms support' \
2289 '#define HAVE_SSL_ALL_ALGORITHMS' << \!
2290 #include <openssl/evp.h>
2291 int main(void){
2292 OpenSSL_add_all_algorithms();
2293 EVP_get_cipherbyname("two cents i never exist");
2294 EVP_cleanup();
2295 return 0;
2298 then
2300 else
2301 feat_bail_required SSL_ALL_ALGORITHMS
2304 fi # feat_yes SSL }}}
2306 if feat_yes SSL && feat_yes MD5 && feat_no NOEXTMD5; then # {{{
2307 run_check ssl_md5 'MD5 digest in the used crypto library' \
2308 '#define HAVE_XSSL_MD5' << \!
2309 #include <stdlib.h>
2310 #include <string.h>
2311 #include <openssl/md5.h>
2312 int main(void){
2313 char const dat[] = "abrakadabrafidibus";
2314 char dig[16], hex[16 * 2];
2315 MD5_CTX ctx;
2316 size_t i, j;
2318 memset(dig, 0, sizeof(dig));
2319 memset(hex, 0, sizeof(hex));
2320 MD5_Init(&ctx);
2321 MD5_Update(&ctx, dat, sizeof(dat) - 1);
2322 MD5_Final(dig, &ctx);
2324 #define hexchar(n) ((n) > 9 ? (n) - 10 + 'a' : (n) + '0')
2325 for(i = 0; i < sizeof(hex) / 2; i++){
2326 j = i << 1;
2327 hex[j] = hexchar((dig[i] & 0xf0) >> 4);
2328 hex[++j] = hexchar(dig[i] & 0x0f);
2330 return !!memcmp("6d7d0a3d949da2e96f2aa010f65d8326", hex, sizeof(hex));
2333 fi # }}}
2334 else
2335 echo '/* OPT_SSL=0 */' >> ${h}
2336 fi # }}} feat_yes SSL
2338 if [ "${have_xssl}" = yes ]; then
2339 OPT_SMIME=1
2340 else
2341 OPT_SMIME=0
2343 feat_def SMIME
2345 feat_def SMTP
2346 feat_def POP3
2347 feat_def IMAP
2349 if feat_yes GSSAPI; then
2350 ${cat} > ${tmp2}.c << \!
2351 #include <gssapi/gssapi.h>
2352 int main(void){
2353 gss_import_name(0, 0, GSS_C_NT_HOSTBASED_SERVICE, 0);
2354 gss_init_sec_context(0,0,0,0,0,0,0,0,0,0,0,0,0);
2355 return 0;
2358 ${sed} -e '1s/gssapi\///' < ${tmp2}.c > ${tmp3}.c
2360 if command -v krb5-config >/dev/null 2>&1; then
2361 i=`command -v krb5-config`
2362 GSS_LIBS="`CFLAGS= ${i} --libs gssapi`"
2363 GSS_INCS="`CFLAGS= ${i} --cflags`"
2364 i='GSS-API via krb5-config(1)'
2365 else
2366 GSS_LIBS='-lgssapi'
2367 GSS_INCS=
2368 i='GSS-API in gssapi/gssapi.h, libgssapi'
2370 if < ${tmp2}.c link_check gss \
2371 "${i}" '#define HAVE_GSSAPI' "${GSS_LIBS}" "${GSS_INCS}" ||\
2372 < ${tmp3}.c link_check gss \
2373 'GSS-API in gssapi.h, libgssapi' \
2374 '#define HAVE_GSSAPI
2375 #define GSSAPI_REG_INCLUDE' \
2376 '-lgssapi' ||\
2377 < ${tmp2}.c link_check gss 'GSS-API in libgssapi_krb5' \
2378 '#define HAVE_GSSAPI' \
2379 '-lgssapi_krb5' ||\
2380 < ${tmp3}.c link_check gss \
2381 'GSS-API in libgssapi, OpenBSD-style (pre 5.3)' \
2382 '#define HAVE_GSSAPI
2383 #define GSS_REG_INCLUDE' \
2384 '-lgssapi -lkrb5 -lcrypto' \
2385 '-I/usr/include/kerberosV' ||\
2386 < ${tmp2}.c link_check gss 'GSS-API in libgss' \
2387 '#define HAVE_GSSAPI' \
2388 '-lgss' ||\
2389 link_check gss 'GSS-API in libgssapi_krb5, old-style' \
2390 '#define HAVE_GSSAPI
2391 #define GSSAPI_OLD_STYLE' \
2392 '-lgssapi_krb5' << \!
2393 #include <gssapi/gssapi.h>
2394 #include <gssapi/gssapi_generic.h>
2395 int main(void){
2396 gss_import_name(0, 0, gss_nt_service_name, 0);
2397 gss_init_sec_context(0,0,0,0,0,0,0,0,0,0,0,0,0);
2398 return 0;
2401 then
2403 else
2404 feat_bail_required GSSAPI
2406 else
2407 echo '/* OPT_GSSAPI=0 */' >> ${h}
2408 fi # feat_yes GSSAPI
2410 feat_def NETRC
2411 feat_def AGENT
2413 if feat_yes IDNA; then
2414 if link_check idna 'GNU Libidn' '#define HAVE_IDNA HAVE_IDNA_LIBIDNA' \
2415 '-lidn' << \!
2416 #include <idna.h>
2417 #include <idn-free.h>
2418 #include <stringprep.h>
2419 int main(void){
2420 char *utf8, *idna_ascii, *idna_utf8;
2422 utf8 = stringprep_locale_to_utf8("does.this.work");
2423 if (idna_to_ascii_8z(utf8, &idna_ascii, IDNA_USE_STD3_ASCII_RULES)
2424 != IDNA_SUCCESS)
2425 return 1;
2426 idn_free(idna_ascii);
2427 /* (Rather link check only here) */
2428 idna_utf8 = stringprep_convert(idna_ascii, "UTF-8", "de_DE");
2429 return 0;
2432 then
2434 elif link_check idna 'idnkit' '#define HAVE_IDNA HAVE_IDNA_IDNKIT' \
2435 '-lidnkit' << \!
2436 #include <stdio.h>
2437 #include <idn/api.h>
2438 #include <idn/result.h>
2439 int main(void){
2440 idn_result_t r;
2441 char ace_name[256];
2442 char local_name[256];
2444 r = idn_encodename(IDN_ENCODE_APP, "does.this.work", ace_name,
2445 sizeof(ace_name));
2446 if (r != idn_success) {
2447 fprintf(stderr, "idn_encodename failed: %s\n", idn_result_tostring(r));
2448 return 1;
2450 r = idn_decodename(IDN_DECODE_APP, ace_name, local_name, sizeof(local_name));
2451 if (r != idn_success) {
2452 fprintf(stderr, "idn_decodename failed: %s\n", idn_result_tostring(r));
2453 return 1;
2455 return 0;
2458 then
2460 else
2461 feat_bail_required IDNA
2464 if [ -n "${have_idna}" ]; then
2465 echo '#define HAVE_IDNA_LIBIDNA 0' >> ${h}
2466 echo '#define HAVE_IDNA_IDNKIT 1' >> ${h}
2468 else
2469 echo '/* OPT_IDNA=0 */' >> ${h}
2472 feat_def IMAP_SEARCH
2474 if feat_yes REGEX; then
2475 if link_check regex 'regular expressions' '#define HAVE_REGEX' << \!
2476 #include <regex.h>
2477 #include <stdlib.h>
2478 int main(void){
2479 size_t xret;
2480 int status;
2481 regex_t re;
2483 status = regcomp(&re, ".*bsd", REG_EXTENDED | REG_ICASE | REG_NOSUB);
2484 xret = regerror(status, &re, NULL, 0);
2485 status = regexec(&re, "plan9", 0,NULL, 0);
2486 regfree(&re);
2487 return !(status == REG_NOMATCH);
2490 then
2492 else
2493 feat_bail_required REGEX
2495 else
2496 echo '/* OPT_REGEX=0 */' >> ${h}
2499 if feat_yes MLE && [ -n "${have_c90amend1}" ]; then
2500 have_mle=1
2501 echo '#define HAVE_MLE' >> ${h}
2502 else
2503 feat_bail_required MLE
2504 echo '/* OPT_MLE=0 */' >> ${h}
2507 # Generic have-a-line-editor switch for those who need it below
2508 if [ -n "${have_mle}" ]; then
2509 have_cle=1
2512 if [ -n "${have_cle}" ] && feat_yes HISTORY; then
2513 echo '#define HAVE_HISTORY' >> ${h}
2514 else
2515 echo '/* OPT_HISTORY=0 */' >> ${h}
2518 if [ -n "${have_mle}" ] && feat_yes KEY_BINDINGS; then
2519 echo '#define HAVE_KEY_BINDINGS' >> ${h}
2520 else
2521 echo '/* OPT_KEY_BINDINGS=0 */' >> ${h}
2524 if feat_yes TERMCAP; then
2525 __termcaplib() {
2526 link_check termcap "termcap(5) (via ${4})" \
2527 "#define HAVE_TERMCAP${3}" "${1}" << _EOT
2528 #include <stdio.h>
2529 #include <stdlib.h>
2530 ${2}
2531 #include <term.h>
2532 #define UNCONST(P) ((void*)(unsigned long)(void const*)(P))
2533 static int my_putc(int c){return putchar(c);}
2534 int main(void){
2535 char buf[1024+512], cmdbuf[2048], *cpb, *r1;
2536 int r2 = OK, r3 = ERR;
2538 tgetent(buf, getenv("TERM"));
2539 cpb = cmdbuf;
2540 r1 = tgetstr(UNCONST("cm"), &cpb);
2541 tgoto(r1, 1, 1);
2542 r2 = tgetnum(UNCONST("Co"));
2543 r3 = tgetflag(UNCONST("ut"));
2544 tputs("cr", 1, &my_putc);
2545 return (r1 == NULL || r2 == -1 || r3 == 0);
2547 _EOT
2550 __terminfolib() {
2551 link_check terminfo "terminfo(5) (via ${2})" \
2552 '#define HAVE_TERMCAP
2553 #define HAVE_TERMCAP_CURSES
2554 #define HAVE_TERMINFO' "${1}" << _EOT
2555 #include <stdio.h>
2556 #include <curses.h>
2557 #include <term.h>
2558 #define UNCONST(P) ((void*)(unsigned long)(void const*)(P))
2559 static int my_putc(int c){return putchar(c);}
2560 int main(void){
2561 int er, r0, r1, r2;
2562 char *r3, *tp;
2564 er = OK;
2565 r0 = setupterm(NULL, 1, &er);
2566 r1 = tigetflag(UNCONST("bce"));
2567 r2 = tigetnum(UNCONST("colors"));
2568 r3 = tigetstr(UNCONST("cr"));
2569 tp = tparm(r3, NULL, NULL, 0,0,0,0,0,0,0);
2570 tputs(tp, 1, &my_putc);
2571 return (r0 == ERR || r1 == -1 || r2 == -2 || r2 == -1 ||
2572 r3 == (char*)-1 || r3 == NULL);
2574 _EOT
2577 if feat_yes TERMCAP_VIA_TERMINFO; then
2578 __terminfolib -ltinfo -ltinfo ||
2579 __terminfolib -lcurses -lcurses ||
2580 __terminfolib -lcursesw -lcursesw ||
2581 feat_bail_required TERMCAP_VIA_TERMINFO
2584 if [ -z "${have_terminfo}" ]; then
2585 __termcaplib -ltermcap '' '' '-ltermcap' ||
2586 __termcaplib -ltermcap '#include <curses.h>' '
2587 #define HAVE_TERMCAP_CURSES' \
2588 'curses.h / -ltermcap' ||
2589 __termcaplib -lcurses '#include <curses.h>' '
2590 #define HAVE_TERMCAP_CURSES' \
2591 'curses.h / -lcurses' ||
2592 __termcaplib -lcursesw '#include <curses.h>' '
2593 #define HAVE_TERMCAP_CURSES' \
2594 'curses.h / -lcursesw' ||
2595 feat_bail_required TERMCAP
2597 if [ -n "${have_termcap}" ]; then
2598 run_check tgetent_null \
2599 "tgetent(3) of termcap(5) takes NULL buffer" \
2600 "#define HAVE_TGETENT_NULL_BUF" << _EOT
2601 #include <stdio.h> /* For C89 NULL */
2602 #include <stdlib.h>
2603 #ifdef HAVE_TERMCAP_CURSES
2604 # include <curses.h>
2605 #endif
2606 #include <term.h>
2607 int main(void){
2608 tgetent(NULL, getenv("TERM"));
2609 return 0;
2611 _EOT
2614 else
2615 echo '/* OPT_TERMCAP=0 */' >> ${h}
2616 echo '/* OPT_TERMCAP_VIA_TERMINFO=0 */' >> ${h}
2619 if feat_def SPAM_SPAMC; then
2620 if command -v spamc >/dev/null 2>&1; then
2621 echo "#define SPAM_SPAMC_PATH \"`command -v spamc`\"" >> ${h}
2625 if feat_yes SPAM_SPAMD && [ -n "${have_af_unix}" ]; then
2626 echo '#define HAVE_SPAM_SPAMD' >> ${h}
2627 else
2628 feat_bail_required SPAM_SPAMD
2629 echo '/* OPT_SPAM_SPAMD=0 */' >> ${h}
2632 feat_def SPAM_FILTER
2634 if feat_yes SPAM_SPAMC || feat_yes SPAM_SPAMD || feat_yes SPAM_FILTER; then
2635 echo '#define HAVE_SPAM' >> ${h}
2636 else
2637 echo '/* HAVE_SPAM */' >> ${h}
2640 if feat_yes QUOTE_FOLD &&\
2641 [ -n "${have_c90amend1}" ] && [ -n "${have_wcwidth}" ]; then
2642 echo '#define HAVE_QUOTE_FOLD' >> ${h}
2643 else
2644 feat_bail_required QUOTE_FOLD
2645 echo '/* OPT_QUOTE_FOLD=0 */' >> ${h}
2648 feat_def FILTER_HTML_TAGSOUP
2649 feat_def COLOUR
2650 feat_def DOTLOCK
2651 feat_def MD5
2652 feat_def NOMEMDBG
2654 ## Summarizing
2656 ${rm} -f ${tmp}
2657 squeeze_em ${inc} ${tmp}
2658 ${mv} ${tmp} ${inc}
2659 squeeze_em ${lib} ${tmp}
2660 ${mv} ${tmp} ${lib}
2662 # mk-config.h
2663 ${mv} ${h} ${tmp}
2664 printf '#ifndef n_MK_CONFIG_H\n# define n_MK_CONFIG_H 1\n' > ${h}
2665 ${cat} ${tmp} >> ${h}
2666 ${rm} -f ${tmp}
2667 printf '\n' >> ${h}
2669 # Create the string that is used by *features* and `version'.
2670 # Take this nice opportunity and generate a visual listing of included and
2671 # non-included features for the person who runs the configuration
2672 msg '\nThe following features are included (+) or not (-):'
2673 set -- ${OPTIONS_DETECT} ${OPTIONS} ${OPTIONS_XTRA}
2674 printf '/* The "feature string" */\n' >> ${h}
2675 # Because + is expanded by *folder* if first in "echo $features", put something
2676 printf '#define VAL_FEATURES_CNT '${#}'\n#define VAL_FEATURES "#' >> ${h}
2677 sep=
2678 for opt
2680 sdoc=`option_doc_of ${opt}`
2681 [ -z "${sdoc}" ] && continue
2682 sopt="`echo ${opt} | ${tr} '[A-Z]_' '[a-z]-'`"
2683 feat_yes ${opt} && sign=+ || sign=-
2684 printf -- "${sep}${sign}${sopt}" >> ${h}
2685 sep=','
2686 msg " %s %s: %s" ${sign} ${sopt} "${sdoc}"
2687 done
2688 # TODO instead of using sh+tr+awk+printf, use awk, drop option_doc_of, inc here
2689 #exec 5>&1 >>${h}
2690 #${awk} -v opts="${OPTIONS_DETECT} ${OPTIONS} ${OPTIONS_XTRA}" \
2691 # -v xopts="${XOPTIONS_DETECT} ${XOPTIONS} ${XOPTIONS_XTRA}" \
2692 printf '"\n' >> ${h}
2694 # Create the real mk-config.mk
2695 # Note we cannout use explicit ./ filename prefix for source and object
2696 # pathnames because of a bug in bmake(1)
2697 ${rm} -rf ${tmp0}.* ${tmp0}*
2698 printf 'OBJ_SRC = ' >> ${mk}
2699 if feat_no AMALGAMATION; then
2700 for i in `printf '%s\n' *.c | ${sort}`; do
2701 if [ "${i}" = privsep.c ]; then
2702 continue
2704 printf "${i} " >> ${mk}
2705 done
2706 printf '\nAMALGAM_TARGET =\nAMALGAM_DEP =\n' >> ${mk}
2707 else
2708 printf 'main.c\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' *.c | ${sort}`; do
2715 if [ "${i}" = "${j}" ] || [ "${i}" = main.c ] || \
2716 [ "${i}" = privsep.c ]; then
2717 continue
2719 printf "${i} " >> ${mk}
2720 printf "# include \"${i}\"\n" >> ${h}
2721 done
2722 echo >> ${mk}
2725 printf '#endif /* n_MK_CONFIG_H */\n' >> ${h}
2727 echo "LIBS = `${cat} ${lib}`" >> ${mk}
2728 echo "INCS = `${cat} ${inc}`" >> ${mk}
2729 echo >> ${mk}
2730 ${cat} ./make-config.in >> ${mk}
2732 ## Finished!
2734 msg '\nSetup:'
2735 msg ' . System-wide resource file: %s/%s' "${VAL_SYSCONFDIR}" "${VAL_SYSCONFRC}"
2736 msg ' . bindir: %s' "${VAL_BINDIR}"
2737 if feat_yes DOTLOCK; then
2738 msg ' . libexecdir: %s' "${VAL_LIBEXECDIR}"
2740 msg ' . mandir: %s' "${VAL_MANDIR}"
2741 msg ' . M(ail)T(ransfer)A(gent): %s (argv0 %s)' "${VAL_MTA}" "${VAL_MTA_ARGV0}"
2742 msg ' . $MAIL spool directory: %s' "${VAL_MAIL}"
2743 msg ''
2745 if [ -n "${have_fnmatch}" ] && [ -n "${have_fchdir}" ]; then
2746 exit 0
2748 msg 'Remarks:'
2749 if [ -z "${have_fnmatch}" ]; then
2750 msg ' . The function fnmatch(3) could not be found.'
2751 msg ' Filename patterns like wildcard are not supported on your system'
2753 if [ -z "${have_fchdir}" ]; then
2754 msg ' . The function fchdir(2) could not be found.'
2755 msg ' We will use chdir(2) instead.'
2756 msg ' This is a problem only if the current working directory is changed'
2757 msg ' while this program is inside of it'
2759 msg ''
2761 # s-it-mode