2 #@ Please see INSTALL and make.rc instead.
7 # For heaven's sake auto-redirect on SunOS/Solaris
8 if [ "x${SHELL}" = x
] ||
[ "${SHELL}" = /bin
/sh
] && \
9 [ -f /usr
/xpg
4/bin
/sh
] && [ -x /usr
/xpg
4/bin
/sh
]; then
10 SHELL
=/usr
/xpg
4/bin
/sh
12 exec /usr
/xpg
4/bin
/sh
"${0}" "${@}"
14 [ -n "${SHELL}" ] || SHELL
=/bin
/sh
17 # The feature set, to be kept in sync with make.rc
18 # If no documentation given, the option is used as such; if doc is a hyphen,
19 # entry is suppressed when configuration overview is printed, and also in the
20 # *features* string: most likely for obsolete features etc.
22 ICONV='Character set conversion using iconv(3)' \
23 SOCKETS='Network support' \
24 SSL='SSL/TLS (OpenSSL / LibreSSL)' \
25 SSL_ALL_ALGORITHMS='Support of all digest and cipher algorithms' \
26 SMTP='Simple Mail Transfer Protocol client' \
27 POP3='Post Office Protocol Version 3 client' \
28 IMAP='IMAP v4r1 client' \
29 GSSAPI='Generic Security Service authentication' \
30 NETRC='.netrc file support' \
32 MD5='MD5 message digest (APOP, CRAM-MD5)' \
33 IDNA='Internationalized Domain Names for Applications (encode only)' \
34 IMAP_SEARCH='IMAP-style search expressions' \
35 REGEX='Regular expressions' \
36 MLE='Mailx Line Editor' \
37 HISTORY='Line editor history management' \
38 KEY_BINDINGS='Configurable key bindings' \
39 TERMCAP='Terminal capability queries (termcap(5))' \
40 TERMCAP_VIA_TERMINFO='Terminal capability queries use terminfo(5)' \
41 ERRORS='Error log message ring' \
42 SPAM_SPAMC='Spam management via spamc(1) of spamassassin(1)' \
44 SPAM_FILTER='Freely configurable *spam-filter-..*s' \
45 DOCSTRINGS='Command documentation help strings' \
46 QUOTE_FOLD='Extended *quote-fold*ing' \
47 FILTER_HTML_TAGSOUP='Simple built-in HTML-to-text display filter' \
48 COLOUR='Coloured message display' \
49 DOTLOCK='Dotlock files and privilege-separated dotlock program' \
52 # Options which are automatically deduced from host environment, i.e., these
53 # need special treatment all around here to warp from/to OPT_ stuff
54 # setlocale, C90AMEND1, NL_LANGINFO, wcwidth
56 LOCALES='Locale support - printable characters etc. depend on environment' \
57 MULTIBYTE_CHARSETS='Multibyte character sets' \
58 TERMINAL_CHARSET='Automatic detection of terminal character set' \
59 WIDE_GLYPHS='Wide glyph support' \
62 # Rather special options, for custom building, or which always exist.
63 # Mostly for generating the visual overview and the *features* string
65 MIME='Multipurpose Internet Mail Extensions' \
66 SMIME='S/MIME message signing, verification, en- and decryption' \
67 CROSS_BUILD='Cross-compilation: trust any detected environment' \
68 DEBUG='Debug enabled binary, not for end-users: THANKS!' \
69 DEVEL='Computers do not blunder' \
72 # The problem is that we don't have any tools we can use right now, so
73 # encapsulate stuff in functions which get called in right order later on
89 OPT_DOTLOCK
=require OPT_ICONV
=require OPT_REGEX
=require
93 option_parse OPTIONS_DETECT
"${XOPTIONS_DETECT}"
94 option_parse OPTIONS
"${XOPTIONS}"
95 option_parse OPTIONS_XTRA
"${XOPTIONS_XTRA}"
98 # Predefined CONFIG= urations take precedence over anything else
99 if [ -n "${CONFIG}" ]; then
104 [nN
][uU
][lL
][lL
][iI
])
107 [mM
][iI
][nN
][iI
][mM
][aA
][lL
])
108 OPT_DOTLOCK
=require OPT_ICONV
=require OPT_REGEX
=require
114 OPT_HISTORY
=1 OPT_KEY_BINDINGS
=1
117 [nN
][eE
][tT
][sS
][eE
][nN
][dD
])
118 OPT_DOTLOCK
=require OPT_ICONV
=require OPT_REGEX
=require
122 OPT_GSSAPI
=1 OPT_NETRC
=1
129 OPT_HISTORY
=1 OPT_KEY_BINDINGS
=1
132 [mM
][aA
][xX
][iI
][mM
][aA
][lL
])
135 [dD
][eE
][vV
][eE
][lL
])
137 OPT_DEVEL
=1 OPT_DEBUG
=1 OPT_NYD2
=1
139 [oO
][dD
][eE
][vV
][eE
][lL
])
144 echo >&2 "Unknown CONFIG= setting: ${CONFIG}"
145 echo >&2 ' NULL, NULLI, MINIMAL, NETSEND, MAXIMAL'
149 msg_nonl
"CONFIG=${CONFIG} ... "
153 # Inter-relationships XXX sort this!
156 OPT_SSL_ALL_ALGORITHMS
=0
159 if feat_no SMTP
&& feat_no POP3
&& feat_no IMAP
; then
162 if feat_no SOCKETS
; then
163 if feat_require SMTP
; then
164 msg
'ERROR: need SOCKETS for required feature SMTP'
167 if feat_require POP3
; then
168 msg
'ERROR: need SOCKETS for required feature POP3'
171 if feat_require IMAP
; then
172 msg
'ERROR: need SOCKETS for required feature IMAP'
175 OPT_SSL
=0 OPT_SSL_ALL_ALGORITHMS
=0
176 OPT_SMTP
=0 OPT_POP3
=0 OPT_IMAP
=0
177 OPT_GSSAPI
=0 OPT_NETRC
=0 OPT_AGENT
=0
179 if feat_no SMTP
&& feat_no IMAP
; then
183 if feat_no ICONV
; then
184 if feat_yes IMAP
; then
185 if feat_require IMAP
; then
186 msg
'ERROR: need ICONV for required feature IMAP'
189 msg
'ERROR: disabling IMAP due to missing ICONV'
193 if feat_yes IDNA
; then
194 if feat_require IDNA
; then
195 msg
'ERROR: need ICONV for required feature IDNA'
198 msg
'ERROR: disabling IDNA due to missing ICONV'
204 OPT_HISTORY
=0 OPT_KEY_BINDINGS
=0
207 # If we don't need MD5 leave it alone
208 if feat_no SOCKETS
; then
212 if feat_no TERMCAP
; then
213 OPT_TERMCAP_VIA_TERMINFO
=0
216 if feat_yes DEVEL
; then
224 h
=.
/mk-config.h h_name
=mk-config.h
227 newlst
=.
/mk-nconfig.lst
228 newmk
=.
/mk-nconfig.mk
229 newev
=.
/mk-nconfig.ev
235 ## -- >8 - << OPTIONS | OS/CC >> - 8< -- ##
237 # Note that potential duplicates in PATH, C_INCLUDE_PATH etc. will be cleaned
238 # via path_check() later on once possible
240 # TODO cc_maxopt is brute simple, we should compile test program and dig real
241 # compiler versions for known compilers, then be more specific
242 [ -n "${cc_maxopt}" ] || cc_maxopt
=100
243 #cc_force_no_stackprot=
246 #ld_rpath_not_runpath=
251 # We don't "have any utility": only path adjustments and such in here!
252 [ -n "${OS}" ] || OS
=`uname -s`
255 if [ ${OS} = SunOS
]; then
256 msg
'SunOS / Solaris? Applying some "early setup" rules ...'
257 _os_early_setup_sunos
261 _os_early_setup_sunos
() {
262 # According to standards(5), this is what we need to do
263 if [ -d /usr
/xpg4
]; then :; else
264 msg
'ERROR: On SunOS / Solaris we need /usr/xpg4 environment! Sorry.'
267 PATH
="/usr/xpg4/bin:/usr/ccs/bin:/usr/bin:${PATH}"
268 [ -d /usr
/xpg6
] && PATH
="/usr/xpg6/bin:${PATH}"
273 # OSENV ends up in *build-osenv*
274 # OSFULLSPEC is used to recognize changes (i.e., machine type, updates etc.)
275 OS
=`echo ${OS} | ${tr} '[A-Z]' '[a-z]'`
276 [ -n "${OSENV}" ] || OSENV
=`uname -srm`
277 [ -n "${OSFULLSPEC}" ] || OSFULLSPEC
=`uname -a`
278 msg
'Operating system is %s' ${OS}
280 if [ ${OS} = darwin
]; then
281 msg
' . have special Darwin environmental addons...'
282 LD_LIBRARY_PATH
=${LD_LIBRARY_PATH}:${DYLD_LIBRARY_PATH}
283 elif [ ${OS} = sunos
]; then
284 msg
' . have special SunOS / Solaris "setup" rules ...'
286 elif [ ${OS} = unixware
]; then
287 if feat_yes AUTOCC
&& acmd_set CC cc
; then
288 msg
' . have special UnixWare environmental rules ...'
289 feat_yes DEBUG
&& _CFLAGS
='-v -Xa -g' || _CFLAGS
='-Xa -O'
291 CFLAGS
="${_CFLAGS} ${EXTRA_CFLAGS}"
292 LDFLAGS
="${_LDFLAGS} ${EXTRA_LDFLAGS}"
293 export CC CFLAGS LDFLAGS
294 OPT_AUTOCC
=0 ld_need_R_flags
=-R
296 elif [ -n "${VERBOSE}" ]; then
297 msg
' . no special treatment for this system necessary or known'
300 # Sledgehammer: better set _GNU_SOURCE
301 # And in general: oh, boy!
302 OS_DEFINES
="${OS_DEFINES}#define _GNU_SOURCE\n"
303 #OS_DEFINES="${OS_DEFINES}#define _POSIX_C_SOURCE 200809L\n"
304 #OS_DEFINES="${OS_DEFINES}#define _XOPEN_SOURCE 700\n"
305 #[ ${OS} = darwin ] && OS_DEFINES="${OS_DEFINES}#define _DARWIN_C_SOURCE\n"
307 # On pkgsrc(7) systems automatically add /usr/pkg/*
308 if [ -d /usr
/pkg
] && feat_yes USE_PKGSYS
; then
309 msg
' . found pkgsrc(7), merging C_INCLUDE_PATH and LD_LIBRARY_PATH'
310 C_INCLUDE_PATH
=/usr
/pkg
/include
:${C_INCLUDE_PATH}
311 LD_LIBRARY_PATH
=/usr
/pkg
/lib
:${LD_LIBRARY_PATH}
312 ld_rpath_not_runpath
=1
317 C_INCLUDE_PATH
=/usr
/xpg
4/include
:${C_INCLUDE_PATH}
318 LD_LIBRARY_PATH
=/usr
/xpg
4/lib
:${LD_LIBRARY_PATH}
321 if [ -d /opt
/csw
] && feat_yes USE_PKGSYS
; then
322 msg
' . found OpenCSW PKGSYS, merging C_INCLUDE_PATH and LD_LIBRARY_PATH'
323 C_INCLUDE_PATH
=/opt
/csw
/include
:${C_INCLUDE_PATH}
324 LD_LIBRARY_PATH
=/opt
/csw
/lib
:${LD_LIBRARY_PATH}
325 ld_no_bind_now
=1 ld_rpath_not_runpath
=1
327 if [ -d /opt
/schily
] && feat_yes USE_PKGSYS
; then
328 msg
' . found Schily PKGSYS, merging C_INCLUDE_PATH and LD_LIBRARY_PATH'
329 C_INCLUDE_PATH
=/opt
/schily
/include
:${C_INCLUDE_PATH}
330 LD_LIBRARY_PATH
=/opt
/schily
/lib
:${LD_LIBRARY_PATH}
331 ld_no_bind_now
=1 ld_rpath_not_runpath
=1
334 OS_DEFINES
="${OS_DEFINES}#define __EXTENSIONS__\n"
335 #OS_DEFINES="${OS_DEFINES}#define _POSIX_C_SOURCE 200112L\n"
337 [ -n "${cksum}" ] ||
cksum=/opt
/csw
/gnu
/cksum
338 if [ -x "${cksum}" ]; then :; else
339 msg
'ERROR: Not an executable program: %s' "${cksum}"
340 msg
'ERROR: We need a CRC-32 cksum(1), as specified in POSIX.'
341 msg
'ERROR: However, we do so only for tests.'
342 msg
'ERROR: If that is ok, set "cksum=/usr/bin/true", then rerun'
346 if feat_yes AUTOCC
; then
347 if acmd_set CC cc
; then
348 feat_yes DEBUG
&& _CFLAGS
="-v -Xa -g" || _CFLAGS
="-Xa -O"
350 CFLAGS
="${_CFLAGS} ${EXTRA_CFLAGS}"
351 LDFLAGS
="${_LDFLAGS} ${EXTRA_LDFLAGS}"
352 export CC CFLAGS LDFLAGS
353 OPT_AUTOCC
=0 ld_need_R_flags
=-R
355 cc_maxopt
=2 cc_force_no_stackprot
=1
360 # Check out compiler ($CC) and -flags ($CFLAGS)
362 # Even though it belongs into cc_flags we will try to compile and link
363 # something, so ensure we have a clean state regarding CFLAGS/LDFLAGS or
364 # EXTRA_CFLAGS/EXTRA_LDFLAGS
365 if feat_no AUTOCC
; then
367 # Ensure those don't do any harm
368 EXTRA_CFLAGS
= EXTRA_LDFLAGS
=
369 export EXTRA_CFLAGS EXTRA_LDFLAGS
373 export CFLAGS LDFLAGS
376 [ -n "${CC}" ] && { _cc_default
; return; }
378 msg_nonl
'Searching for a usable C compiler .. $CC='
379 if acmd_set CC clang || acmd_set CC gcc ||
380 acmd_set CC tcc || acmd_set CC pcc ||
381 acmd_set CC c89 || acmd_set CC c99
; then
384 msg
'boing booom tschak'
385 msg
'ERROR: I cannot find a compiler!'
386 msg
' Neither of clang(1), gcc(1), tcc(1), pcc(1), c89(1) and c99(1).'
387 msg
' Please set ${CC} environment variable, maybe ${CFLAGS}, rerun.'
395 if [ -z "${CC}" ]; then
396 msg
'To go on like you have chosen, please set $CC, rerun.'
400 if [ -z "${VERBOSE}" ] && [ -f ${lst} ] && feat_no DEBUG
; then
403 msg
'Using C compiler ${CC}=%s' "${CC}"
408 if feat_yes AUTOCC
; then
409 if [ -f ${lst} ] && feat_no DEBUG
&& [ -z "${VERBOSE}" ]; then
411 msg
'Detecting ${CFLAGS}/${LDFLAGS} for ${CC}=%s, just a second..' \
415 msg
'Testing usable ${CFLAGS}/${LDFLAGS} for ${CC}=%s' "${CC}"
418 i=`echo "${CC}" | ${awk} 'BEGIN{FS="/"}{print $NF}'`
419 if { echo "${i}" | ${grep} tcc; } >/dev/null 2>&1; then
420 msg ' . have special tcc(1) environmental rules ...'
423 # As of pcc CVS 2016-04-02, stack protection support is announced but
424 # will break if used on Linux
425 if { echo "${i}" | ${grep} pcc; } >/dev/null 2>&1; then
426 cc_force_no_stackprot=1
431 feat_no DEBUG && _CFLAGS="-DNDEBUG ${_CFLAGS}"
432 CFLAGS="${_CFLAGS} ${EXTRA_CFLAGS}"
433 LDFLAGS="${_LDFLAGS} ${EXTRA_LDFLAGS}"
435 if feat_no DEBUG; then
436 CFLAGS="-DNDEBUG ${CFLAGS}"
440 export CFLAGS LDFLAGS
444 __cflags=${_CFLAGS} __ldflags=${_LDFLAGS}
451 if feat_yes DEBUG; then
452 # May have problems to find libtcc cc_check -b
456 if ld_check -Wl,-rpath =./ no; then
457 ld_need_R_flags=-Wl,-rpath=
458 if [ -z "${ld_rpath_not_runpath}" ]; then
459 ld_check -Wl,--enable-new-dtags
461 msg ' ! $LD_LIBRARY_PATH adjusted, not trying --enable-new-dtags'
463 ld_runtime_flags # update!
466 _CFLAGS="${_CFLAGS} ${__cflags}" _LDFLAGS="${_LDFLAGS} ${__ldflags}"
467 unset __cflags __ldflags
470 _cc_flags_generic() {
471 __cflags=${_CFLAGS} __ldflags=${_LDFLAGS}
473 feat_yes DEVEL && cc_check -std=c89 || cc_check -std=c99
475 # E.g., valgrind does not work well with high optimization
476 if [ ${cc_maxopt} -gt 1 ] && feat_yes NOMEMDBG &&
477 feat_no ASAN_ADDRESS && feat_no ASAN_MEMORY; then
478 msg ' ! OPT_NOMEMDBG, setting cc_maxopt=1 (-O1)'
481 # Check -g first since some others may rely upon -g / optim. level
482 if feat_yes DEBUG; then
485 elif [ ${cc_maxopt} -gt 2 ] && cc_check -O3; then
487 elif [ ${cc_maxopt} -gt 1 ] && cc_check -O2; then
489 elif [ ${cc_maxopt} -gt 0 ] && cc_check -O1; then
495 if feat_yes AMALGAMATION; then
499 #if feat_yes DEVEL && cc_check -Weverything; then
504 cc_check -Wbad-function-cast
505 cc_check -Wcast-align
508 cc_check -Wmissing-prototypes
511 cc_check -Wwrite-strings
512 cc_check -Wno-long-long
516 if feat_yes AMALGAMATION && feat_no DEVEL; then
517 cc_check -Wno-unused-function
519 feat_no DEVEL && cc_check -Wno-unused-result # XXX do right way (pragma too)
521 cc_check -fno-unwind-tables
522 cc_check -fno-asynchronous-unwind-tables
523 cc_check -fstrict-aliasing
524 if cc_check -fstrict-overflow && feat_yes DEVEL; then
525 cc_check -Wstrict-overflow=5
528 if feat_yes DEBUG || feat_yes FORCED_STACKPROT; then
529 if [ -z "${cc_force_no_stackprot}" ]; then
530 if cc_check -fstack-protector-strong ||
531 cc_check -fstack-protector-all; then
532 cc_check -D_FORTIFY_SOURCE=2
535 msg ' ! Not checking for -fstack-protector compiler option,'
536 msg ' ! since that caused errors in a "similar" configuration.'
537 msg ' ! You may turn off OPT_AUTOCC and use your own settings, rerun'
541 # LD (+ dependend CC)
543 if feat_yes ASAN_ADDRESS; then
545 if cc_check -fsanitize=address &&
546 ld_check -fsanitize=address; then
549 feat_bail_required ASAN_ADDRESS
554 if feat_yes ASAN_MEMORY; then
556 if cc_check -fsanitize=memory &&
557 ld_check -fsanitize=memory &&
558 cc_check -fsanitize-memory-track-origins=2 &&
559 ld_check -fsanitize-memory-track-origins=2; then
562 feat_bail_required ASAN_MEMORY
567 ld_check -Wl,-z,relro
568 if [ -z "${ld_no_bind_now}" ]; then
571 msg ' ! $LD_LIBRARY_PATH adjusted, not trying -Wl,-z,now'
573 ld_check -Wl,-z,noexecstack
574 if ld_check -Wl,-rpath =./ no; then
575 ld_need_R_flags=-Wl,-rpath=
576 # Choose DT_RUNPATH (after $LD_LIBRARY_PATH) over DT_RPATH (before)
577 if [ -z "${ld_rpath_not_runpath}" ]; then
578 ld_check -Wl,--enable-new-dtags
580 msg ' ! $LD_LIBRARY_PATH adjusted, not trying --enable-new-dtags'
582 ld_runtime_flags # update!
583 elif ld_check -Wl,-R ./ no; then
584 ld_need_R_flags=-Wl,-R
585 if [ -z "${ld_rpath_not_runpath}" ]; then
586 ld_check -Wl,--enable-new-dtags
588 msg ' ! $LD_LIBRARY_PATH adjusted, not trying --enable-new-dtags'
590 ld_runtime_flags # update!
593 # Address randomization
595 if cc_check -fPIE || cc_check -fpie; then
596 ld_check -pie || _CFLAGS=${_ccfg}
600 _CFLAGS="${_CFLAGS} ${__cflags}" _LDFLAGS="${_LDFLAGS} ${__ldflags}"
601 unset __cflags __ldflags
604 ## -- >8 - <<OS/CC | SUPPORT FUNS>> - 8< -- ##
607 ## - Heirloom sh(1) (and same origin) have _sometimes_ problems with ': >'
608 ## redirection, so use "printf '' >" instead
610 ## Very first: we undergo several states regarding I/O redirection etc.,
611 ## but need to deal with option updates from within all. Since all the
612 ## option stuff should be above the scissor line, define utility functions
613 ## and redefine them as necessary.
614 ## And, since we have those functions, simply use them for whatever
616 t1=ten10one1ten10one1
617 if ( [ ${t1##*ten10} = one1 ] && [ ${t1#*ten10} = one1ten10one1 ] &&
618 [ ${t1%%one1*} = ten10 ] && [ ${t1%one1*} = ten10one1ten10 ]
619 ) > /dev/null 2>&1; then
626 ( set -o noglob ) >/dev/null 2>&1 && noglob_shell=1 || unset noglob_shell
632 # which(1) not standardized, command(1) -v may return non-executable: unroll!
633 acmd_test() { __acmd "${1}" 1 0 0; }
634 acmd_test_fail() { __acmd "${1}" 1 1 0; }
635 acmd_set() { __acmd "${2}" 0 0 0 "${1}"; }
636 acmd_set_fail() { __acmd "${2}" 0 1 0 "${1}"; }
637 acmd_testandset() { __acmd "${2}" 1 0 0 "${1}"; }
638 acmd_testandset_fail() { __acmd "${2}" 1 1 0 "${1}"; }
639 thecmd_set() { __acmd "${2}" 0 0 1 "${1}"; }
640 thecmd_set_fail() { __acmd "${2}" 0 1 1 "${1}"; }
641 thecmd_testandset() { __acmd "${2}" 1 0 1 "${1}"; }
642 thecmd_testandset_fail() { __acmd "${2}" 1 1 1 "${1}"; }
644 pname=${1} dotest=${2} dofail=${3} verbok=${4} varname=${5}
646 if [ "${dotest}" -ne 0 ]; then
647 eval dotest=\$${varname}
648 if [ -n "${dotest}" ]; then
649 [ -n "${VERBOSE}" ] && [ ${verbok} -ne 0 ] &&
650 msg ' . ${%s} ... %s' "${pname}" "${dotest}"
656 [ -n "${noglob_shell}" ] && set -o noglob
658 [ -n "${noglob_shell}" ] && set +o noglob
662 if [ -z "${path}" ] || [ "${path}" = . ]; then
663 if [ -d "${PWD}" ]; then
669 if [ -f "${path}/${pname}" ] && [ -x "${path}/${pname}" ]; then
670 [ -n "${VERBOSE}" ] && [ ${verbok} -ne 0 ] &&
671 msg ' . ${%s} ... %s' "${pname}" "${path}/${pname}"
672 [ -n "${varname}" ] && eval ${varname}="${path}/${pname}"
677 # We may have no builtin string functions, we yet have no programs we can
678 # use, try to access once from the root, assuming it is an absolute path if
679 # that finds the executable
680 if ( cd && [ -f "${pname}" ] && [ -x "${pname}" ] ); then
681 [ -n "${VERBOSE}" ] && [ ${verbok} -ne 0 ] &&
682 msg ' . ${%s} ... %s' "${pname}" "${pname}"
683 [ -n "${varname}" ] && eval ${varname}="${pname}"
687 [ ${dofail} -eq 0 ] && return 1
688 msg 'ERROR: no trace of utility '"${pname}"
695 printf >&2 -- "${fmt}\\n" "${@}"
701 printf >&2 -- "${fmt}" "${@}"
704 # Our feature check environment
706 [ "x${1}" = x0 ] || [ "x${1}" = xn ] ||
707 [ "x${1}" = xfalse ] || [ "x${1}" = xno ] || [ "x${1}" = xoff ]
711 [ "x${1}" = x1 ] || [ "x${1}" = xy ] ||
712 [ "x${1}" = xtrue ] || [ "x${1}" = xyes ] || [ "x${1}" = xon ] ||
713 [ "x${1}" = xrequire ]
717 [ "x${1}" = xrequire ]
722 i="`echo ${i} |
${tr} '[A-Z]' '[a-z]'`"
723 if feat_val_no "${i}"; then
725 elif feat_val_yes "${i}"; then
728 msg "ERROR: %s: 0/n/false/no/off or 1/y/true/yes/on/require, got: %s" \
739 _feat_check ${1} && return 1
745 i="`echo ${i} |
${tr} '[A-Z]' '[a-z]'`"
746 [ "x${i}" = xrequire ] || [ "x${i}" = xrequired ]
749 feat_bail_required() {
750 if feat_require ${1}; then
751 msg 'ERROR: feature OPT_%s is required but not available' "${1}"
755 option_update # XXX this is rather useless here (dependency chain..)
759 # Parse one of our XOPTIONS* in $2 and assign the sh(1) compatible list of
760 # options, without documentation, to $1
762 i="`${awk} -v input
=\"${2}\" '
765 voff = match(input, /[[:alnum:]_]+(='${j}'[^'${j}']+)?/)
768 v = substr(input, voff, RLENGTH)
769 input = substr(input, voff + RLENGTH)
772 d = substr(v, doff + 2, length(v) - doff - 1)
773 v = substr(v, 1, doff - 1)
783 # Return the "documentation string" for option $1, itself if none such
785 ${awk} -v want="${1}" \
786 -v input="${XOPTIONS_DETECT}${XOPTIONS}${XOPTIONS_XTRA}" '
789 voff = match(input, /[[:alnum:]_]+(='${j}'[^'${j}']+)?/)
792 v = substr(input, voff, RLENGTH)
793 input = substr(input, voff + RLENGTH)
796 d = substr(v, doff + 2, length(v) - doff - 1)
797 v = substr(v, 1, doff - 1)
811 # Join the values from make.rc into what currently is defined, not
812 # overwriting yet existing settings
814 # We want read(1) to perform reverse solidus escaping in order to be able to
815 # use multiline values in make.rc; the resulting sh(1)/sed(1) code was very
816 # slow in VMs (see [fa2e248]), Aharon Robbins suggested the following
817 < ${rc} ${awk} 'BEGIN{line = ""}{
818 gsub(/^[[:space:]]+/, "", $0)
819 gsub(/[[:space:]]+$/, "", $0)
820 if(gsub(/\\$/, "", $0)){
825 if(index(line, "#") == 1){
827 }else if(length(line)){
833 if [ -n "${good_shell}" ]; then
836 i=`${awk} -v LINE
="${line}" 'BEGIN{
837 gsub(/=.*$/, "", LINE)
841 if [ "${i}" = "${line}" ]; then
842 msg 'ERROR: invalid syntax in: %s' "${line}"
846 eval j="\$${i}" jx="\${${i}+x}"
847 if [ -n "${j}" ] || [ "${jx}" = x ]; then
850 j=`${awk} -v LINE
="${line}" 'BEGIN{
851 gsub(/^[^=]*=/, "", LINE)
852 gsub(/^\"*/, "", LINE)
853 gsub(/\"*$/, "", LINE)
857 [ "${i}" = "DESTDIR" ] && continue
860 # Reread the mixed version right now
865 # Expand the option values, which may contain shell snippets
866 ${rm} -f ${newlst} ${newmk} ${newh}
867 exec 5<&0 6>&1 <${tmp} >${newlst}
870 if [ -n "${good_shell}" ]; then
872 [ "${i}" != "${i#OPT_}" ] && z=1
874 i=`${awk} -v LINE
="${line}" 'BEGIN{
875 gsub(/=.*$/, "", LINE);\
878 if echo "${i}" | ${grep} '^OPT_' >/dev/null 2>&1; then
884 if [ -n "${z}" ]; then
885 j="`echo ${j} |
${tr} '[A-Z]' '[a-z]'`"
886 if [ -z "${j}" ] || feat_val_no "${j}"; then
888 printf " /* #undef ${i} */\n" >> ${newh}
889 elif feat_val_yes "${j}"; then
890 if feat_val_require "${j}"; then
895 printf " /* #define ${i} */\n" >> ${newh}
897 msg 'ERROR: cannot parse <%s>' "${line}"
901 printf "#define ${i} \"${j}\"\n" >> ${newh}
903 printf "${i} = ${j}\n" >> ${newmk}
907 exec 0<&5 1>&6 5<&- 6<&-
911 # "path_check VARNAME" or "path_check VARNAME FLAG VARNAME"
912 varname=${1} addflag=${2} flagvarname=${3}
915 [ -n "${noglob_shell}" ] && set -o noglob
917 [ -n "${noglob_shell}" ] && set +o noglob
922 [ -z "${i}" ] && continue
923 [ -d "${i}" ] || continue
924 if [ -n "${j}" ]; then
925 if { z=${y}; echo "${z}"; } | ${grep} ":${i}:" >/dev/null 2>&1; then
930 # But do not link any fakeroot path into our binaries!
931 if [ -n "${addflag}" ]; then
932 case "${i}" in *fakeroot*) continue;; esac
933 k="${k} ${addflag}${i}"
939 # But do not link any fakeroot path into our binaries!
940 if [ -n "${addflag}" ]; then
941 case "${i}" in *fakeroot*) continue;; esac
942 k="${k} ${addflag}${i}"
946 eval "${varname}=\"${j}\""
947 [ -n "${addflag}" ] && eval "${flagvarname}=\"${k}\""
952 if [ -n "${ld_need_R_flags}" ]; then
955 set -- ${LD_LIBRARY_PATH}
959 # But do not link any fakeroot path into our binaries!
960 case "${i}" in *fakeroot*) continue;; esac
961 LDFLAGS="${LDFLAGS} ${ld_need_R_flags}${i}"
962 _LDFLAGS="${_LDFLAGS} ${ld_need_R_flags}${i}"
966 # Disable it for a possible second run.
971 [ -n "${cc_check_silent}" ] || msg_nonl ' . CC %s .. ' "${1}"
973 ${_CFLAGS} ${1} ${EXTRA_CFLAGS} ${_LDFLAGS} ${EXTRA_LDFLAGS} \
974 -o ${tmp2} ${tmp}.c ${LIBS} >/dev/null 2>&1; then
975 _CFLAGS="${_CFLAGS} ${1}"
976 [ -n "${cc_check_silent}" ] || msg 'yes'
979 [ -n "${cc_check_silent}" ] || msg 'no'
984 # $1=option [$2=option argument] [$3=if set, shall NOT be added to _LDFLAGS]
985 [ -n "${cc_check_silent}" ] || msg_nonl ' . LD %s .. ' "${1}"
986 if "${CC}" ${INCS} ${_CFLAGS} ${_LDFLAGS} ${1}${2} ${EXTRA_LDFLAGS} \
987 -o ${tmp2} ${tmp}.c ${LIBS} >/dev/null 2>&1; then
988 [ -n "${3}" ] || _LDFLAGS="${_LDFLAGS} ${1}"
989 [ -n "${cc_check_silent}" ] || msg 'yes'
992 [ -n "${cc_check_silent}" ] || msg 'no'
998 variable=$1 topic=$2 define=$3
1001 msg_nonl ' . %s ... ' "${topic}"
1002 echo "/* checked ${topic} */" >> ${h}
1003 ${rm} -f ${tmp} ${tmp}.o
1004 if [ "${dump_test_program}" = 1 ]; then
1005 echo '*** test program is'
1006 { echo '#include <'"${h_name}"'>'; cat; } | ${tee} ${tmp}.c
1008 { echo '#include <'"${h_name}"'>'; cat; } > ${tmp}.c
1010 #echo '*** the preprocessor generates'
1011 #${make} -f ${makefile} ${tmp}.x
1013 echo '*** tests results'
1017 yesno=$1 variable=$2 topic=$3 define=$4 libs=$5 incs=$6
1020 msg_nonl ' . %s ... ' "${topic}"
1022 echo '*** enforced unchecked results are'
1023 if feat_val_yes ${yesno}; then
1024 if [ -n "${incs}" ] || [ -n "${libs}" ]; then
1025 echo "*** adding INCS<${incs}> LIBS<${libs}>"
1026 LIBS="${LIBS} ${libs}"
1027 echo "${libs}" >> ${lib}
1028 INCS="${INCS} ${incs}"
1029 echo "${incs}" >> ${inc}
1032 echo "${define}" >> ${h}
1033 eval have_${variable}=yes
1036 echo "/* ${define} */" >> ${h}
1038 eval unset have_${variable}
1044 variable=$1 topic=$2 define=$3
1046 _check_preface "${variable}" "${topic}" "${define}"
1048 if ${make} -f ${makefile} XINCS="${INCS}" \
1049 CFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}" \
1051 [ -f ./${tmp}.o ]; then
1053 echo "${define}" >> ${h}
1054 eval have_${variable}=yes
1057 echo "/* ${define} */" >> ${h}
1059 eval unset have_${variable}
1065 run=$1 variable=$2 topic=$3 define=$4 libs=$5 incs=$6
1067 _check_preface "${variable}" "${topic}" "${define}"
1069 if feat_yes CROSS_BUILD; then
1070 if [ ${run} = 1 ]; then
1075 if ${make} -f ${makefile} XINCS="${INCS} ${incs}" \
1076 CFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}" \
1077 XLIBS="${LIBS} ${libs}" \
1080 { [ ${run} -eq 0 ] || ./${tmp}; }; then
1081 echo "*** adding INCS<${incs}> LIBS<${libs}>; executed: ${run}"
1083 echo "${define}" >> ${h}
1084 LIBS="${LIBS} ${libs}"
1085 echo "${libs}" >> ${lib}
1086 INCS="${INCS} ${incs}"
1087 echo "${incs}" >> ${inc}
1088 eval have_${variable}=yes
1092 echo "/* ${define} */" >> ${h}
1093 eval unset have_${variable}
1099 _link_mayrun 0 "${1}" "${2}" "${3}" "${4}" "${5}"
1103 _link_mayrun 1 "${1}" "${2}" "${3}" "${4}" "${5}"
1107 _link_mayrun 2 "${1}" "${2}" "${3}" "${4}" "${5}"
1111 if feat_yes ${1}; then
1112 echo '#define HAVE_'${1}'' >> ${h}
1115 echo '/* OPT_'${1}'=0 */' >> ${h}
1121 < "${1}" > "${2}" ${awk} \
1122 'BEGIN {ORS = " "} /^[^#]/ {print} {next} END {ORS = ""; print "\n"}'
1125 ## -- >8 - <<SUPPORT FUNS | RUNNING>> - 8< -- ##
1127 # First of all, create new configuration and check whether it changed
1129 # Very easy checks for the operating system in order to be able to adjust paths
1130 # or similar very basic things which we need to be able to go at all
1133 # Check those tools right now that we need before including $rc
1134 msg 'Checking for basic utility set'
1135 thecmd_testandset_fail awk awk
1136 thecmd_testandset_fail rm rm
1137 thecmd_testandset_fail tr tr
1139 # Initialize the option set
1140 msg_nonl 'Setting up configuration options ... '
1144 # Include $rc, but only take from it what wasn't overwritten by the user from
1145 # within the command line or from a chosen fixed CONFIG=
1146 # Note we leave alone the values
1147 trap "exit 1" HUP INT TERM
1148 trap "${rm} -f ${tmp}" EXIT
1150 msg_nonl 'Joining in %s ... ' ${rc}
1154 # We need to know about that now, in order to provide utility overwrites etc.
1157 msg 'Checking for remaining set of utilities'
1158 thecmd_testandset_fail grep grep
1160 # Before we step ahead with the other utilities perform a path cleanup first.
1164 thecmd_testandset_fail basename basename
1165 thecmd_testandset_fail cat cat
1166 thecmd_testandset_fail chmod chmod
1167 thecmd_testandset_fail cp cp
1168 thecmd_testandset_fail cmp cmp
1170 thecmd_testandset_fail mkdir mkdir
1171 thecmd_testandset_fail mv mv
1173 thecmd_testandset_fail sed sed
1174 thecmd_testandset_fail sort sort
1175 thecmd_testandset_fail tee tee
1177 thecmd_testandset chown chown ||
1178 PATH="/sbin:${PATH}" thecmd_set chown chown ||
1179 PATH="/usr/sbin:${PATH}" thecmd_set_fail chown chown
1181 thecmd_testandset_fail MAKE make
1184 thecmd_testandset strip strip && HAVE_STRIP=1 || HAVE_STRIP=0
1186 # For ./cc-test.sh only
1187 thecmd_testandset_fail cksum cksum
1189 # Update OPT_ options now, in order to get possible inter-dependencies right
1192 # (No functions since some shells loose non-exported variables in traps)
1193 trap "trap \"\" HUP INT TERM; exit 1" HUP INT TERM
1194 trap "trap \"\" HUP INT TERM EXIT;\
1195 ${rm} -rf ${newlst} ${tmp0}.* ${tmp0}* ${newmk} ${newev} ${newh}" EXIT
1197 # Our configuration options may at this point still contain shell snippets,
1198 # we need to evaluate them in order to get them expanded, and we need those
1199 # evaluated values not only in our new configuration file, but also at hand..
1200 msg_nonl 'Evaluating all configuration items ... '
1204 printf "#define VAL_UAGENT \"${VAL_SID}${VAL_MAILX}\"\n" >> ${newh}
1205 printf "VAL_UAGENT = ${VAL_SID}${VAL_MAILX}\n" >> ${newmk}
1207 # The problem now is that the test should be able to run in the users linker
1208 # and path environment, so we need to place the test: rule first, before
1209 # injecting the relevant make variables. Set up necessary environment
1210 if [ -z "${VERBOSE}" ]; then
1211 printf -- "ECHO_CC = @echo ' 'CC \$(@);\n" >> ${newmk}
1212 printf -- "ECHO_LINK = @echo ' 'LINK \$(@);\n" >> ${newmk}
1213 printf -- "ECHO_GEN = @echo ' 'GEN \$(@);\n" >> ${newmk}
1214 printf -- "ECHO_TEST = @\n" >> ${newmk}
1215 printf -- "ECHO_CMD = @echo ' CMD';\n" >> ${newmk}
1216 printf -- "ECHO_BLOCK_BEGIN = @( \n" >> ${newmk}
1217 printf -- "ECHO_BLOCK_END = ) >/dev/null\n" >> ${newmk}
1219 printf 'test: all\n\t$(ECHO_TEST)%s %scc-test.sh --check-only ./%s\n' \
1220 "${SHELL}" "${SRCDIR}" "${VAL_SID}${VAL_MAILX}" >> ${newmk}
1222 # Add the known utility and some other variables
1223 printf "#define VAL_PRIVSEP \"${VAL_SID}${VAL_MAILX}-privsep\"\n" >> ${newh}
1224 printf "VAL_PRIVSEP = \$(VAL_UAGENT)-privsep\n" >> ${newmk}
1225 if feat_yes DOTLOCK; then
1226 printf "OPTIONAL_PRIVSEP = \$(VAL_PRIVSEP)\n" >> ${newmk}
1228 printf "OPTIONAL_PRIVSEP =\n" >> ${newmk}
1233 awk basename cat chmod chown cp cmp grep mkdir mv rm sed sort tee tr \
1234 MAKE MAKEFLAGS make SHELL strip \
1237 printf "${i} = ${j}\n" >> ${newmk}
1238 printf "${i}=${j}\n" >> ${newlst}
1239 printf "${i}=\"${j}\";export ${i}; " >> ${newev}
1241 printf "\n" >> ${newev}
1243 # Build a basic set of INCS and LIBS according to user environment.
1244 C_INCLUDE_PATH="${CWDDIR}:${SRCDIR}:${C_INCLUDE_PATH}"
1245 path_check C_INCLUDE_PATH -I _INCS
1246 INCS="${INCS} ${_INCS}"
1247 path_check LD_LIBRARY_PATH -L _LIBS
1248 LIBS="${LIBS} ${_LIBS}"
1250 export C_INCLUDE_PATH LD_LIBRARY_PATH
1252 # Some environments need runtime path flags to be able to go at all
1255 ## Detect CC, whether we can use it, and possibly which CFLAGS we can use
1259 ${cat} > ${tmp}.c << \!
1262 static void doit(char const *s);
1264 main(int argc, char **argv){
1267 doit("Hello world");
1271 doit(char const *s){
1273 memcpy(buf, s, strlen(s) +1);
1278 if "${CC}" ${INCS} ${CFLAGS} ${EXTRA_CFLAGS} ${LDFLAGS} ${EXTRA_LDFLAGS} \
1279 -o ${tmp2} ${tmp}.c ${LIBS}; then
1282 msg 'ERROR: i cannot compile a "Hello world" via'
1284 "${CC} ${INCS} ${CFLAGS} ${EXTRA_CFLAGS} ${LDFLAGS} ${EXTRA_LDFLAGS} ${LIBS}"
1285 msg 'ERROR: Please read INSTALL, rerun'
1289 # This may also update ld_runtime_flags() (again)
1296 printf -- "${i}=${j}\n" >> ${newlst}
1302 PATH C_INCLUDE_PATH LD_LIBRARY_PATH \
1306 printf -- "${i} = ${j}\n" >> ${newmk}
1307 printf -- "${i}=${j}\n" >> ${newlst}
1310 # Now finally check whether we already have a configuration and if so, whether
1311 # all those parameters are still the same.. or something has actually changed
1312 if [ -f ${lst} ] && ${cmp} ${newlst} ${lst} >/dev/null 2>&1; then
1313 echo 'Configuration is up-to-date'
1315 elif [ -f ${lst} ]; then
1316 echo 'Configuration has been updated..'
1317 ( eval "${MAKE} -f ./mk-config.mk clean" )
1320 echo 'Shiny configuration..'
1323 # Time to redefine helper 1
1325 ${rm} -f ${lst} ${h} ${mk}
1329 ${mv} -f ${newlst} ${lst}
1330 ${mv} -f ${newev} ${ev}
1331 ${mv} -f ${newh} ${h}
1332 ${mv} -f ${newmk} ${mk}
1334 ## Compile and link checking
1340 makefile=./${tmp0}.mk
1342 # (No function since some shells loose non-exported variables in traps)
1343 trap "trap \"\" HUP INT TERM;\
1344 ${rm} -f ${lst} ${h} ${mk} ${lib} ${inc}; exit 1" HUP INT TERM
1345 trap "trap \"\" HUP INT TERM EXIT;\
1346 ${rm} -rf ${tmp0}.* ${tmp0}*" EXIT
1348 # Time to redefine helper 2
1352 printf "*** ${fmt}\\n" "${@}"
1353 printf -- "${fmt}\\n" "${@}" >&5
1358 printf "*** ${fmt}\\n" "${@}"
1359 printf -- "${fmt}" "${@}" >&5
1363 exec 5>&2 > ${log} 2>&1
1365 echo "${LIBS}" > ${lib}
1366 echo "${INCS}" > ${inc}
1367 ${cat} > ${makefile} << \!
1368 .SUFFIXES: .o .c .x .y
1370 $(CC) -I./ $(XINCS) $(CFLAGS) -c $(<)
1372 $(CC) -I./ $(XINCS) -E $(<) > $(@)
1374 $(CC) -I./ $(XINCS) $(CFLAGS) $(LDFLAGS) -o $(@) $(<) $(XLIBS)
1379 # May be multiline..
1381 [ -n "${OS_DEFINES}" ] && printf -- "${OS_DEFINES}" >> ${h}
1382 echo '#define VAL_BUILD_OS "'"${OS}"'"' >> ${h}
1383 echo '#define VAL_BUILD_OSENV "'"${OSENV}"'"' >> ${h}
1385 # Generate n_err_number OS mappings
1388 feat_yes DEVEL && NV= || NV=noverbose
1389 SRCDIR="${SRCDIR}" TARGET="${h}" awk="${awk}" \
1390 ${SHELL} "${SRCDIR}"make-errors.sh ${NV} config
1391 ) | xrun_check oserrno 'OS error mapping table generated' || config_exit 1
1394 feat_def ALWAYS_UNICODE_LOCALE
1395 feat_def AMALGAMATION
1396 feat_def CROSS_BUILD
1400 feat_def ASAN_ADDRESS
1401 feat_def ASAN_MEMORY
1407 if xrun_check inline 'inline functions' \
1408 '#define HAVE_INLINE
1409 #define n_INLINE static inline' << \!
1410 static inline int ilf(int i){return ++i;}
1411 int main(void){return ilf(-1);}
1415 elif xrun_check inline 'inline functions (via __inline)' \
1416 '#define HAVE_INLINE
1417 #define n_INLINE static __inline' << \!
1418 static __inline int ilf(int i){return ++i;}
1419 int main(void){return ilf(-1);}
1425 ## Test for "basic" system-calls / functionality that is used by all parts
1426 ## of our program. Once this is done fork away BASE_LIBS and other BASE_*
1427 ## macros to be used by only the subprograms (potentially).
1429 if run_check clock_gettime 'clock_gettime(2)' \
1430 '#define HAVE_CLOCK_GETTIME' << \!
1436 if(!clock_gettime(CLOCK_REALTIME, &ts) || errno != ENOSYS)
1443 elif run_check clock_gettime 'clock_gettime(2) (via -lrt)' \
1444 '#define HAVE_CLOCK_GETTIME' '-lrt' << \!
1450 if(!clock_gettime(CLOCK_REALTIME, &ts) || errno != ENOSYS)
1457 elif run_check gettimeofday 'gettimeofday(2)' \
1458 '#define HAVE_GETTIMEOFDAY' << \!
1459 #include <stdio.h> /* For C89 NULL */
1460 #include <sys/time.h>
1465 if(!gettimeofday(&tv, NULL) || errno != ENOSYS)
1473 have_no_subsecond_time=1
1476 if run_check nanosleep 'nanosleep(2)' \
1477 '#define HAVE_NANOSLEEP' << \!
1484 ts.tv_nsec = 100000;
1485 if(!nanosleep(&ts, NULL) || errno != ENOSYS)
1492 elif run_check nanosleep 'nanosleep(2) (via -lrt)' \
1493 '#define HAVE_NANOSLEEP' '-lrt' << \!
1500 ts.tv_nsec = 100000;
1501 if(!nanosleep(&ts, NULL) || errno != ENOSYS)
1508 # link_check is enough for this, that function is so old, trust the proto
1509 elif link_check sleep 'sleep(3)' \
1510 '#define HAVE_SLEEP' << \!
1514 if(!sleep(1) || errno != ENOSYS)
1522 msg 'ERROR: we require one of nanosleep(2) and sleep(3).'
1526 if run_check userdb 'gete?[gu]id(2), getpwuid(3), getpwnam(3)' << \!
1535 if((gid = getgid()) != 0)
1537 if((uid = getuid()) != 0)
1539 if((pw = getpwuid(uid)) == NULL && errno == ENOSYS)
1541 if((pw = getpwnam("root")) == NULL && errno == ENOSYS)
1549 msg 'ERROR: we require user and group info / database searches.'
1550 msg 'That much Unix we indulge ourselfs.'
1554 if link_check ftruncate 'ftruncate(2)' \
1555 '#define HAVE_FTRUNCATE' << \!
1557 #include <sys/types.h>
1559 return (ftruncate(0, 0) != 0);
1565 msg 'ERROR: we require the ftruncate(2) system call.'
1569 if run_check sa_restart 'SA_RESTART (for sigaction(2))' << \!
1573 struct sigaction nact, oact;
1575 nact.sa_handler = SIG_DFL;
1576 sigemptyset(&nact.sa_mask);
1577 nact.sa_flags = SA_RESTART;
1578 return !(!sigaction(SIGCHLD, &nact, &oact) || errno != ENOSYS);
1584 msg 'ERROR: we (yet) require the SA_RESTART flag for sigaction(2).'
1588 if link_check snprintf 'snprintf(3)' << \!
1593 snprintf(b, sizeof b, "%s", "string");
1600 msg 'ERROR: we require the snprintf(3) function.'
1604 if link_check environ 'environ(3)' << \!
1605 #include <stdio.h> /* For C89 NULL */
1607 extern char **environ;
1609 return environ[0] == NULL;
1615 msg 'ERROR: we require the environ(3) array for subprocess control.'
1619 if link_check setenv '(un)?setenv(3)' '#define HAVE_SETENV' << \!
1622 setenv("s-mailx", "i want to see it cute!", 1);
1623 unsetenv("s-mailx");
1629 elif link_check setenv 'putenv(3)' '#define HAVE_PUTENV' << \!
1632 putenv("s-mailx=i want to see it cute!");
1639 msg 'ERROR: we require either the setenv(3) or putenv(3) functions.'
1643 if link_check termios 'termios.h and tc*(3) family' << \!
1644 #include <termios.h>
1646 struct termios tios;
1648 tcgetattr(0, &tios);
1649 tcsetattr(0, TCSANOW | TCSADRAIN | TCSAFLUSH, &tios);
1656 msg 'ERROR: we require termios.h and the tc[gs]etattr() family of functions.'
1657 msg 'That much Unix we indulge ourselfs.'
1663 if link_check vsnprintf 'vsnprintf(3)' << \!
1666 static void dome(char *buf, size_t blen, ...){
1670 vsnprintf(buf, blen, "%s", ap);
1676 dome(b, sizeof b, "string");
1683 feat_bail_required ERRORS
1686 if [ "${have_vsnprintf}" = yes ]; then
1688 link_check va_copy "va_copy(3) (as ${2})" \
1689 "#define HAVE_N_VA_COPY
1690 #define n_va_copy ${2}" <<_EOT
1694 # if defined __va_copy && !defined va_copy
1695 # define va_copy __va_copy
1698 static void dome2(char *buf, size_t blen, va_list src){
1702 vsnprintf(buf, blen, "%s", ap);
1705 static void dome(char *buf, size_t blen, ...){
1709 dome2(buf, blen, ap);
1715 dome(b, sizeof b, "string");
1720 __va_copy 0 va_copy || __va_copy 1 __va_copy
1723 run_check pathconf 'f?pathconf(2)' '#define HAVE_PATHCONF' << \!
1730 rv |= !(pathconf(".", _PC_NAME_MAX) >= 0 || errno == 0 || errno != ENOSYS);
1732 rv |= !(pathconf(".", _PC_PATH_MAX) >= 0 || errno == 0 || errno != ENOSYS);
1734 /* Only link check */
1735 fpathconf(0, _PC_NAME_MAX);
1741 run_check pipe2 'pipe2(2)' '#define HAVE_PIPE2' << \!
1748 if(!pipe2(fds, O_CLOEXEC) || errno != ENOSYS)
1754 link_check tcgetwinsize 'tcgetwinsize(3)' '#define HAVE_TCGETWINSIZE' << \!
1755 #include <termios.h>
1759 tcgetwinsize(0, &ws);
1764 # We use this only then for now (need NOW+1)
1765 run_check utimensat 'utimensat(2)' '#define HAVE_UTIMENSAT' << \!
1766 #include <fcntl.h> /* For AT_* */
1767 #include <sys/stat.h>
1770 struct timespec ts[2];
1772 ts[0].tv_nsec = UTIME_NOW;
1773 ts[1].tv_nsec = UTIME_OMIT;
1774 if(!utimensat(AT_FDCWD, "", ts, 0) || errno != ENOSYS)
1782 # XXX Add POSIX check once standardized
1783 if link_check posix_random 'arc4random(3)' '#define HAVE_POSIX_RANDOM 0' << \!
1792 elif link_check getrandom 'getrandom(2) (in sys/random.h)' \
1793 '#define HAVE_GETRANDOM(B,S) getrandom(B, S, 0)
1794 #define HAVE_GETRANDOM_HEADER <sys/random.h>' <<\!
1795 #include <sys/random.h>
1798 getrandom(buf, sizeof buf, 0);
1804 elif link_check getrandom 'getrandom(2) (via syscall(2))' \
1805 '#define HAVE_GETRANDOM(B,S) syscall(SYS_getrandom, B, S, 0)
1806 #define HAVE_GETRANDOM_HEADER <sys/syscall.h>' <<\!
1807 #include <sys/syscall.h>
1810 syscall(SYS_getrandom, buf, sizeof buf, 0);
1816 elif [ -n "${have_no_subsecond_time}" ]; then
1817 msg 'ERROR: %s %s' 'without a native random' \
1818 'one of clock_gettime(2) and gettimeofday(2) is required.'
1823 link_check putc_unlocked 'putc_unlocked(3)' '#define HAVE_PUTC_UNLOCKED' <<\!
1826 putc_unlocked('@', stdout);
1831 link_check fchdir 'fchdir(3)' '#define HAVE_FCHDIR' << \!
1839 if run_check realpath 'realpath(3)' '#define HAVE_REALPATH' << \!
1842 char x_buf[4096], *x = realpath(".", x_buf);
1844 return (x != NULL) ? 0 : 1;
1848 if run_check realpath_malloc 'realpath(3) takes NULL' \
1849 '#define HAVE_REALPATH_NULL' << \!
1852 char *x = realpath(".", NULL);
1856 return (x != NULL) ? 0 : 1;
1864 ## optional and selectable
1866 if feat_yes DOTLOCK; then
1867 if run_check readlink 'readlink(2)' << \!
1873 if(!readlink("here", buf, sizeof buf) || errno != ENOSYS)
1881 feat_bail_required DOTLOCK
1885 if feat_yes DOTLOCK; then
1886 if run_check fchown 'fchown(2)' << \!
1890 if(!fchown(0, 0, 0) || errno != ENOSYS)
1898 feat_bail_required DOTLOCK
1902 ## Now it is the time to fork away the BASE_ series
1905 squeeze_em ${inc} ${tmp}
1907 squeeze_em ${lib} ${tmp}
1910 echo "BASE_LIBS = `${cat} ${lib}`" >> ${mk}
1911 echo "BASE_INCS = `${cat} ${inc}`" >> ${mk}
1913 ## The remains are expected to be used only by the main MUA binary!
1916 link_check setlocale 'setlocale(3)' '#define HAVE_SETLOCALE' << \!
1919 setlocale(LC_ALL, "");
1923 [ -n "${have_setlocale}" ] && OPT_LOCALES=1
1925 OPT_MULTIBYTE_CHARSETS=0
1927 OPT_TERMINAL_CHARSET=0
1928 if [ -n "${have_setlocale}" ]; then
1929 link_check c90amend1 'ISO/IEC 9899:1990/Amendment 1:1995' \
1930 '#define HAVE_C90AMEND1' << \!
1936 char mbb[MB_LEN_MAX + 1];
1941 mbtowc(&wc, "x
", 1);
1942 mbrtowc(&wc, "x
", 1, NULL);
1944 return (mblen("\
0", 1) == 0);
1947 [ -n "${have_c90amend1}" ] && OPT_MULTIBYTE_CHARSETS=1
1949 if [ -n "${have_c90amend1}" ]; then
1950 link_check wcwidth 'wcwidth(3)' '#define HAVE_WCWIDTH' << \!
1957 [ -n "${have_wcwidth}" ] && OPT_WIDE_GLYPHS=1
1960 link_check nl_langinfo 'nl_langinfo(3)' '#define HAVE_NL_LANGINFO' << \!
1961 #include <langinfo.h>
1965 return (nl_langinfo(CODESET) == NULL);
1968 [ -n "${have_nl_langinfo}" ] && OPT_TERMINAL_CHARSET=1
1971 link_check fnmatch 'fnmatch(3)' '#define HAVE_FNMATCH' << \!
1972 #include <fnmatch.h>
1974 return (fnmatch("*", ".
", FNM_PATHNAME | FNM_PERIOD) == FNM_NOMATCH);
1978 link_check dirent_d_type 'struct dirent.d_type' '#define HAVE_DIRENT_TYPE' << \!
1982 return !(de.d_type == DT_UNKNOWN ||
1983 de.d_type == DT_DIR || de.d_type == DT_LNK);
1987 ## optional and selectable
1989 if feat_yes ICONV; then
1990 ${cat} > ${tmp2}.c << \!
1991 #include <stdio.h> /* For C89 NULL */
1996 id = iconv_open("foo
", "bar
");
1997 iconv(id, NULL, NULL, NULL, NULL);
2002 < ${tmp2}.c link_check iconv 'iconv(3) functionality' \
2003 '#define HAVE_ICONV' ||
2004 < ${tmp2}.c link_check iconv 'iconv(3) functionality (via -liconv)' \
2005 '#define HAVE_ICONV' '-liconv' ||
2006 feat_bail_required ICONV
2008 echo '/* OPT_ICONV=0 */' >> ${h}
2011 if feat_yes SOCKETS || feat_yes SPAM_SPAMD; then
2012 ${cat} > ${tmp2}.c << \!
2013 #include <sys/types.h>
2014 #include <sys/socket.h>
2018 struct sockaddr_un soun;
2020 if(socket(AF_UNIX, SOCK_STREAM, 0) == -1 && errno == ENOSYS)
2022 if(connect(0, (struct sockaddr*)&soun, 0) == -1 && errno == ENOSYS)
2024 if(shutdown(0, SHUT_RD | SHUT_WR | SHUT_RDWR) == -1 && errno == ENOSYS)
2030 < ${tmp2}.c run_check af_unix 'AF_UNIX sockets' \
2031 '#define HAVE_UNIX_SOCKETS' ||
2032 < ${tmp2}.c run_check af_unix 'AF_UNIX sockets (via -lnsl)' \
2033 '#define HAVE_UNIX_SOCKETS' '-lnsl' ||
2034 < ${tmp2}.c run_check af_unix 'AF_UNIX sockets (via -lsocket -lnsl)' \
2035 '#define HAVE_UNIX_SOCKETS' '-lsocket -lnsl'
2038 if feat_yes SOCKETS; then
2039 ${cat} > ${tmp2}.c << \!
2040 #include <sys/types.h>
2041 #include <sys/socket.h>
2042 #include <netinet/in.h>
2047 if(socket(AF_INET, SOCK_STREAM, 0) == -1 && errno == ENOSYS)
2049 if(connect(0, &s, 0) == -1 && errno == ENOSYS)
2055 < ${tmp2}.c run_check sockets 'sockets' \
2056 '#define HAVE_SOCKETS' ||
2057 < ${tmp2}.c run_check sockets 'sockets (via -lnsl)' \
2058 '#define HAVE_SOCKETS' '-lnsl' ||
2059 < ${tmp2}.c run_check sockets 'sockets (via -lsocket -lnsl)' \
2060 '#define HAVE_SOCKETS' '-lsocket -lnsl' ||
2061 feat_bail_required SOCKETS
2063 echo '/* OPT_SOCKETS=0 */' >> ${h}
2064 fi # feat_yes SOCKETS
2066 if feat_yes SOCKETS; then
2067 link_check getaddrinfo 'getaddrinfo(3)' \
2068 '#define HAVE_GETADDRINFO' << \!
2069 #include <sys/types.h>
2070 #include <sys/socket.h>
2074 struct addrinfo a, *ap;
2077 switch((lrv = getaddrinfo("foo
", "0", &a, &ap))){
2081 fprintf(stderr, "%s
\n", gai_strerror(lrv));
2090 if feat_yes SOCKETS && [ -z "${have_getaddrinfo}" ]; then
2091 compile_check arpa_inet_h '<arpa/inet.h>' \
2092 '#define HAVE_ARPA_INET_H' << \!
2093 #include <sys/types.h>
2094 #include <sys/socket.h>
2096 #include <netinet/in.h>
2097 #include <arpa/inet.h>
2100 ${cat} > ${tmp2}.c << \!
2101 #include <sys/types.h>
2102 #include <sys/socket.h>
2106 #include <netinet/in.h>
2107 #ifdef HAVE_ARPA_INET_H
2108 #include <arpa/inet.h>
2111 struct sockaddr_in servaddr;
2112 unsigned short portno;
2115 struct in_addr **pptr;
2118 if((ep = getservbyname("POPPY-PORT
", "tcp
")) != NULL)
2119 portno = (unsigned short)ep->s_port;
2121 if((hp = gethostbyname("POPPY-HOST
")) != NULL){
2122 pptr = (struct in_addr**)hp->h_addr_list;
2123 if(hp->h_addrtype != AF_INET)
2124 fprintf(stderr, "au
\n");
2127 case HOST_NOT_FOUND:
2133 fprintf(stderr, "au
\n");
2138 memset(&servaddr, 0, sizeof servaddr);
2139 servaddr.sin_family = AF_INET;
2140 servaddr.sin_port = htons(portno);
2141 memcpy(&servaddr.sin_addr, *pptr, sizeof(struct in_addr));
2142 fprintf(stderr, "Would connect to
%s
:%d ...
\n",
2143 inet_ntoa(**pptr), (int)portno);
2148 < ${tmp2}.c link_check gethostbyname 'get(serv|host)byname(3)' ||
2149 < ${tmp2}.c link_check gethostbyname \
2150 'get(serv|host)byname(3) (via -nsl)' '' '-lnsl' ||
2151 < ${tmp2}.c link_check gethostbyname \
2152 'get(serv|host)byname(3) (via -lsocket -nsl)' \
2153 '' '-lsocket -lnsl' ||
2154 feat_bail_required SOCKETS
2158 run_check setsockopt 'setsockopt(2)' '#define HAVE_SETSOCKOPT' << \!
2159 #include <sys/socket.h>
2165 if(setsockopt(sockfd, SOL_SOCKET, SO_KEEPALIVE, NULL, 0) == -1 &&
2172 feat_yes SOCKETS && [ -n "${have_setsockopt}" ] &&
2173 link_check so_sndtimeo 'SO_SNDTIMEO' '#define HAVE_SO_SNDTIMEO' << \!
2174 #include <sys/socket.h>
2182 setsockopt(sockfd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof tv);
2183 setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof tv);
2188 feat_yes SOCKETS && [ -n "${have_setsockopt}" ] &&
2189 link_check so_linger 'SO_LINGER' '#define HAVE_SO_LINGER' << \!
2190 #include <sys/socket.h>
2198 setsockopt(sockfd, SOL_SOCKET, SO_LINGER, &li, sizeof li);
2204 if feat_yes SSL; then # {{{
2205 # {{{ LibreSSL decided to define OPENSSL_VERSION_NUMBER with a useless value
2206 # instead of keeping it at the one that corresponds to the OpenSSL at fork
2207 # time: we need to test it first in order to get things right
2208 if compile_check _xssl 'TLS/SSL (LibreSSL)' \
2211 #define HAVE_XSSL_RESSL
2212 #define HAVE_XSSL_OPENSSL 0' << \!
2213 #include <openssl/opensslv.h>
2214 #ifdef LIBRESSL_VERSION_NUMBER
2221 VAL_SSL_FEATURES=libressl
2222 # TODO OPENSSL_IS_BORINGSSL, but never tried that one!
2223 elif compile_check _xssl 'TLS/SSL (OpenSSL >= v1.1.0)' \
2226 #define HAVE_XSSL_OPENSSL 0x10100' << \!
2227 #include <openssl/opensslv.h>
2228 #if OPENSSL_VERSION_NUMBER + 0 >= 0x10100000L
2235 VAL_SSL_FEATURES=libssl-0x10100
2236 elif compile_check _xssl 'TLS/SSL (OpenSSL)' \
2239 #define HAVE_XSSL_OPENSSL 0x10000' << \!
2240 #include <openssl/opensslv.h>
2241 #ifdef OPENSSL_VERSION_NUMBER
2248 VAL_SSL_FEATURES=libssl-0x10000
2250 feat_bail_required SSL
2253 if feat_yes SSL; then # {{{
2254 if [ -n "${ossl_v1_1}" ]; then
2255 without_check yes xssl 'TLS/SSL new style TLS_client_method(3ssl)' \
2256 '#define n_XSSL_CLIENT_METHOD TLS_client_method' \
2258 elif link_check xssl 'TLS/SSL new style TLS_client_method(3ssl)' \
2259 '#define n_XSSL_CLIENT_METHOD TLS_client_method' \
2260 '-lssl -lcrypto' << \!
2261 #include <openssl/ssl.h>
2262 #include <openssl/err.h>
2263 #include <openssl/x509v3.h>
2264 #include <openssl/x509.h>
2265 #include <openssl/rand.h>
2266 #ifdef OPENSSL_NO_TLS1 /* TODO only deduced from OPENSSL_NO_SSL[23]! */
2267 # error We need TLSv1.
2270 SSL_CTX *ctx = SSL_CTX_new(TLS_client_method());
2273 PEM_read_PrivateKey(0, 0, 0, 0);
2279 elif link_check xssl 'TLS/SSL old style SSLv23_client_method(3ssl)' \
2280 '#define n_XSSL_CLIENT_METHOD SSLv23_client_method' \
2281 '-lssl -lcrypto' << \!
2282 #include <openssl/ssl.h>
2283 #include <openssl/err.h>
2284 #include <openssl/x509v3.h>
2285 #include <openssl/x509.h>
2286 #include <openssl/rand.h>
2287 #if defined OPENSSL_NO_SSL3 &&\
2288 defined OPENSSL_NO_TLS1 /* TODO only deduced from OPENSSL_NO_SSL[23]! */
2289 # error We need one of SSLv3 and TLSv1.
2292 SSL_CTX *ctx = SSL_CTX_new(SSLv23_client_method());
2295 PEM_read_PrivateKey(0, 0, 0, 0);
2302 feat_bail_required SSL
2306 if feat_yes SSL; then # {{{
2307 if feat_yes SSL_ALL_ALGORITHMS; then
2308 if [ -n "${ossl_v1_1}" ]; then
2309 without_check yes ssl_all_algo 'TLS/SSL all-algorithms support' \
2310 '#define HAVE_SSL_ALL_ALGORITHMS'
2311 elif link_check ssl_all_algo 'TLS/SSL all-algorithms support' \
2312 '#define HAVE_SSL_ALL_ALGORITHMS' << \!
2313 #include <openssl/evp.h>
2315 OpenSSL_add_all_algorithms();
2316 EVP_get_cipherbyname("two cents i never exist
");
2324 feat_bail_required SSL_ALL_ALGORITHMS
2326 elif [ -n "${ossl_v1_1}" ]; then
2327 without_check yes ssl_all_algo \
2328 'TLS/SSL all-algorithms (always available in v1.1.0+)' \
2329 '#define HAVE_SSL_ALL_ALGORITHMS'
2332 if [ -n "${ossl_v1_1}" ]; then
2333 without_check yes xssl_stack_of 'TLS/SSL STACK_OF()' \
2334 '#define HAVE_XSSL_STACK_OF'
2335 elif compile_check xssl_stack_of 'TLS/SSL STACK_OF()' \
2336 '#define HAVE_XSSL_STACK_OF' << \!
2337 #include <stdio.h> /* For C89 NULL */
2338 #include <openssl/ssl.h>
2339 #include <openssl/err.h>
2340 #include <openssl/x509v3.h>
2341 #include <openssl/x509.h>
2342 #include <openssl/rand.h>
2344 STACK_OF(GENERAL_NAME) *gens = NULL;
2346 printf("%p
", gens); /* to use it */
2354 if [ -n "${ossl_v1_1}" ]; then
2355 without_check yes xssl_conf 'TLS/SSL OpenSSL_modules_load_file(3ssl)' \
2356 '#define HAVE_XSSL_CONFIG'
2357 VAL_SSL_FEATURES="${VAL_SSL_FEATURES},+modules-load-file
"
2358 elif link_check xssl_conf \
2359 'TLS/SSL OpenSSL_modules_load_file(3ssl) support' \
2360 '#define HAVE_XSSL_CONFIG' << \!
2361 #include <stdio.h> /* For C89 NULL */
2362 #include <openssl/conf.h>
2364 CONF_modules_load_file(NULL, NULL, CONF_MFLAGS_IGNORE_MISSING_FILE);
2365 CONF_modules_free();
2370 VAL_SSL_FEATURES="${VAL_SSL_FEATURES},+modules-load-file
"
2372 VAL_SSL_FEATURES="${VAL_SSL_FEATURES},-modules-load-file"
2375 if [ -n "${ossl_v1_1}" ]; then
2376 without_check yes xssl_conf_ctx 'TLS/SSL SSL_CONF_CTX support' \
2377 '#define HAVE_XSSL_CONF_CTX'
2378 VAL_SSL_FEATURES="${VAL_SSL_FEATURES},+conf-ctx
"
2379 elif link_check xssl_conf_ctx 'TLS/SSL SSL_CONF_CTX support' \
2380 '#define HAVE_XSSL_CONF_CTX' << \!
2381 #include <openssl/ssl.h>
2382 #include <openssl/err.h>
2384 SSL_CTX *ctx = SSL_CTX_new(n_XSSL_CLIENT_METHOD());
2385 SSL_CONF_CTX *cctx = SSL_CONF_CTX_new();
2387 SSL_CONF_CTX_set_flags(cctx,
2388 SSL_CONF_FLAG_FILE | SSL_CONF_FLAG_CLIENT |
2389 SSL_CONF_FLAG_CERTIFICATE | SSL_CONF_FLAG_SHOW_ERRORS);
2390 SSL_CONF_CTX_set_ssl_ctx(cctx, ctx);
2391 SSL_CONF_cmd(cctx, "Protocol
", "ALL
");
2392 SSL_CONF_CTX_finish(cctx);
2393 SSL_CONF_CTX_free(cctx);
2399 VAL_SSL_FEATURES="${VAL_SSL_FEATURES},+conf-ctx
"
2401 VAL_SSL_FEATURES="${VAL_SSL_FEATURES},-conf-ctx"
2404 if [ -n "${ossl_v1_1}" ]; then
2405 without_check yes xssl_ctx_config 'TLS/SSL SSL_CTX_config(3ssl)' \
2406 '#define HAVE_XSSL_CTX_CONFIG'
2407 VAL_SSL_FEATURES="${VAL_SSL_FEATURES},+ctx-config
"
2408 elif [ -n "${have_xssl_conf}" ] && [ -n "${have_xssl_conf_ctx}" ] &&
2409 link_check xssl_ctx_config 'TLS/SSL SSL_CTX_config(3ssl)' \
2410 '#define HAVE_XSSL_CTX_CONFIG' << \!
2411 #include <stdio.h> /* For C89 NULL */
2412 #include <openssl/ssl.h>
2414 SSL_CTX_config(NULL, "SOMEVAL
");
2419 VAL_SSL_FEATURES="${VAL_SSL_FEATURES},+ctx-config
"
2421 VAL_SSL_FEATURES="${VAL_SSL_FEATURES},-ctx-config"
2424 if [ -n "${ossl_v1_1}" ] && [ -n "${have_xssl_conf_ctx}" ]; then
2425 without_check yes xssl_set_maxmin_proto \
2426 'TLS/SSL SSL_CTX_set_min_proto_version(3ssl)' \
2427 '#define HAVE_XSSL_SET_MIN_PROTO_VERSION'
2428 VAL_SSL_FEATURES="${VAL_SSL_FEATURES},+ctx-set-maxmin-proto
"
2429 elif link_check xssl_set_maxmin_proto \
2430 'TLS/SSL SSL_CTX_set_min_proto_version(3ssl)' \
2431 '#define HAVE_XSSL_SET_MIN_PROTO_VERSION' << \!
2432 #include <stdio.h> /* For C89 NULL */
2433 #include <openssl/ssl.h>
2435 SSL_CTX_set_min_proto_version(NULL, 0);
2436 SSL_CTX_set_max_proto_version(NULL, 10);
2441 VAL_SSL_FEATURES="${VAL_SSL_FEATURES},+ctx-set-maxmin-proto
"
2443 VAL_SSL_FEATURES="${VAL_SSL_FEATURES},-ctx-set-maxmin-proto"
2446 if link_check xssl_rand_egd 'TLS/SSL RAND_egd(3ssl)' \
2447 '#define HAVE_XSSL_RAND_EGD' << \!
2448 #include <openssl/rand.h>
2450 return RAND_egd("some.where
") > 0;
2454 VAL_SSL_FEATURES="${VAL_SSL_FEATURES},+rand-egd
"
2456 VAL_SSL_FEATURES="${VAL_SSL_FEATURES},-rand-egd"
2458 fi # feat_yes SSL }}}
2460 if feat_yes SSL && feat_yes MD5 && feat_no NOEXTMD5; then # {{{
2461 run_check ssl_md5 'MD5 digest in the used crypto library' \
2462 '#define HAVE_XSSL_MD5' << \!
2465 #include <openssl/md5.h>
2467 char const dat[] = "abrakadabrafidibus
";
2468 char dig[16], hex[16 * 2];
2472 memset(dig, 0, sizeof(dig));
2473 memset(hex, 0, sizeof(hex));
2475 MD5_Update(&ctx, dat, sizeof(dat) - 1);
2476 MD5_Final(dig, &ctx);
2478 #define hexchar(n) ((n) > 9 ? (n) - 10 + 'a' : (n) + '0')
2479 for(i = 0; i < sizeof(hex) / 2; i++){
2481 hex[j] = hexchar((dig[i] & 0xf0) >> 4);
2482 hex[++j] = hexchar(dig[i] & 0x0f);
2484 return !!memcmp("6d7d0a3d949da2e96f2aa010f65d8326
", hex, sizeof(hex));
2489 echo '/* OPT_SSL=0 */' >> ${h}
2490 fi # }}} feat_yes SSL
2491 printf '#define VAL_SSL_FEATURES "#'"${VAL_SSL_FEATURES}"'"\n' >> ${h}
2493 if [ "${have_xssl}" = yes ]; then
2504 if feat_yes GSSAPI
; then
2505 ${cat} > ${tmp2}.c
<< \
!
2506 #include <gssapi/gssapi.h>
2508 gss_import_name
(0, 0, GSS_C_NT_HOSTBASED_SERVICE
, 0);
2509 gss_init_sec_context
(0,0,0,0,0,0,0,0,0,0,0,0,0);
2513 ${sed} -e '1s/gssapi\///' < ${tmp2}.c > ${tmp3}.c
2515 if acmd_set i krb5-config
; then
2516 GSS_LIBS
="`CFLAGS= ${i} --libs gssapi`"
2517 GSS_INCS
="`CFLAGS= ${i} --cflags`"
2518 i
='GSS-API via krb5-config(1)'
2522 i
='GSS-API in gssapi/gssapi.h, libgssapi'
2524 if < ${tmp2}.c link_check gss \
2525 "${i}" '#define HAVE_GSSAPI' "${GSS_LIBS}" "${GSS_INCS}" ||\
2526 < ${tmp3}.c link_check gss \
2527 'GSS-API in gssapi.h, libgssapi' \
2528 '#define HAVE_GSSAPI
2529 #define GSSAPI_REG_INCLUDE' \
2531 < ${tmp2}.c link_check gss
'GSS-API in libgssapi_krb5' \
2532 '#define HAVE_GSSAPI' \
2534 < ${tmp3}.c link_check gss \
2535 'GSS-API in libgssapi, OpenBSD-style (pre 5.3)' \
2536 '#define HAVE_GSSAPI
2537 #define GSS_REG_INCLUDE' \
2538 '-lgssapi -lkrb5 -lcrypto' \
2539 '-I/usr/include/kerberosV' ||\
2540 < ${tmp2}.c link_check gss
'GSS-API in libgss' \
2541 '#define HAVE_GSSAPI' \
2543 link_check gss
'GSS-API in libgssapi_krb5, old-style' \
2544 '#define HAVE_GSSAPI
2545 #define GSSAPI_OLD_STYLE' \
2546 '-lgssapi_krb5' << \
!
2547 #include <gssapi/gssapi.h>
2548 #include <gssapi/gssapi_generic.h>
2550 gss_import_name
(0, 0, gss_nt_service_name
, 0);
2551 gss_init_sec_context
(0,0,0,0,0,0,0,0,0,0,0,0,0);
2558 feat_bail_required GSSAPI
2561 echo '/* OPT_GSSAPI=0 */' >> ${h}
2562 fi # feat_yes GSSAPI
2567 if feat_yes IDNA
; then
2568 if link_check idna
'GNU Libidn' '#define HAVE_IDNA HAVE_IDNA_LIBIDNA' \
2571 #include <idn-free.h>
2572 #include <stringprep.h>
2574 char
*utf8
, *idna_ascii
, *idna_utf8
;
2576 utf8
= stringprep_locale_to_utf8
("does.this.work");
2577 if (idna_to_ascii_8z
(utf8
, &idna_ascii
, IDNA_USE_STD3_ASCII_RULES
)
2580 idn_free
(idna_ascii
);
2581 /* (Rather link check only here
) */
2582 idna_utf8
= stringprep_convert
(idna_ascii
, "UTF-8", "de_DE");
2588 elif link_check idna
'idnkit' '#define HAVE_IDNA HAVE_IDNA_IDNKIT' \
2591 #include <idn/api.h>
2592 #include <idn/result.h>
2596 char local_name
[256];
2598 r
= idn_encodename
(IDN_ENCODE_APP
, "does.this.work", ace_name
,
2600 if (r
!= idn_success
) {
2601 fprintf
(stderr
, "idn_encodename failed: %s\n", idn_result_tostring
(r
));
2604 r
= idn_decodename
(IDN_DECODE_APP
, ace_name
, local_name
, sizeof
(local_name
));
2605 if (r
!= idn_success
) {
2606 fprintf
(stderr
, "idn_decodename failed: %s\n", idn_result_tostring
(r
));
2615 feat_bail_required IDNA
2618 if [ -n "${have_idna}" ]; then
2619 echo '#define HAVE_IDNA_LIBIDNA 0' >> ${h}
2620 echo '#define HAVE_IDNA_IDNKIT 1' >> ${h}
2623 echo '/* OPT_IDNA=0 */' >> ${h}
2626 feat_def IMAP_SEARCH
2628 if feat_yes REGEX
; then
2629 if link_check regex
'regular expressions' '#define HAVE_REGEX' << \
!
2637 status
= regcomp
(&re
, ".*bsd", REG_EXTENDED | REG_ICASE | REG_NOSUB
);
2638 xret
= regerror
(status
, &re
, NULL
, 0);
2639 status
= regexec
(&re
, "plan9", 0,NULL
, 0);
2641 return !(status
== REG_NOMATCH
);
2647 feat_bail_required REGEX
2650 echo '/* OPT_REGEX=0 */' >> ${h}
2653 if feat_yes MLE
&& [ -n "${have_c90amend1}" ]; then
2655 echo '#define HAVE_MLE' >> ${h}
2657 feat_bail_required MLE
2658 echo '/* OPT_MLE=0 */' >> ${h}
2661 # Generic have-a-line-editor switch for those who need it below
2662 if [ -n "${have_mle}" ]; then
2666 if [ -n "${have_cle}" ] && feat_yes HISTORY
; then
2667 echo '#define HAVE_HISTORY' >> ${h}
2669 echo '/* OPT_HISTORY=0 */' >> ${h}
2672 if [ -n "${have_mle}" ] && feat_yes KEY_BINDINGS
; then
2673 echo '#define HAVE_KEY_BINDINGS' >> ${h}
2675 echo '/* OPT_KEY_BINDINGS=0 */' >> ${h}
2678 if feat_yes TERMCAP
; then
2680 link_check termcap
"termcap(5) (via ${4})" \
2681 "#define HAVE_TERMCAP${3}" "${1}" << _EOT
2686 #define UNCONST(P) ((void*)(unsigned long)(void const*)(P))
2687 static int my_putc(int c){return putchar(c);}
2689 char buf[1024+512], cmdbuf[2048], *cpb, *r1;
2690 int r2 = OK, r3 = ERR;
2692 tgetent(buf, getenv("TERM"));
2694 r1 = tgetstr(UNCONST("cm"), &cpb);
2696 r2 = tgetnum(UNCONST("Co"));
2697 r3 = tgetflag(UNCONST("ut"));
2698 tputs("cr", 1, &my_putc);
2699 return (r1 == NULL || r2 == -1 || r3 == 0);
2705 link_check terminfo
"terminfo(5) (via ${2})" \
2706 '#define HAVE_TERMCAP
2707 #define HAVE_TERMCAP_CURSES
2708 #define HAVE_TERMINFO' "${1}" << _EOT
2712 #define UNCONST(P) ((void*)(unsigned long)(void const*)(P))
2713 static int my_putc(int c){return putchar(c);}
2719 r0 = setupterm(NULL, 1, &er);
2720 r1 = tigetflag(UNCONST("bce"));
2721 r2 = tigetnum(UNCONST("colors"));
2722 r3 = tigetstr(UNCONST("cr"));
2723 tp = tparm(r3, NULL, NULL, 0,0,0,0,0,0,0);
2724 tputs(tp, 1, &my_putc);
2725 return (r0 == ERR || r1 == -1 || r2 == -2 || r2 == -1 ||
2726 r3 == (char*)-1 || r3 == NULL);
2731 if feat_yes TERMCAP_VIA_TERMINFO
; then
2732 __terminfolib
-ltinfo -ltinfo ||
2733 __terminfolib
-lcurses -lcurses ||
2734 __terminfolib
-lcursesw -lcursesw ||
2735 feat_bail_required TERMCAP_VIA_TERMINFO
2738 if [ -z "${have_terminfo}" ]; then
2739 __termcaplib
-ltermcap '' '' '-ltermcap' ||
2740 __termcaplib
-ltermcap '#include <curses.h>' '
2741 #define HAVE_TERMCAP_CURSES' \
2742 'curses.h / -ltermcap' ||
2743 __termcaplib
-lcurses '#include <curses.h>' '
2744 #define HAVE_TERMCAP_CURSES' \
2745 'curses.h / -lcurses' ||
2746 __termcaplib
-lcursesw '#include <curses.h>' '
2747 #define HAVE_TERMCAP_CURSES' \
2748 'curses.h / -lcursesw' ||
2749 feat_bail_required TERMCAP
2751 if [ -n "${have_termcap}" ]; then
2752 run_check tgetent_null \
2753 "tgetent(3) of termcap(5) takes NULL buffer" \
2754 "#define HAVE_TGETENT_NULL_BUF" << _EOT
2755 #include <stdio.h> /* For C89 NULL */
2757 #ifdef HAVE_TERMCAP_CURSES
2758 # include <curses.h>
2762 tgetent(NULL, getenv("TERM"));
2769 echo '/* OPT_TERMCAP=0 */' >> ${h}
2770 echo '/* OPT_TERMCAP_VIA_TERMINFO=0 */' >> ${h}
2773 if feat_def SPAM_SPAMC
; then
2774 if acmd_set i spamc
; then
2775 echo "#define SPAM_SPAMC_PATH \"${i}\"" >> ${h}
2779 if feat_yes SPAM_SPAMD
&& [ -n "${have_af_unix}" ]; then
2780 echo '#define HAVE_SPAM_SPAMD' >> ${h}
2782 feat_bail_required SPAM_SPAMD
2783 echo '/* OPT_SPAM_SPAMD=0 */' >> ${h}
2786 feat_def SPAM_FILTER
2788 if feat_yes SPAM_SPAMC || feat_yes SPAM_SPAMD || feat_yes SPAM_FILTER
; then
2789 echo '#define HAVE_SPAM' >> ${h}
2791 echo '/* HAVE_SPAM */' >> ${h}
2794 if feat_yes QUOTE_FOLD
&&\
2795 [ -n "${have_c90amend1}" ] && [ -n "${have_wcwidth}" ]; then
2796 echo '#define HAVE_QUOTE_FOLD' >> ${h}
2798 feat_bail_required QUOTE_FOLD
2799 echo '/* OPT_QUOTE_FOLD=0 */' >> ${h}
2802 feat_def FILTER_HTML_TAGSOUP
2810 squeeze_em
${inc} ${tmp}
2812 squeeze_em
${lib} ${tmp}
2817 printf '#ifndef n_MK_CONFIG_H\n# define n_MK_CONFIG_H 1\n' > ${h}
2818 ${cat} ${tmp} >> ${h}
2822 # Create the string that is used by *features* and `version'.
2823 # Take this nice opportunity and generate a visual listing of included and
2824 # non-included features for the person who runs the configuration
2825 msg
'\nThe following features are included (+) or not (-):'
2826 set -- ${OPTIONS_DETECT} ${OPTIONS} ${OPTIONS_XTRA}
2827 printf '/* The "feature string" */\n' >> ${h}
2828 # Because + is expanded by *folder* if first in "echo $features", put something
2829 printf '#define VAL_FEATURES_CNT '${#}'\n#define VAL_FEATURES "#' >> ${h}
2833 sdoc
=`option_doc_of ${opt}`
2834 [ -z "${sdoc}" ] && continue
2835 sopt
="`echo ${opt} | ${tr} '[A-Z]_' '[a-z]-'`"
2836 feat_yes
${opt} && sign
=+ || sign
=-
2837 printf -- "${sep}${sign}${sopt}" >> ${h}
2839 msg " %s
%s
: %s
" ${sign} ${sopt} "${sdoc}"
2841 # TODO instead of using sh+tr+awk+printf, use awk, drop option_doc_of, inc here
2843 #${awk} -v opts="${OPTIONS_DETECT} ${OPTIONS} ${OPTIONS_XTRA}" \
2844 # -v xopts="${XOPTIONS_DETECT} ${XOPTIONS} ${XOPTIONS_XTRA}" \
2845 printf '"\n' >> ${h}
2847 # Create the real mk-config.mk
2848 # Note we cannout use explicit ./ filename prefix for source and object
2849 # pathnames because of a bug in bmake(1)
2850 ${rm} -rf ${tmp0}.* ${tmp0}*
2852 if feat_no AMALGAMATION
; then
2853 for i
in `printf '%s\n' "${SRCDIR}"*.c | ${sort}`; do
2854 i
=`basename "${i}" .c`
2855 if [ "${i}" = privsep
]; then
2858 objlist
="${objlist} ${i}.o"
2859 srclist
="${srclist} \$(SRCDIR)${i}.c"
2860 printf '%s: %s\n\t$(ECHO_CC)$(CC) $(CFLAGS) $(INCS) -c %s\n' \
2861 "${i}.o" "\$(SRCDIR)${i}.c" "\$(SRCDIR)${i}.c" >> ${mk}
2863 printf '\nAMALGAM_TARGET =\nAMALGAM_DEP =\n' >> ${mk}
2865 printf '%s:\n\t$(ECHO_CC)$(CC) $(CFLAGS) $(INCS) -c $(SRCDIR)%s\n' \
2866 "main.o
" "main.c
" >> ${mk}
2867 srclist=main.c objlist=main.o
2868 printf '\nAMALGAM_TARGET = main.o\nAMALGAM_DEP = ' >> ${mk}
2870 printf '\n/* HAVE_AMALGAMATION: include sources */\n' >> ${h}
2871 printf '#elif n_MK_CONFIG_H + 0 == 1\n' >> ${h}
2872 printf '# undef n_MK_CONFIG_H\n' >> ${h}
2873 printf '# define n_MK_CONFIG_H 2\n' >> ${h}
2874 for i in `printf '%s\n' "${SRCDIR}"*.c | ${sort}`; do
2876 if [ "${i}" = main.c ] ||
2877 [ "${i}" = privsep.c ]; then
2880 printf '$(SRCDIR)%s ' "${i}" >> ${mk}
2881 printf '# include "%s
%s
"\n' "${SRCDIR}" "${i}" >> ${h}
2885 printf 'OBJ_SRC = %s\nOBJ = %s\n' "${srclist}" "${objlist}" >> "${mk}"
2887 printf '#endif /* n_MK_CONFIG_H */\n' >> ${h}
2889 echo "LIBS = `${cat} ${lib}`" >> ${mk}
2890 echo "INCS
= `${cat} ${inc}`" >> ${mk}
2892 ${cat} "${SRCDIR}"make-config.in >> ${mk}
2897 msg ' . System-wide resource file: %s/%s' "${VAL_SYSCONFDIR}" "${VAL_SYSCONFRC}"
2898 msg ' . bindir: %s' "${VAL_BINDIR}"
2899 if feat_yes DOTLOCK; then
2900 msg ' . libexecdir: %s' "${VAL_LIBEXECDIR}"
2902 msg ' . mandir: %s' "${VAL_MANDIR}"
2903 msg ' . M(ail)T(ransfer)A(gent): %s (argv0: %s)' "${VAL_MTA}" "${VAL_MTA_ARGV0}"
2904 msg ' . $MAIL spool directory: %s' "${VAL_MAIL}"
2907 if [ -n "${have_fnmatch}" ] && [ -n "${have_fchdir}" ]; then
2911 if [ -z "${have_fnmatch}" ]; then
2912 msg ' . The function fnmatch(3) could not be found.'
2913 msg ' Filename patterns like wildcard are not supported on your system'
2915 if [ -z "${have_fchdir}" ]; then
2916 msg ' . The function fchdir(2) could not be found.'
2917 msg ' We will use chdir(2) instead.'
2918 msg ' This is a problem only if the current working directory is changed'
2919 msg ' while this program is inside of it'