2 #@ Please see INSTALL and make.rc instead.
7 [ -n "${SHELL}" ] || SHELL
=/bin
/sh
10 # The feature set, to be kept in sync with make.rc
11 # If no documentation given, the option is used as such; if doc is a hyphen,
12 # entry is suppressed when configuration overview is printed, and also in the
13 # *features* string: most likely for obsolete features etc.
15 ICONV='Character set conversion using iconv(3)' \
16 SOCKETS='Network support' \
17 SSL='SSL/TLS (OpenSSL / LibreSSL)' \
18 SSL_ALL_ALGORITHMS='Support of all digest and cipher algorithms' \
19 SMTP='Simple Mail Transfer Protocol client' \
20 POP3='Post Office Protocol Version 3 client' \
21 IMAP='IMAP v4r1 client' \
22 GSSAPI='Generic Security Service authentication' \
23 NETRC='.netrc file support' \
25 MD5='MD5 message digest (APOP, CRAM-MD5)' \
26 IDNA='Internationalized Domain Names for Applications (encode only)' \
27 IMAP_SEARCH='IMAP-style search expressions' \
28 REGEX='Regular expressions' \
29 MLE='Mailx Line Editor' \
30 HISTORY='Line editor history management' \
31 KEY_BINDINGS='Configurable key bindings' \
32 TERMCAP='Terminal capability queries (termcap(5))' \
33 TERMCAP_VIA_TERMINFO='Terminal capability queries use terminfo(5)' \
34 ERRORS='Error log message ring' \
35 SPAM_SPAMC='Spam management via spamc(1) of spamassassin(1)' \
37 SPAM_FILTER='Freely configurable *spam-filter-..*s' \
38 DOCSTRINGS='Command documentation help strings' \
39 QUOTE_FOLD='Extended *quote-fold*ing' \
40 FILTER_HTML_TAGSOUP='Simple built-in HTML-to-text display filter' \
41 COLOUR='Coloured message display' \
42 DOTLOCK='Dotlock files and privilege-separated dotlock program' \
45 # Options which are automatically deduced from host environment, i.e., these
46 # need special treatment all around here to warp from/to OPT_ stuff
47 # setlocale, C90AMEND1, NL_LANGINFO, wcwidth
49 LOCALES='Locale support - printable characters etc. depend on environment' \
50 MULTIBYTE_CHARSETS='Multibyte character sets' \
51 TERMINAL_CHARSET='Automatic detection of terminal character set' \
52 WIDE_GLYPHS='Wide glyph support' \
55 # Rather special options, for custom building, or which always exist.
56 # Mostly for generating the visual overview and the *features* string
58 MIME='Multipurpose Internet Mail Extensions' \
59 SMIME='S/MIME message signing, verification, en- and decryption' \
60 CROSS_BUILD='Cross-compilation: trust any detected environment' \
61 DEBUG='Debug enabled binary, not for end-users: THANKS!' \
62 DEVEL='Computers do not blunder' \
65 # The problem is that we don't have any tools we can use right now, so
66 # encapsulate stuff in functions which get called in right order later on
82 OPT_DOTLOCK
=require OPT_ICONV
=require OPT_REGEX
=require
86 option_parse OPTIONS_DETECT
"${XOPTIONS_DETECT}"
87 option_parse OPTIONS
"${XOPTIONS}"
88 option_parse OPTIONS_XTRA
"${XOPTIONS_XTRA}"
91 # Predefined CONFIG= urations take precedence over anything else
92 if [ -n "${CONFIG}" ]; then
100 [mM
][iI
][nN
][iI
][mM
][aA
][lL
])
101 OPT_DOTLOCK
=require OPT_ICONV
=require OPT_REGEX
=require
107 OPT_HISTORY
=1 OPT_KEY_BINDINGS
=1
110 [nN
][eE
][tT
][sS
][eE
][nN
][dD
])
111 OPT_DOTLOCK
=require OPT_ICONV
=require OPT_REGEX
=require
115 OPT_GSSAPI
=1 OPT_NETRC
=1
122 OPT_HISTORY
=1 OPT_KEY_BINDINGS
=1
125 [mM
][aA
][xX
][iI
][mM
][aA
][lL
])
128 [dD
][eE
][vV
][eE
][lL
])
130 OPT_DEVEL
=1 OPT_DEBUG
=1 OPT_NYD2
=1
132 [oO
][dD
][eE
][vV
][eE
][lL
])
137 echo >&2 "Unknown CONFIG= setting: ${CONFIG}"
138 echo >&2 ' NULL, NULLI, MINIMAL, NETSEND, MAXIMAL'
142 msg_nonl
"CONFIG=${CONFIG} ... "
146 # Inter-relationships
148 if feat_no SMTP
&& feat_no POP3
&& feat_no IMAP
; then
151 if feat_no SOCKETS
; then
152 if feat_require SMTP
; then
153 msg
'ERROR: need SOCKETS for required feature SMTP'
156 if feat_require POP3
; then
157 msg
'ERROR: need SOCKETS for required feature POP3'
160 if feat_require IMAP
; then
161 msg
'ERROR: need SOCKETS for required feature IMAP'
164 OPT_SSL
=0 OPT_SSL_ALL_ALGORITHMS
=0
165 OPT_SMTP
=0 OPT_POP3
=0 OPT_IMAP
=0
166 OPT_GSSAPI
=0 OPT_NETRC
=0 OPT_AGENT
=0
168 if feat_no SMTP
&& feat_no IMAP
; then
172 if feat_no ICONV
; then
173 if feat_yes IMAP
; then
174 if feat_require IMAP
; then
175 msg
'ERROR: need ICONV for required feature IMAP'
178 msg
'ERROR: disabling IMAP due to missing ICONV'
182 if feat_yes IDNA
; then
183 if feat_require IDNA
; then
184 msg
'ERROR: need ICONV for required feature IDNA'
187 msg
'ERROR: disabling IDNA due to missing ICONV'
193 OPT_HISTORY
=0 OPT_KEY_BINDINGS
=0
196 # If we don't need MD5 leave it alone
197 if feat_no SOCKETS
; then
201 if feat_no TERMCAP
; then
202 OPT_TERMCAP_VIA_TERMINFO
=0
205 if feat_yes DEVEL
; then
213 h
=.
/mk-config.h h_name
=mk-config.h
216 newlst
=.
/mk-nconfig.lst
217 newmk
=.
/mk-nconfig.mk
218 newev
=.
/mk-nconfig.ev
224 ## -- >8 - << OPTIONS | OS/CC >> - 8< -- ##
226 # Note that potential duplicates in PATH, C_INCLUDE_PATH etc. will be cleaned
227 # via path_check() later on once possible
229 # TODO cc_maxopt is brute simple, we should compile test program and dig real
230 # compiler versions for known compilers, then be more specific
231 [ -n "${cc_maxopt}" ] || cc_maxopt
=100
235 # We don't "have any utility": only path adjustments and such in here!
236 [ -n "${OS}" ] || OS
=`uname -s`
239 if [ ${OS} = SunOS
]; then
240 msg
'SunOS / Solaris? Applying some "early setup" rules ...'
241 _os_early_setup_sunos
245 _os_early_setup_sunos
() {
246 # According to standards(5), this is what we need to do
247 if [ -d /usr
/xpg4
]; then :; else
248 msg
'ERROR: On SunOS / Solaris we need /usr/xpg4 environment! Sorry.'
251 PATH
="/usr/xpg4/bin:/usr/ccs/bin:/usr/bin:${PATH}"
252 [ -d /usr
/xpg6
] && PATH
="/usr/xpg6/bin:${PATH}"
257 # OSENV ends up in *build-osenv*
258 # OSFULLSPEC is used to recognize changes (i.e., machine type, updates etc.)
259 OS
=`echo ${OS} | ${tr} '[A-Z]' '[a-z]'`
260 [ -n "${OSENV}" ] || OSENV
=`uname -srm`
261 [ -n "${OSFULLSPEC}" ] || OSFULLSPEC
=`uname -a`
262 msg
'Operating system is %s' ${OS}
264 if [ ${OS} = darwin
]; then
265 msg
' . have special Darwin environmental addons...'
266 LD_LIBRARY_PATH
=${LD_LIBRARY_PATH}:${DYLD_LIBRARY_PATH}
267 elif [ ${OS} = sunos
]; then
268 msg
' . have special SunOS / Solaris "setup" rules ...'
270 elif [ ${OS} = unixware
]; then
271 if feat_yes AUTOCC
&& acmd_set CC cc
; then
272 msg
' . have special UnixWare environmental rules ...'
273 feat_yes DEBUG
&& _CFLAGS
='-v -Xa -g' || _CFLAGS
='-Xa -O'
275 CFLAGS
="${_CFLAGS} ${EXTRA_CFLAGS}"
276 LDFLAGS
="${_LDFLAGS} ${EXTRA_LDFLAGS}"
277 export CC CFLAGS LDFLAGS
278 OPT_AUTOCC
=0 had_want_autocc
=1 need_R_ldflags
=-R
280 elif [ -n "${VERBOSE}" ]; then
281 msg
' . no special treatment for this system necessary or known'
284 # Sledgehammer: better set _GNU_SOURCE
285 # And in general: oh, boy!
286 OS_DEFINES
="${OS_DEFINES}#define _GNU_SOURCE\n"
287 #OS_DEFINES="${OS_DEFINES}#define _POSIX_C_SOURCE 200809L\n"
288 #OS_DEFINES="${OS_DEFINES}#define _XOPEN_SOURCE 700\n"
289 #[ ${OS} = darwin ] && OS_DEFINES="${OS_DEFINES}#define _DARWIN_C_SOURCE\n"
291 # On pkgsrc(7) systems automatically add /usr/pkg/*
292 if [ -d /usr
/pkg
]; then
293 C_INCLUDE_PATH
=/usr
/pkg
/include
:${C_INCLUDE_PATH}
294 LD_LIBRARY_PATH
=/usr
/pkg
/lib
:${LD_LIBRARY_PATH}
299 C_INCLUDE_PATH
=/usr
/xpg
4/include
:${C_INCLUDE_PATH}
300 LD_LIBRARY_PATH
=/usr
/xpg
4/lib
:${LD_LIBRARY_PATH}
303 if [ -d /opt
/csw
]; then
304 C_INCLUDE_PATH
=/opt
/csw
/include
:${C_INCLUDE_PATH}
305 LD_LIBRARY_PATH
=/opt
/csw
/lib
:${LD_LIBRARY_PATH}
308 OS_DEFINES
="${OS_DEFINES}#define __EXTENSIONS__\n"
309 #OS_DEFINES="${OS_DEFINES}#define _POSIX_C_SOURCE 200112L\n"
311 [ -n "${cksum}" ] ||
cksum=/opt
/csw
/gnu
/cksum
312 if [ -x "${cksum}" ]; then :; else
313 msg
'ERROR: Not an executable program: %s' "${cksum}"
314 msg
'ERROR: We need a CRC-32 cksum(1), as specified in POSIX.'
315 msg
'ERROR: However, we do so only for tests.'
316 msg
'ERROR: If that is ok, set "cksum=/usr/bin/true", then rerun'
320 if feat_yes AUTOCC
; then
321 if acmd_set CC cc
; then
322 feat_yes DEBUG
&& _CFLAGS
="-v -Xa -g" || _CFLAGS
="-Xa -O"
324 CFLAGS
="${_CFLAGS} ${EXTRA_CFLAGS}"
325 LDFLAGS
="${_LDFLAGS} ${EXTRA_LDFLAGS}"
326 export CC CFLAGS LDFLAGS
327 OPT_AUTOCC
=0 had_want_autocc
=1 need_R_ldflags
=-R
329 # Assume gcc(1), which supports -R for compat
330 cc_maxopt
=2 force_no_stackprot
=1 need_R_ldflags
=-Wl,-R
335 # Check out compiler ($CC) and -flags ($CFLAGS)
337 # Even though it belongs into cc_flags we will try to compile and link
338 # something, so ensure we have a clean state regarding CFLAGS/LDFLAGS or
339 # EXTRA_CFLAGS/EXTRA_LDFLAGS
340 if feat_no AUTOCC
; then
342 # Ensure those don't do any harm
343 EXTRA_CFLAGS
= EXTRA_LDFLAGS
=
344 export EXTRA_CFLAGS EXTRA_LDFLAGS
348 export CFLAGS LDFLAGS
351 [ -n "${CC}" ] && { _cc_default
; return; }
353 msg_nonl
'Searching for a usable C compiler .. $CC='
354 if acmd_set CC clang || acmd_set CC gcc ||
355 acmd_set CC tcc || acmd_set CC pcc ||
356 acmd_set CC c89 || acmd_set CC c99
; then
359 msg
'boing booom tschak'
360 msg
'ERROR: I cannot find a compiler!'
361 msg
' Neither of clang(1), gcc(1), tcc(1), pcc(1), c89(1) and c99(1).'
362 msg
' Please set ${CC} environment variable, maybe ${CFLAGS}, rerun.'
370 if [ -z "${CC}" ]; then
371 msg
'To go on like you have chosen, please set $CC, rerun.'
375 if [ -z "${VERBOSE}" ] && [ -f ${lst} ] && feat_no DEBUG
; then
378 msg
'Using C compiler ${CC}=%s' "${CC}"
383 if feat_yes AUTOCC
; then
384 if [ -f ${lst} ] && feat_no DEBUG
&& [ -z "${VERBOSE}" ]; then
386 msg
'Detecting ${CFLAGS}/${LDFLAGS} for ${CC}=%s, just a second..' \
390 msg
'Testing usable ${CFLAGS}/${LDFLAGS} for ${CC}=%s' "${CC}"
393 i=`echo "${CC}" | ${awk} 'BEGIN{FS="/"}{print $NF}'`
394 if { echo "${i}" | ${grep} tcc; } >/dev/null 2>&1; then
395 msg ' . have special tcc(1) environmental rules ...'
398 # As of pcc CVS 2016-04-02, stack protection support is announced but
399 # will break if used on Linux
400 if { echo "${i}" | ${grep} pcc; } >/dev/null 2>&1; then
406 feat_no DEBUG && _CFLAGS="-DNDEBUG ${_CFLAGS}"
407 CFLAGS="${_CFLAGS} ${EXTRA_CFLAGS}"
408 LDFLAGS="${_LDFLAGS} ${EXTRA_LDFLAGS}"
410 if feat_no DEBUG; then
411 CFLAGS="-DNDEBUG ${CFLAGS}"
415 export CFLAGS LDFLAGS
419 __cflags=${_CFLAGS} __ldflags=${_LDFLAGS}
426 if feat_yes DEBUG; then
427 # May have problems to find libtcc cc_check -b
431 if ld_check -Wl,-rpath =./ no; then
432 need_R_ldflags=-Wl,-rpath=
433 ld_check -Wl,--enable-new-dtags
434 ld_runtime_flags # update!
437 _CFLAGS="${_CFLAGS} ${__cflags}" _LDFLAGS="${_LDFLAGS} ${__ldflags}"
438 unset __cflags __ldflags
441 _cc_flags_generic() {
442 __cflags=${_CFLAGS} __ldflags=${_LDFLAGS}
444 feat_yes DEVEL && cc_check -std=c89 || cc_check -std=c99
446 # E.g., valgrind does not work well with high optimization
447 if [ ${cc_maxopt} -gt 1 ] && feat_yes NOMEMDBG &&
448 feat_no ASAN_ADDRESS && feat_no ASAN_MEMORY; then
449 msg 'OP_NOMEMDBG, setting cc_maxopt=1 (-O1)'
452 # Check -g first since some others may rely upon -g / optim. level
453 if feat_yes DEBUG; then
456 elif [ ${cc_maxopt} -gt 2 ] && cc_check -O3; then
458 elif [ ${cc_maxopt} -gt 1 ] && cc_check -O2; then
460 elif [ ${cc_maxopt} -gt 0 ] && cc_check -O1; then
466 if feat_yes AMALGAMATION; then
470 #if feat_yes DEVEL && cc_check -Weverything; then
475 cc_check -Wbad-function-cast
476 cc_check -Wcast-align
479 cc_check -Wmissing-prototypes
482 cc_check -Wwrite-strings
483 cc_check -Wno-long-long
487 if feat_yes AMALGAMATION && feat_no DEVEL; then
488 cc_check -Wno-unused-function
490 feat_no DEVEL && cc_check -Wno-unused-result # XXX do right way (pragma too)
492 cc_check -fno-unwind-tables
493 cc_check -fno-asynchronous-unwind-tables
494 cc_check -fstrict-aliasing
495 if cc_check -fstrict-overflow && feat_yes DEVEL; then
496 cc_check -Wstrict-overflow=5
499 if feat_yes DEBUG || feat_yes FORCED_STACKPROT; then
500 if [ -z "${force_no_stackprot}" ]; then
501 if cc_check -fstack-protector-strong ||
502 cc_check -fstack-protector-all; then
503 cc_check -D_FORTIFY_SOURCE=2
506 msg 'Not checking for -fstack-protector compiler option,'
507 msg 'since that caused errors in a "similar" configuration.'
508 msg 'You may turn off OPT_AUTOCC and use your own settings, rerun'
512 # LD (+ dependend CC)
514 if feat_yes ASAN_ADDRESS; then
516 if cc_check -fsanitize=address &&
517 ld_check -fsanitize=address; then
520 feat_bail_required ASAN_ADDRESS
525 if feat_yes ASAN_MEMORY; then
527 if cc_check -fsanitize=memory &&
528 ld_check -fsanitize=memory &&
529 cc_check -fsanitize-memory-track-origins=2 &&
530 ld_check -fsanitize-memory-track-origins=2; then
533 feat_bail_required ASAN_MEMORY
538 ld_check -Wl,-z,relro
540 ld_check -Wl,-z,noexecstack
541 if ld_check -Wl,-rpath =./ no; then
542 need_R_ldflags=-Wl,-rpath=
543 # Choose DT_RUNPATH (after $LD_LIBRARY_PATH) over DT_RPATH (before)
544 ld_check -Wl,--enable-new-dtags
545 ld_runtime_flags # update!
546 elif ld_check -Wl,-R ./ no; then
547 need_R_ldflags=-Wl,-R
548 ld_check -Wl,--enable-new-dtags
549 ld_runtime_flags # update!
552 # Address randomization
554 if cc_check -fPIE || cc_check -fpie; then
555 ld_check -pie || _CFLAGS=${_ccfg}
559 _CFLAGS="${_CFLAGS} ${__cflags}" _LDFLAGS="${_LDFLAGS} ${__ldflags}"
560 unset __cflags __ldflags
563 ## -- >8 - <<OS/CC | SUPPORT FUNS>> - 8< -- ##
566 ## - Heirloom sh(1) (and same origin) have _sometimes_ problems with ': >'
567 ## redirection, so use "printf '' >" instead
569 ## Very first: we undergo several states regarding I/O redirection etc.,
570 ## but need to deal with option updates from within all. Since all the
571 ## option stuff should be above the scissor line, define utility functions
572 ## and redefine them as necessary.
573 ## And, since we have those functions, simply use them for whatever
575 t1=ten10one1ten10one1
576 if ( [ ${t1##*ten10} = one1 ] && [ ${t1#*ten10} = one1ten10one1 ] &&
577 [ ${t1%%one1*} = ten10 ] && [ ${t1%one1*} = ten10one1ten10 ]
578 ) > /dev/null 2>&1; then
585 ( set -o noglob ) >/dev/null 2>&1 && noglob_shell=1 || unset noglob_shell
591 # which(1) not standardized, command(1) -v may return non-executable: unroll!
592 acmd_test() { __acmd "${1}" 1 0 0; }
593 acmd_test_fail() { __acmd "${1}" 1 1 0; }
594 acmd_set() { __acmd "${2}" 0 0 0 "${1}"; }
595 acmd_set_fail() { __acmd "${2}" 0 1 0 "${1}"; }
596 acmd_testandset() { __acmd "${2}" 1 0 0 "${1}"; }
597 acmd_testandset_fail() { __acmd "${2}" 1 1 0 "${1}"; }
598 thecmd_set() { __acmd "${2}" 0 0 1 "${1}"; }
599 thecmd_set_fail() { __acmd "${2}" 0 1 1 "${1}"; }
600 thecmd_testandset() { __acmd "${2}" 1 0 1 "${1}"; }
601 thecmd_testandset_fail() { __acmd "${2}" 1 1 1 "${1}"; }
603 pname=${1} dotest=${2} dofail=${3} verbok=${4} varname=${5}
605 if [ "${dotest}" -ne 0 ]; then
606 eval dotest=\$${varname}
607 if [ -n "${dotest}" ]; then
608 [ -n "${VERBOSE}" ] && [ ${verbok} -ne 0 ] &&
609 msg ' . ${%s} ... %s' "${pname}" "${dotest}"
615 [ -n "${noglob_shell}" ] && set -o noglob
617 [ -n "${noglob_shell}" ] && set +o noglob
621 if [ -z "${path}" ] || [ "${path}" = . ]; then
622 if [ -d "${PWD}" ]; then
628 if [ -f "${path}/${pname}" ] && [ -x "${path}/${pname}" ]; then
629 [ -n "${VERBOSE}" ] && [ ${verbok} -ne 0 ] &&
630 msg ' . ${%s} ... %s' "${pname}" "${path}/${pname}"
631 [ -n "${varname}" ] && eval ${varname}="${path}/${pname}"
636 # We may have no builtin string functions, we yet have no programs we can
637 # use, try to access once from the root, assuming it is an absolute path if
638 # that finds the executable
639 if ( cd && [ -f "${pname}" ] && [ -x "${pname}" ] ); then
640 [ -n "${VERBOSE}" ] && [ ${verbok} -ne 0 ] &&
641 msg ' . ${%s} ... %s' "${pname}" "${pname}"
642 [ -n "${varname}" ] && eval ${varname}="${pname}"
646 [ ${dofail} -eq 0 ] && return 1
647 msg 'ERROR: no trace of utility '"${pname}"
654 printf >&2 -- "${fmt}\\n" "${@}"
660 printf >&2 -- "${fmt}" "${@}"
663 # Our feature check environment
665 [ "x${1}" = x0 ] || [ "x${1}" = xn ] ||
666 [ "x${1}" = xfalse ] || [ "x${1}" = xno ] || [ "x${1}" = xoff ]
670 [ "x${1}" = x1 ] || [ "x${1}" = xy ] ||
671 [ "x${1}" = xtrue ] || [ "x${1}" = xyes ] || [ "x${1}" = xon ] ||
672 [ "x${1}" = xrequire ]
676 [ "x${1}" = xrequire ]
681 i="`echo ${i} |
${tr} '[A-Z]' '[a-z]'`"
682 if feat_val_no "${i}"; then
684 elif feat_val_yes "${i}"; then
687 msg "ERROR: %s: 0/n/false/no/off or 1/y/true/yes/on/require, got: %s" \
698 _feat_check ${1} && return 1
704 i="`echo ${i} |
${tr} '[A-Z]' '[a-z]'`"
705 [ "x${i}" = xrequire ] || [ "x${i}" = xrequired ]
708 feat_bail_required() {
709 if feat_require ${1}; then
710 msg 'ERROR: feature OPT_%s is required but not available' "${1}"
714 option_update # XXX this is rather useless here (dependency chain..)
718 # Parse one of our XOPTIONS* in $2 and assign the sh(1) compatible list of
719 # options, without documentation, to $1
721 i="`${awk} -v input
=\"${2}\" '
724 voff = match(input, /[[:alnum:]_]+(='${j}'[^'${j}']+)?/)
727 v = substr(input, voff, RLENGTH)
728 input = substr(input, voff + RLENGTH)
731 d = substr(v, doff + 2, length(v) - doff - 1)
732 v = substr(v, 1, doff - 1)
742 # Return the "documentation string" for option $1, itself if none such
744 ${awk} -v want="${1}" \
745 -v input="${XOPTIONS_DETECT}${XOPTIONS}${XOPTIONS_XTRA}" '
748 voff = match(input, /[[:alnum:]_]+(='${j}'[^'${j}']+)?/)
751 v = substr(input, voff, RLENGTH)
752 input = substr(input, voff + RLENGTH)
755 d = substr(v, doff + 2, length(v) - doff - 1)
756 v = substr(v, 1, doff - 1)
770 # Join the values from make.rc into what currently is defined, not
771 # overwriting yet existing settings
773 # We want read(1) to perform reverse solidus escaping in order to be able to
774 # use multiline values in make.rc; the resulting sh(1)/sed(1) code was very
775 # slow in VMs (see [fa2e248]), Aharon Robbins suggested the following
776 < ${rc} ${awk} 'BEGIN{line = ""}{
777 gsub(/^[[:space:]]+/, "", $0)
778 gsub(/[[:space:]]+$/, "", $0)
779 if(gsub(/\\$/, "", $0)){
784 if(index(line, "#") == 1){
786 }else if(length(line)){
792 if [ -n "${good_shell}" ]; then
795 i=`${awk} -v LINE
="${line}" 'BEGIN{
796 gsub(/=.*$/, "", LINE)
800 if [ "${i}" = "${line}" ]; then
801 msg 'ERROR: invalid syntax in: %s' "${line}"
805 eval j="\$${i}" jx="\${${i}+x}"
806 if [ -n "${j}" ] || [ "${jx}" = x ]; then
809 j=`${awk} -v LINE
="${line}" 'BEGIN{
810 gsub(/^[^=]*=/, "", LINE)
811 gsub(/^\"*/, "", LINE)
812 gsub(/\"*$/, "", LINE)
816 [ "${i}" = "DESTDIR" ] && continue
819 # Reread the mixed version right now
824 # Expand the option values, which may contain shell snippets
825 ${rm} -f ${newlst} ${newmk} ${newh}
826 exec 5<&0 6>&1 <${tmp} >${newlst}
829 if [ -n "${good_shell}" ]; then
831 [ "${i}" != "${i#OPT_}" ] && z=1
833 i=`${awk} -v LINE
="${line}" 'BEGIN{
834 gsub(/=.*$/, "", LINE);\
837 if echo "${i}" | ${grep} '^OPT_' >/dev/null 2>&1; then
843 if [ -n "${z}" ]; then
844 j="`echo ${j} |
${tr} '[A-Z]' '[a-z]'`"
845 if [ -z "${j}" ] || feat_val_no "${j}"; then
847 printf " /* #undef ${i} */\n" >> ${newh}
848 elif feat_val_yes "${j}"; then
849 if feat_val_require "${j}"; then
854 printf " /* #define ${i} */\n" >> ${newh}
856 msg 'ERROR: cannot parse <%s>' "${line}"
860 printf "#define ${i} \"${j}\"\n" >> ${newh}
862 printf "${i} = ${j}\n" >> ${newmk}
866 exec 0<&5 1>&6 5<&- 6<&-
870 # "path_check VARNAME" or "path_check VARNAME FLAG VARNAME"
871 varname=${1} addflag=${2} flagvarname=${3}
874 [ -n "${noglob_shell}" ] && set -o noglob
876 [ -n "${noglob_shell}" ] && set +o noglob
881 [ -z "${i}" ] && continue
882 [ -d "${i}" ] || continue
883 if [ -n "${j}" ]; then
884 if { z=${y}; echo "${z}"; } | ${grep} ":${i}:" >/dev/null 2>&1; then
889 # But do not link any fakeroot path into our binaries!
890 if [ -n "${addflag}" ]; then
891 case "${i}" in *fakeroot*) continue;; esac
892 k="${k} ${addflag}${i}"
898 # But do not link any fakeroot path into our binaries!
899 if [ -n "${addflag}" ]; then
900 case "${i}" in *fakeroot*) continue;; esac
901 k="${k} ${addflag}${i}"
905 eval "${varname}=\"${j}\""
906 [ -n "${addflag}" ] && eval "${flagvarname}=\"${k}\""
911 if [ -n "${need_R_ldflags}" ]; then
914 set -- ${LD_LIBRARY_PATH}
918 # But do not link any fakeroot path into our binaries!
919 case "${i}" in *fakeroot*) continue;; esac
920 LDFLAGS="${LDFLAGS} ${need_R_ldflags}${i}"
921 _LDFLAGS="${_LDFLAGS} ${need_R_ldflags}${i}"
925 # Disable it for a possible second run.
930 [ -n "${cc_check_silent}" ] || msg_nonl ' . CC %s .. ' "${1}"
932 ${_CFLAGS} ${1} ${EXTRA_CFLAGS} ${_LDFLAGS} ${EXTRA_LDFLAGS} \
933 -o ${tmp2} ${tmp}.c ${LIBS} >/dev/null 2>&1; then
934 _CFLAGS="${_CFLAGS} ${1}"
935 [ -n "${cc_check_silent}" ] || msg 'yes'
938 [ -n "${cc_check_silent}" ] || msg 'no'
943 # $1=option [$2=option argument] [$3=if set, shall NOT be added to _LDFLAGS]
944 [ -n "${cc_check_silent}" ] || msg_nonl ' . LD %s .. ' "${1}"
945 if "${CC}" ${INCS} ${_CFLAGS} ${_LDFLAGS} ${1}${2} ${EXTRA_LDFLAGS} \
946 -o ${tmp2} ${tmp}.c ${LIBS} >/dev/null 2>&1; then
947 [ -n "${3}" ] || _LDFLAGS="${_LDFLAGS} ${1}"
948 [ -n "${cc_check_silent}" ] || msg 'yes'
951 [ -n "${cc_check_silent}" ] || msg 'no'
957 variable=$1 topic=$2 define=$3
960 msg_nonl ' . %s ... ' "${topic}"
961 echo "/* checked ${topic} */" >> ${h}
962 ${rm} -f ${tmp} ${tmp}.o
963 if [ "${dump_test_program}" = 1 ]; then
964 echo '*** test program is'
965 { echo '#include <'"${h_name}"'>'; cat; } | ${tee} ${tmp}.c
967 { echo '#include <'"${h_name}"'>'; cat; } > ${tmp}.c
969 #echo '*** the preprocessor generates'
970 #${make} -f ${makefile} ${tmp}.x
972 echo '*** tests results'
976 yesno=$1 variable=$2 topic=$3 define=$4 libs=$5 incs=$6
979 msg_nonl ' . %s ... ' "${topic}"
981 echo '*** enforced unchecked results are'
982 if feat_val_yes ${yesno}; then
983 if [ -n "${incs}" ] || [ -n "${libs}" ]; then
984 echo "*** adding INCS<${incs}> LIBS<${libs}>"
985 LIBS="${LIBS} ${libs}"
986 echo "${libs}" >> ${lib}
987 INCS="${INCS} ${incs}"
988 echo "${incs}" >> ${inc}
991 echo "${define}" >> ${h}
992 eval have_${variable}=yes
995 echo "/* ${define} */" >> ${h}
997 eval unset have_${variable}
1003 variable=$1 topic=$2 define=$3
1005 _check_preface "${variable}" "${topic}" "${define}"
1007 if ${make} -f ${makefile} XINCS="${INCS}" \
1008 CFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}" \
1010 [ -f ./${tmp}.o ]; then
1012 echo "${define}" >> ${h}
1013 eval have_${variable}=yes
1016 echo "/* ${define} */" >> ${h}
1018 eval unset have_${variable}
1024 run=$1 variable=$2 topic=$3 define=$4 libs=$5 incs=$6
1026 _check_preface "${variable}" "${topic}" "${define}"
1028 if feat_yes CROSS_BUILD; then
1029 if [ ${run} = 1 ]; then
1034 if ${make} -f ${makefile} XINCS="${INCS} ${incs}" \
1035 CFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}" \
1036 XLIBS="${LIBS} ${libs}" \
1039 { [ ${run} -eq 0 ] || ./${tmp}; }; then
1040 echo "*** adding INCS<${incs}> LIBS<${libs}>; executed: ${run}"
1042 echo "${define}" >> ${h}
1043 LIBS="${LIBS} ${libs}"
1044 echo "${libs}" >> ${lib}
1045 INCS="${INCS} ${incs}"
1046 echo "${incs}" >> ${inc}
1047 eval have_${variable}=yes
1051 echo "/* ${define} */" >> ${h}
1052 eval unset have_${variable}
1058 _link_mayrun 0 "${1}" "${2}" "${3}" "${4}" "${5}"
1062 _link_mayrun 1 "${1}" "${2}" "${3}" "${4}" "${5}"
1066 _link_mayrun 2 "${1}" "${2}" "${3}" "${4}" "${5}"
1070 if feat_yes ${1}; then
1071 echo '#define HAVE_'${1}'' >> ${h}
1074 echo '/* OPT_'${1}'=0 */' >> ${h}
1080 < "${1}" > "${2}" ${awk} \
1081 'BEGIN {ORS = " "} /^[^#]/ {print} {next} END {ORS = ""; print "\n"}'
1084 ## -- >8 - <<SUPPORT FUNS | RUNNING>> - 8< -- ##
1086 # First of all, create new configuration and check whether it changed
1088 # Very easy checks for the operating system in order to be able to adjust paths
1089 # or similar very basic things which we need to be able to go at all
1092 # Check those tools right now that we need before including $rc
1093 msg 'Checking for basic utility set'
1094 thecmd_testandset_fail awk awk
1095 thecmd_testandset_fail rm rm
1096 thecmd_testandset_fail tr tr
1098 # Initialize the option set
1099 msg_nonl 'Setting up configuration options ... '
1103 # Include $rc, but only take from it what wasn't overwritten by the user from
1104 # within the command line or from a chosen fixed CONFIG=
1105 # Note we leave alone the values
1106 trap "exit 1" HUP INT TERM
1107 trap "${rm} -f ${tmp}" EXIT
1109 msg_nonl 'Joining in %s ... ' ${rc}
1113 # We need to know about that now, in order to provide utility overwrites etc.
1116 msg 'Checking for remaining set of utilities'
1117 thecmd_testandset_fail grep grep
1119 # Before we step ahead with the other utilities perform a path cleanup first.
1123 thecmd_testandset_fail basename basename
1124 thecmd_testandset_fail cat cat
1125 thecmd_testandset_fail chmod chmod
1126 thecmd_testandset_fail cp cp
1127 thecmd_testandset_fail cmp cmp
1129 thecmd_testandset_fail mkdir mkdir
1130 thecmd_testandset_fail mv mv
1132 thecmd_testandset_fail sed sed
1133 thecmd_testandset_fail sort sort
1134 thecmd_testandset_fail tee tee
1136 thecmd_testandset chown chown ||
1137 PATH="/sbin:${PATH}" thecmd_set chown chown ||
1138 PATH="/usr/sbin:${PATH}" thecmd_set_fail chown chown
1140 thecmd_testandset_fail make make
1143 thecmd_testandset strip strip && HAVE_STRIP=1 || HAVE_STRIP=0
1145 # For ./cc-test.sh only
1146 thecmd_testandset_fail cksum cksum
1148 # Update OPT_ options now, in order to get possible inter-dependencies right
1151 # (No functions since some shells loose non-exported variables in traps)
1152 trap "trap \"\" HUP INT TERM; exit 1" HUP INT TERM
1153 trap "trap \"\" HUP INT TERM EXIT;\
1154 ${rm} -rf ${newlst} ${tmp0}.* ${tmp0}* ${newmk} ${newev} ${newh}" EXIT
1156 # Our configuration options may at this point still contain shell snippets,
1157 # we need to evaluate them in order to get them expanded, and we need those
1158 # evaluated values not only in our new configuration file, but also at hand..
1159 msg_nonl 'Evaluating all configuration items ... '
1163 # Add the known utility and some other variables
1164 printf "#define VAL_UAGENT \"${VAL_SID}${VAL_MAILX}\"\n" >> ${newh}
1165 printf "VAL_UAGENT = ${VAL_SID}${VAL_MAILX}\n" >> ${newmk}
1167 printf "#define VAL_PRIVSEP \"${VAL_SID}${VAL_MAILX}-privsep\"\n" >> ${newh}
1168 printf "VAL_PRIVSEP = \$(VAL_UAGENT)-privsep\n" >> ${newmk}
1169 if feat_yes DOTLOCK; then
1170 printf "OPTIONAL_PRIVSEP = \$(VAL_PRIVSEP)\n" >> ${newmk}
1172 printf "OPTIONAL_PRIVSEP =\n" >> ${newmk}
1177 awk basename cat chmod chown cp cmp grep mkdir mv rm sed sort tee tr \
1178 MAKE MAKEFLAGS make SHELL strip \
1181 printf "${i} = ${j}\n" >> ${newmk}
1182 printf "${i}=${j}\n" >> ${newlst}
1183 printf "${i}=\"${j}\";export ${i}; " >> ${newev}
1185 printf "\n" >> ${newev}
1187 # Build a basic set of INCS and LIBS according to user environment.
1188 C_INCLUDE_PATH="${CWDDIR}:${SRCDIR}:${C_INCLUDE_PATH}"
1189 path_check C_INCLUDE_PATH -I _INCS
1190 INCS="${INCS} ${_INCS}"
1191 path_check LD_LIBRARY_PATH -L _LIBS
1192 LIBS="${LIBS} ${_LIBS}"
1194 export C_INCLUDE_PATH LD_LIBRARY_PATH
1196 # Some environments need runtime path flags to be able to go at all
1199 ## Detect CC, whether we can use it, and possibly which CFLAGS we can use
1203 ${cat} > ${tmp}.c << \!
1206 static void doit(char const *s);
1208 main(int argc, char **argv){
1211 doit("Hello world");
1215 doit(char const *s){
1217 memcpy(buf, s, strlen(s) +1);
1222 if "${CC}" ${INCS} ${CFLAGS} ${EXTRA_CFLAGS} ${LDFLAGS} ${EXTRA_LDFLAGS} \
1223 -o ${tmp2} ${tmp}.c ${LIBS}; then
1226 msg 'ERROR: i cannot compile a "Hello world" via'
1228 "${CC} ${INCS} ${CFLAGS} ${EXTRA_CFLAGS} ${LDFLAGS} ${EXTRA_LDFLAGS} ${LIBS}"
1229 msg 'ERROR: Please read INSTALL, rerun'
1233 # This may also update ld_runtime_flags() (again)
1240 printf -- "${i}=${j}\n" >> ${newlst}
1246 PATH C_INCLUDE_PATH LD_LIBRARY_PATH \
1250 printf -- "${i} = ${j}\n" >> ${newmk}
1251 printf -- "${i}=${j}\n" >> ${newlst}
1254 # Now finally check whether we already have a configuration and if so, whether
1255 # all those parameters are still the same.. or something has actually changed
1256 if [ -f ${lst} ] && ${cmp} ${newlst} ${lst} >/dev/null 2>&1; then
1257 echo 'Configuration is up-to-date'
1259 elif [ -f ${lst} ]; then
1260 echo 'Configuration has been updated..'
1261 ( eval "${MAKE} -f ./mk-config.mk clean" )
1264 echo 'Shiny configuration..'
1267 # Time to redefine helper 1
1269 ${rm} -f ${lst} ${h} ${mk}
1273 ${mv} -f ${newlst} ${lst}
1274 ${mv} -f ${newev} ${ev}
1275 ${mv} -f ${newh} ${h}
1276 ${mv} -f ${newmk} ${mk}
1278 if [ -z "${VERBOSE}" ]; then
1279 printf -- "ECHO_CC = @echo ' 'CC \$(@);\n" >> ${mk}
1280 printf -- "ECHO_LINK = @echo ' 'LINK \$(@);\n" >> ${mk}
1281 printf -- "ECHO_GEN = @echo ' 'GEN \$(@);\n" >> ${mk}
1282 printf -- "ECHO_TEST = @\n" >> ${mk}
1283 printf -- "ECHO_CMD = @echo ' CMD';\n" >> ${mk}
1284 printf -- "ECHO_BLOCK_BEGIN = @( \n" >> ${mk}
1285 printf -- "ECHO_BLOCK_END = ) >/dev/null\n" >> ${mk}
1288 ## Compile and link checking
1294 makefile=./${tmp0}.mk
1296 # (No function since some shells loose non-exported variables in traps)
1297 trap "trap \"\" HUP INT TERM;\
1298 ${rm} -f ${lst} ${h} ${mk} ${lib} ${inc}; exit 1" HUP INT TERM
1299 trap "trap \"\" HUP INT TERM EXIT;\
1300 ${rm} -rf ${tmp0}.* ${tmp0}*" EXIT
1302 # Time to redefine helper 2
1306 printf "*** ${fmt}\\n" "${@}"
1307 printf -- "${fmt}\\n" "${@}" >&5
1312 printf "*** ${fmt}\\n" "${@}"
1313 printf -- "${fmt}" "${@}" >&5
1317 exec 5>&2 > ${log} 2>&1
1319 echo "${LIBS}" > ${lib}
1320 echo "${INCS}" > ${inc}
1321 ${cat} > ${makefile} << \!
1322 .SUFFIXES: .o .c .x .y
1324 $(CC) -I./ $(XINCS) $(CFLAGS) -c $(<)
1326 $(CC) -I./ $(XINCS) -E $(<) > $(@)
1328 $(CC) -I./ $(XINCS) $(CFLAGS) $(LDFLAGS) -o $(@) $(<) $(XLIBS)
1333 # May be multiline..
1335 [ -n "${OS_DEFINES}" ] && printf -- "${OS_DEFINES}" >> ${h}
1336 echo '#define VAL_BUILD_OS "'"${OS}"'"' >> ${h}
1337 echo '#define VAL_BUILD_OSENV "'"${OSENV}"'"' >> ${h}
1339 # Generate n_err_number OS mappings
1342 feat_yes DEVEL && NV= || NV=noverbose
1343 SRCDIR="${SRCDIR}" TARGET="${h}" awk="${awk}" \
1344 ${SHELL} "${SRCDIR}"make-errors.sh ${NV} config
1345 ) | xrun_check oserrno 'OS error mapping table generated' || config_exit 1
1348 feat_def ALWAYS_UNICODE_LOCALE
1349 feat_def AMALGAMATION
1350 feat_def CROSS_BUILD
1354 feat_def ASAN_ADDRESS
1355 feat_def ASAN_MEMORY
1361 if xrun_check inline 'inline functions' \
1362 '#define HAVE_INLINE
1363 #define n_INLINE static inline' << \!
1364 static inline int ilf(int i){return ++i;}
1365 int main(void){return ilf(-1);}
1369 elif xrun_check inline 'inline functions (via __inline)' \
1370 '#define HAVE_INLINE
1371 #define n_INLINE static __inline' << \!
1372 static __inline int ilf(int i){return ++i;}
1373 int main(void){return ilf(-1);}
1379 ## Test for "basic" system-calls / functionality that is used by all parts
1380 ## of our program. Once this is done fork away BASE_LIBS and other BASE_*
1381 ## macros to be used by only the subprograms (potentially).
1383 if run_check clock_gettime 'clock_gettime(2)' \
1384 '#define HAVE_CLOCK_GETTIME' << \!
1390 if(!clock_gettime(CLOCK_REALTIME, &ts) || errno != ENOSYS)
1397 elif run_check clock_gettime 'clock_gettime(2) (via -lrt)' \
1398 '#define HAVE_CLOCK_GETTIME' '-lrt' << \!
1404 if(!clock_gettime(CLOCK_REALTIME, &ts) || errno != ENOSYS)
1411 elif run_check gettimeofday 'gettimeofday(2)' \
1412 '#define HAVE_GETTIMEOFDAY' << \!
1413 #include <stdio.h> /* For C89 NULL */
1414 #include <sys/time.h>
1419 if(!gettimeofday(&tv, NULL) || errno != ENOSYS)
1427 have_no_subsecond_time=1
1430 if run_check nanosleep 'nanosleep(2)' \
1431 '#define HAVE_NANOSLEEP' << \!
1438 ts.tv_nsec = 100000;
1439 if(!nanosleep(&ts, NULL) || errno != ENOSYS)
1446 elif run_check nanosleep 'nanosleep(2) (via -lrt)' \
1447 '#define HAVE_NANOSLEEP' '-lrt' << \!
1454 ts.tv_nsec = 100000;
1455 if(!nanosleep(&ts, NULL) || errno != ENOSYS)
1462 # link_check is enough for this, that function is so old, trust the proto
1463 elif link_check sleep 'sleep(3)' \
1464 '#define HAVE_SLEEP' << \!
1468 if(!sleep(1) || errno != ENOSYS)
1476 msg 'ERROR: we require one of nanosleep(2) and sleep(3).'
1480 if run_check userdb 'gete?[gu]id(2), getpwuid(3), getpwnam(3)' << \!
1489 if((gid = getgid()) != 0)
1491 if((uid = getuid()) != 0)
1493 if((pw = getpwuid(uid)) == NULL && errno == ENOSYS)
1495 if((pw = getpwnam("root")) == NULL && errno == ENOSYS)
1503 msg 'ERROR: we require user and group info / database searches.'
1504 msg 'That much Unix we indulge ourselfs.'
1508 if link_check ftruncate 'ftruncate(2)' \
1509 '#define HAVE_FTRUNCATE' << \!
1511 #include <sys/types.h>
1513 return (ftruncate(0, 0) != 0);
1519 msg 'ERROR: we require the ftruncate(2) system call.'
1523 if run_check sa_restart 'SA_RESTART (for sigaction(2))' << \!
1527 struct sigaction nact, oact;
1529 nact.sa_handler = SIG_DFL;
1530 sigemptyset(&nact.sa_mask);
1531 nact.sa_flags = SA_RESTART;
1532 return !(!sigaction(SIGCHLD, &nact, &oact) || errno != ENOSYS);
1538 msg 'ERROR: we (yet) require the SA_RESTART flag for sigaction(2).'
1542 if link_check snprintf 'snprintf(3)' << \!
1547 snprintf(b, sizeof b, "%s", "string");
1554 msg 'ERROR: we require the snprintf(3) function.'
1558 if link_check environ 'environ(3)' << \!
1559 #include <stdio.h> /* For C89 NULL */
1561 extern char **environ;
1563 return environ[0] == NULL;
1569 msg 'ERROR: we require the environ(3) array for subprocess control.'
1573 if link_check setenv '(un)?setenv(3)' '#define HAVE_SETENV' << \!
1576 setenv("s-mailx", "i want to see it cute!", 1);
1577 unsetenv("s-mailx");
1583 elif link_check setenv 'putenv(3)' '#define HAVE_PUTENV' << \!
1586 putenv("s-mailx=i want to see it cute!");
1593 msg 'ERROR: we require either the setenv(3) or putenv(3) functions.'
1597 if link_check termios 'termios.h and tc*(3) family' << \!
1598 #include <termios.h>
1600 struct termios tios;
1602 tcgetattr(0, &tios);
1603 tcsetattr(0, TCSANOW | TCSADRAIN | TCSAFLUSH, &tios);
1610 msg 'ERROR: we require termios.h and the tc*() family of functions.'
1611 msg 'That much Unix we indulge ourselfs.'
1617 if link_check vsnprintf 'vsnprintf(3)' << \!
1620 static void dome(char *buf, size_t blen, ...){
1624 vsnprintf(buf, blen, "%s", ap);
1630 dome(b, sizeof b, "string");
1637 feat_bail_required ERRORS
1640 if [ "${have_vsnprintf}" = yes ]; then
1642 link_check va_copy "va_copy(3) (as ${2})" \
1643 "#define HAVE_N_VA_COPY
1644 #define n_va_copy ${2}" <<_EOT
1648 # if defined __va_copy && !defined va_copy
1649 # define va_copy __va_copy
1652 static void dome2(char *buf, size_t blen, va_list src){
1656 vsnprintf(buf, blen, "%s", ap);
1659 static void dome(char *buf, size_t blen, ...){
1663 dome2(buf, blen, ap);
1669 dome(b, sizeof b, "string");
1674 __va_copy 0 va_copy || __va_copy 1 __va_copy
1677 run_check pathconf 'f?pathconf(2)' '#define HAVE_PATHCONF' << \!
1684 rv |= !(pathconf(".", _PC_NAME_MAX) >= 0 || errno == 0 || errno != ENOSYS);
1686 rv |= !(pathconf(".", _PC_PATH_MAX) >= 0 || errno == 0 || errno != ENOSYS);
1688 /* Only link check */
1689 fpathconf(0, _PC_NAME_MAX);
1695 run_check pipe2 'pipe2(2)' '#define HAVE_PIPE2' << \!
1702 if(!pipe2(fds, O_CLOEXEC) || errno != ENOSYS)
1708 # We use this only then for now (need NOW+1)
1709 run_check utimensat 'utimensat(2)' '#define HAVE_UTIMENSAT' << \!
1710 #include <fcntl.h> /* For AT_* */
1711 #include <sys/stat.h>
1714 struct timespec ts[2];
1716 ts[0].tv_nsec = UTIME_NOW;
1717 ts[1].tv_nsec = UTIME_OMIT;
1718 if(!utimensat(AT_FDCWD, "", ts, 0) || errno != ENOSYS)
1726 # XXX Add POSIX check once standardized
1727 if link_check posix_random 'arc4random(3)' '#define HAVE_POSIX_RANDOM 0' << \!
1736 elif link_check getrandom 'getrandom(2) (in sys/random.h)' \
1737 '#define HAVE_GETRANDOM(B,S) getrandom(B, S, 0)
1738 #define HAVE_GETRANDOM_HEADER <sys/random.h>' <<\!
1739 #include <sys/random.h>
1742 getrandom(buf, sizeof buf, 0);
1748 elif link_check getrandom 'getrandom(2) (via syscall(2))' \
1749 '#define HAVE_GETRANDOM(B,S) syscall(SYS_getrandom, B, S, 0)
1750 #define HAVE_GETRANDOM_HEADER <sys/syscall.h>' <<\!
1751 #include <sys/syscall.h>
1754 syscall(SYS_getrandom, buf, sizeof buf, 0);
1760 elif [ -n "${have_no_subsecond_time}" ]; then
1761 msg 'ERROR: %s %s' 'without a native random' \
1762 'one of clock_gettime(2) and gettimeofday(2) is required.'
1767 link_check putc_unlocked 'putc_unlocked(3)' '#define HAVE_PUTC_UNLOCKED' <<\!
1770 putc_unlocked('@', stdout);
1775 link_check fchdir 'fchdir(3)' '#define HAVE_FCHDIR' << \!
1783 if run_check realpath 'realpath(3)' '#define HAVE_REALPATH' << \!
1786 char x_buf[4096], *x = realpath(".", x_buf);
1788 return (x != NULL) ? 0 : 1;
1792 if run_check realpath_malloc 'realpath(3) takes NULL' \
1793 '#define HAVE_REALPATH_NULL' << \!
1796 char *x = realpath(".", NULL);
1800 return (x != NULL) ? 0 : 1;
1808 ## optional and selectable
1810 if feat_yes DOTLOCK; then
1811 if run_check readlink 'readlink(2)' << \!
1817 if(!readlink("here", buf, sizeof buf) || errno != ENOSYS)
1825 feat_bail_required DOTLOCK
1829 if feat_yes DOTLOCK; then
1830 if run_check fchown 'fchown(2)' << \!
1834 if(!fchown(0, 0, 0) || errno != ENOSYS)
1842 feat_bail_required DOTLOCK
1846 ## Now it is the time to fork away the BASE_ series
1849 squeeze_em ${inc} ${tmp}
1851 squeeze_em ${lib} ${tmp}
1854 echo "BASE_LIBS = `${cat} ${lib}`" >> ${mk}
1855 echo "BASE_INCS = `${cat} ${inc}`" >> ${mk}
1857 ## The remains are expected to be used only by the main MUA binary!
1860 link_check setlocale 'setlocale(3)' '#define HAVE_SETLOCALE' << \!
1863 setlocale(LC_ALL, "");
1867 [ -n "${have_setlocale}" ] && OPT_LOCALES=1
1869 OPT_MULTIBYTE_CHARSETS=0
1871 OPT_TERMINAL_CHARSET=0
1872 if [ -n "${have_setlocale}" ]; then
1873 link_check c90amend1 'ISO/IEC 9899:1990/Amendment 1:1995' \
1874 '#define HAVE_C90AMEND1' << \!
1880 char mbb[MB_LEN_MAX + 1];
1885 mbtowc(&wc, "x
", 1);
1886 mbrtowc(&wc, "x
", 1, NULL);
1888 return (mblen("\
0", 1) == 0);
1891 [ -n "${have_c90amend1}" ] && OPT_MULTIBYTE_CHARSETS=1
1893 if [ -n "${have_c90amend1}" ]; then
1894 link_check wcwidth 'wcwidth(3)' '#define HAVE_WCWIDTH' << \!
1901 [ -n "${have_wcwidth}" ] && OPT_WIDE_GLYPHS=1
1904 link_check nl_langinfo 'nl_langinfo(3)' '#define HAVE_NL_LANGINFO' << \!
1905 #include <langinfo.h>
1909 return (nl_langinfo(CODESET) == NULL);
1912 [ -n "${have_nl_langinfo}" ] && OPT_TERMINAL_CHARSET=1
1915 link_check fnmatch 'fnmatch(3)' '#define HAVE_FNMATCH' << \!
1916 #include <fnmatch.h>
1918 return (fnmatch("*", ".
", FNM_PATHNAME | FNM_PERIOD) == FNM_NOMATCH);
1922 link_check dirent_d_type 'struct dirent.d_type' '#define HAVE_DIRENT_TYPE' << \!
1926 return !(de.d_type == DT_UNKNOWN ||
1927 de.d_type == DT_DIR || de.d_type == DT_LNK);
1931 ## optional and selectable
1933 if feat_yes ICONV; then
1934 ${cat} > ${tmp2}.c << \!
1935 #include <stdio.h> /* For C89 NULL */
1940 id = iconv_open("foo
", "bar
");
1941 iconv(id, NULL, NULL, NULL, NULL);
1946 < ${tmp2}.c link_check iconv 'iconv(3) functionality' \
1947 '#define HAVE_ICONV' ||
1948 < ${tmp2}.c link_check iconv 'iconv(3) functionality (via -liconv)' \
1949 '#define HAVE_ICONV' '-liconv' ||
1950 feat_bail_required ICONV
1952 echo '/* OPT_ICONV=0 */' >> ${h}
1955 if feat_yes SOCKETS || feat_yes SPAM_SPAMD; then
1956 ${cat} > ${tmp2}.c << \!
1957 #include <sys/types.h>
1958 #include <sys/socket.h>
1962 struct sockaddr_un soun;
1964 if(socket(AF_UNIX, SOCK_STREAM, 0) == -1 && errno == ENOSYS)
1966 if(connect(0, (struct sockaddr*)&soun, 0) == -1 && errno == ENOSYS)
1968 if(shutdown(0, SHUT_RD | SHUT_WR | SHUT_RDWR) == -1 && errno == ENOSYS)
1974 < ${tmp2}.c run_check af_unix 'AF_UNIX sockets' \
1975 '#define HAVE_UNIX_SOCKETS' ||
1976 < ${tmp2}.c run_check af_unix 'AF_UNIX sockets (via -lnsl)' \
1977 '#define HAVE_UNIX_SOCKETS' '-lnsl' ||
1978 < ${tmp2}.c run_check af_unix 'AF_UNIX sockets (via -lsocket -lnsl)' \
1979 '#define HAVE_UNIX_SOCKETS' '-lsocket -lnsl'
1982 if feat_yes SOCKETS; then
1983 ${cat} > ${tmp2}.c << \!
1984 #include <sys/types.h>
1985 #include <sys/socket.h>
1986 #include <netinet/in.h>
1991 if(socket(AF_INET, SOCK_STREAM, 0) == -1 && errno == ENOSYS)
1993 if(connect(0, &s, 0) == -1 && errno == ENOSYS)
1999 < ${tmp2}.c run_check sockets 'sockets' \
2000 '#define HAVE_SOCKETS' ||
2001 < ${tmp2}.c run_check sockets 'sockets (via -lnsl)' \
2002 '#define HAVE_SOCKETS' '-lnsl' ||
2003 < ${tmp2}.c run_check sockets 'sockets (via -lsocket -lnsl)' \
2004 '#define HAVE_SOCKETS' '-lsocket -lnsl' ||
2005 feat_bail_required SOCKETS
2007 echo '/* OPT_SOCKETS=0 */' >> ${h}
2008 fi # feat_yes SOCKETS
2010 if feat_yes SOCKETS; then
2011 link_check getaddrinfo 'getaddrinfo(3)' \
2012 '#define HAVE_GETADDRINFO' << \!
2013 #include <sys/types.h>
2014 #include <sys/socket.h>
2018 struct addrinfo a, *ap;
2021 switch((lrv = getaddrinfo("foo
", "0", &a, &ap))){
2025 fprintf(stderr, "%s
\n", gai_strerror(lrv));
2034 if feat_yes SOCKETS && [ -z "${have_getaddrinfo}" ]; then
2035 compile_check arpa_inet_h '<arpa/inet.h>' \
2036 '#define HAVE_ARPA_INET_H' << \!
2037 #include <sys/types.h>
2038 #include <sys/socket.h>
2040 #include <netinet/in.h>
2041 #include <arpa/inet.h>
2044 ${cat} > ${tmp2}.c << \!
2045 #include <sys/types.h>
2046 #include <sys/socket.h>
2050 #include <netinet/in.h>
2051 #ifdef HAVE_ARPA_INET_H
2052 #include <arpa/inet.h>
2055 struct sockaddr_in servaddr;
2056 unsigned short portno;
2059 struct in_addr **pptr;
2062 if((ep = getservbyname("POPPY-PORT
", "tcp
")) != NULL)
2063 portno = (unsigned short)ep->s_port;
2065 if((hp = gethostbyname("POPPY-HOST
")) != NULL){
2066 pptr = (struct in_addr**)hp->h_addr_list;
2067 if(hp->h_addrtype != AF_INET)
2068 fprintf(stderr, "au
\n");
2071 case HOST_NOT_FOUND:
2077 fprintf(stderr, "au
\n");
2082 memset(&servaddr, 0, sizeof servaddr);
2083 servaddr.sin_family = AF_INET;
2084 servaddr.sin_port = htons(portno);
2085 memcpy(&servaddr.sin_addr, *pptr, sizeof(struct in_addr));
2086 fprintf(stderr, "Would connect to
%s
:%d ...
\n",
2087 inet_ntoa(**pptr), (int)portno);
2092 < ${tmp2}.c link_check gethostbyname 'get(serv|host)byname(3)' ||
2093 < ${tmp2}.c link_check gethostbyname \
2094 'get(serv|host)byname(3) (via -nsl)' '' '-lnsl' ||
2095 < ${tmp2}.c link_check gethostbyname \
2096 'get(serv|host)byname(3) (via -lsocket -nsl)' \
2097 '' '-lsocket -lnsl' ||
2098 feat_bail_required SOCKETS
2102 run_check setsockopt 'setsockopt(2)' '#define HAVE_SETSOCKOPT' << \!
2103 #include <sys/socket.h>
2109 if(setsockopt(sockfd, SOL_SOCKET, SO_KEEPALIVE, NULL, 0) == -1 &&
2116 feat_yes SOCKETS && [ -n "${have_setsockopt}" ] &&
2117 link_check so_sndtimeo 'SO_SNDTIMEO' '#define HAVE_SO_SNDTIMEO' << \!
2118 #include <sys/socket.h>
2126 setsockopt(sockfd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof tv);
2127 setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof tv);
2132 feat_yes SOCKETS && [ -n "${have_setsockopt}" ] &&
2133 link_check so_linger 'SO_LINGER' '#define HAVE_SO_LINGER' << \!
2134 #include <sys/socket.h>
2142 setsockopt(sockfd, SOL_SOCKET, SO_LINGER, &li, sizeof li);
2147 if feat_yes SSL; then # {{{
2148 # {{{ LibreSSL decided to define OPENSSL_VERSION_NUMBER with a useless value
2149 # instead of keeping it at the one that corresponds to the OpenSSL at fork
2150 # time: we need to test it first in order to get things right
2151 if compile_check _xssl 'TLS/SSL (LibreSSL)' \
2154 #define HAVE_XSSL_RESSL
2155 #define HAVE_XSSL_OPENSSL 0' << \!
2156 #include <openssl/opensslv.h>
2157 #ifdef LIBRESSL_VERSION_NUMBER
2164 # TODO OPENSSL_IS_BORINGSSL, but never tried that one!
2165 elif compile_check _xssl 'TLS/SSL (OpenSSL >= v1.1.0)' \
2168 #define HAVE_XSSL_OPENSSL 0x10100' << \!
2169 #include <openssl/opensslv.h>
2170 #if OPENSSL_VERSION_NUMBER + 0 >= 0x10100000L
2177 elif compile_check _xssl 'TLS/SSL (OpenSSL)' \
2180 #define HAVE_XSSL_OPENSSL 0x10000' << \!
2181 #include <openssl/opensslv.h>
2182 #ifdef OPENSSL_VERSION_NUMBER
2190 feat_bail_required SSL
2193 if feat_yes SSL; then # {{{
2194 if [ -n "${ossl_v1_1}" ]; then
2195 without_check yes xssl 'TLS/SSL (new style *_client_method(3ssl))' \
2196 '#define n_XSSL_CLIENT_METHOD TLS_client_method' \
2198 elif link_check xssl 'TLS/SSL (new style *_client_method(3ssl))' \
2199 '#define n_XSSL_CLIENT_METHOD TLS_client_method' \
2200 '-lssl -lcrypto' << \!
2201 #include <openssl/ssl.h>
2202 #include <openssl/err.h>
2203 #include <openssl/x509v3.h>
2204 #include <openssl/x509.h>
2205 #include <openssl/rand.h>
2206 #ifdef OPENSSL_NO_TLS1 /* TODO only deduced from OPENSSL_NO_SSL[23]! */
2207 # error We need TLSv1.
2210 SSL_CTX *ctx = SSL_CTX_new(TLS_client_method());
2213 PEM_read_PrivateKey(0, 0, 0, 0);
2219 elif link_check xssl 'TLS/SSL (old style *_client_method(3ssl))' \
2220 '#define n_XSSL_CLIENT_METHOD SSLv23_client_method' \
2221 '-lssl -lcrypto' << \!
2222 #include <openssl/ssl.h>
2223 #include <openssl/err.h>
2224 #include <openssl/x509v3.h>
2225 #include <openssl/x509.h>
2226 #include <openssl/rand.h>
2227 #if defined OPENSSL_NO_SSL3 &&\
2228 defined OPENSSL_NO_TLS1 /* TODO only deduced from OPENSSL_NO_SSL[23]! */
2229 # error We need one of SSLv3 and TLSv1.
2232 SSL_CTX *ctx = SSL_CTX_new(SSLv23_client_method());
2235 PEM_read_PrivateKey(0, 0, 0, 0);
2242 feat_bail_required SSL
2246 if feat_yes SSL; then # {{{
2247 if [ -n "${ossl_v1_1}" ]; then
2248 without_check yes xssl_stack_of 'TLS/SSL STACK_OF()' \
2249 '#define HAVE_XSSL_STACK_OF'
2250 elif compile_check xssl_stack_of 'TLS/SSL STACK_OF()' \
2251 '#define HAVE_XSSL_STACK_OF' << \!
2252 #include <stdio.h> /* For C89 NULL */
2253 #include <openssl/ssl.h>
2254 #include <openssl/err.h>
2255 #include <openssl/x509v3.h>
2256 #include <openssl/x509.h>
2257 #include <openssl/rand.h>
2259 STACK_OF(GENERAL_NAME) *gens = NULL;
2261 printf("%p
", gens); /* to use it */
2269 if [ -n "${ossl_v1_1}" ]; then
2270 without_check yes xssl_conf 'TLS/SSL OpenSSL_modules_load_file()' \
2271 '#define HAVE_XSSL_CONFIG'
2272 elif link_check xssl_conf 'TLS/SSL OpenSSL_modules_load_file() support' \
2273 '#define HAVE_XSSL_CONFIG' << \!
2274 #include <stdio.h> /* For C89 NULL */
2275 #include <openssl/conf.h>
2277 CONF_modules_load_file(NULL, NULL, CONF_MFLAGS_IGNORE_MISSING_FILE);
2278 CONF_modules_free();
2286 if [ -n "${ossl_v1_1}" ]; then
2287 without_check yes xssl_conf_ctx 'TLS/SSL SSL_CONF_CTX support' \
2288 '#define HAVE_XSSL_CONF_CTX'
2289 elif link_check xssl_conf_ctx 'TLS/SSL SSL_CONF_CTX support' \
2290 '#define HAVE_XSSL_CONF_CTX' << \!
2291 #include <openssl/ssl.h>
2292 #include <openssl/err.h>
2294 SSL_CTX *ctx = SSL_CTX_new(n_XSSL_CLIENT_METHOD());
2295 SSL_CONF_CTX *cctx = SSL_CONF_CTX_new();
2297 SSL_CONF_CTX_set_flags(cctx,
2298 SSL_CONF_FLAG_FILE | SSL_CONF_FLAG_CLIENT |
2299 SSL_CONF_FLAG_CERTIFICATE | SSL_CONF_FLAG_SHOW_ERRORS);
2300 SSL_CONF_CTX_set_ssl_ctx(cctx, ctx);
2301 SSL_CONF_cmd(cctx, "Protocol
", "ALL
");
2302 SSL_CONF_CTX_finish(cctx);
2303 SSL_CONF_CTX_free(cctx);
2312 if [ -n "${ossl_v1_1}" ]; then
2313 without_check no xssl_rand_egd 'TLS/SSL RAND_egd(3ssl)' \
2314 '#define HAVE_XSSL_RAND_EGD'
2315 elif link_check xssl_rand_egd 'TLS/SSL RAND_egd(3ssl)' \
2316 '#define HAVE_XSSL_RAND_EGD' << \!
2317 #include <openssl/rand.h>
2319 return RAND_egd("some.where
") > 0;
2326 if feat_yes SSL_ALL_ALGORITHMS; then
2327 if [ -n "${ossl_v1_1}" ]; then
2328 without_check yes ssl_all_algo 'TLS/SSL all-algorithms support' \
2329 '#define HAVE_SSL_ALL_ALGORITHMS'
2330 elif link_check ssl_all_algo 'TLS/SSL all-algorithms support' \
2331 '#define HAVE_SSL_ALL_ALGORITHMS' << \!
2332 #include <openssl/evp.h>
2334 OpenSSL_add_all_algorithms();
2335 EVP_get_cipherbyname("two cents i never exist
");
2343 feat_bail_required SSL_ALL_ALGORITHMS
2346 fi # feat_yes SSL }}}
2348 if feat_yes SSL && feat_yes MD5 && feat_no NOEXTMD5; then # {{{
2349 run_check ssl_md5 'MD5 digest in the used crypto library' \
2350 '#define HAVE_XSSL_MD5' << \!
2353 #include <openssl/md5.h>
2355 char const dat[] = "abrakadabrafidibus
";
2356 char dig[16], hex[16 * 2];
2360 memset(dig, 0, sizeof(dig));
2361 memset(hex, 0, sizeof(hex));
2363 MD5_Update(&ctx, dat, sizeof(dat) - 1);
2364 MD5_Final(dig, &ctx);
2366 #define hexchar(n) ((n) > 9 ? (n) - 10 + 'a' : (n) + '0')
2367 for(i = 0; i < sizeof(hex) / 2; i++){
2369 hex[j] = hexchar((dig[i] & 0xf0) >> 4);
2370 hex[++j] = hexchar(dig[i] & 0x0f);
2372 return !!memcmp("6d7d0a3d949da2e96f2aa010f65d8326
", hex, sizeof(hex));
2377 echo '/* OPT_SSL=0 */' >> ${h}
2378 fi # }}} feat_yes SSL
2380 if [ "${have_xssl}" = yes ]; then
2391 if feat_yes GSSAPI; then
2392 ${cat} > ${tmp2}.c << \!
2393 #include <gssapi/gssapi.h>
2395 gss_import_name(0, 0, GSS_C_NT_HOSTBASED_SERVICE, 0);
2396 gss_init_sec_context(0,0,0,0,0,0,0,0,0,0,0,0,0);
2400 ${sed} -e '1s/gssapi\///' < ${tmp2}.c > ${tmp3}.c
2402 if acmd_set i krb5-config; then
2403 GSS_LIBS="`CFLAGS= ${i} --libs gssapi`"
2404 GSS_INCS="`CFLAGS= ${i} --cflags`"
2405 i='GSS-API via krb5-config(1)'
2409 i='GSS-API in gssapi/gssapi.h, libgssapi'
2411 if < ${tmp2}.c link_check gss \
2412 "${i}" '#define HAVE_GSSAPI' "${GSS_LIBS}" "${GSS_INCS}" ||\
2413 < ${tmp3}.c link_check gss \
2414 'GSS-API in gssapi.h, libgssapi' \
2415 '#define HAVE_GSSAPI
2416 #define GSSAPI_REG_INCLUDE' \
2418 < ${tmp2}.c link_check gss 'GSS-API in libgssapi_krb5' \
2419 '#define HAVE_GSSAPI' \
2421 < ${tmp3}.c link_check gss \
2422 'GSS-API in libgssapi, OpenBSD-style (pre 5.3)' \
2423 '#define HAVE_GSSAPI
2424 #define GSS_REG_INCLUDE' \
2425 '-lgssapi -lkrb5 -lcrypto' \
2426 '-I/usr/include/kerberosV' ||\
2427 < ${tmp2}.c link_check gss 'GSS-API in libgss' \
2428 '#define HAVE_GSSAPI' \
2430 link_check gss 'GSS-API in libgssapi_krb5, old-style' \
2431 '#define HAVE_GSSAPI
2432 #define GSSAPI_OLD_STYLE' \
2433 '-lgssapi_krb5' << \!
2434 #include <gssapi/gssapi.h>
2435 #include <gssapi/gssapi_generic.h>
2437 gss_import_name(0, 0, gss_nt_service_name, 0);
2438 gss_init_sec_context(0,0,0,0,0,0,0,0,0,0,0,0,0);
2445 feat_bail_required GSSAPI
2448 echo '/* OPT_GSSAPI=0 */' >> ${h}
2449 fi # feat_yes GSSAPI
2454 if feat_yes IDNA; then
2455 if link_check idna 'GNU Libidn' '#define HAVE_IDNA HAVE_IDNA_LIBIDNA' \
2458 #include <idn-free.h>
2459 #include <stringprep.h>
2461 char *utf8, *idna_ascii, *idna_utf8;
2463 utf8 = stringprep_locale_to_utf8("does.this.work
");
2464 if (idna_to_ascii_8z(utf8, &idna_ascii, IDNA_USE_STD3_ASCII_RULES)
2467 idn_free(idna_ascii);
2468 /* (Rather link check only here) */
2469 idna_utf8 = stringprep_convert(idna_ascii, "UTF-8
", "de_DE
");
2475 elif link_check idna 'idnkit' '#define HAVE_IDNA HAVE_IDNA_IDNKIT' \
2478 #include <idn/api.h>
2479 #include <idn/result.h>
2483 char local_name[256];
2485 r = idn_encodename(IDN_ENCODE_APP, "does.this.work
", ace_name,
2487 if (r != idn_success) {
2488 fprintf(stderr, "idn_encodename failed
: %s
\n", idn_result_tostring(r));
2491 r = idn_decodename(IDN_DECODE_APP, ace_name, local_name, sizeof(local_name));
2492 if (r != idn_success) {
2493 fprintf(stderr, "idn_decodename failed
: %s
\n", idn_result_tostring(r));
2502 feat_bail_required IDNA
2505 if [ -n "${have_idna}" ]; then
2506 echo '#define HAVE_IDNA_LIBIDNA 0' >> ${h}
2507 echo '#define HAVE_IDNA_IDNKIT 1' >> ${h}
2510 echo '/* OPT_IDNA=0 */' >> ${h}
2513 feat_def IMAP_SEARCH
2515 if feat_yes REGEX; then
2516 if link_check regex 'regular expressions' '#define HAVE_REGEX' << \!
2524 status = regcomp(&re, ".
*bsd
", REG_EXTENDED | REG_ICASE | REG_NOSUB);
2525 xret = regerror(status, &re, NULL, 0);
2526 status = regexec(&re, "plan9
", 0,NULL, 0);
2528 return !(status == REG_NOMATCH);
2534 feat_bail_required REGEX
2537 echo '/* OPT_REGEX=0 */' >> ${h}
2540 if feat_yes MLE && [ -n "${have_c90amend1}" ]; then
2542 echo '#define HAVE_MLE' >> ${h}
2544 feat_bail_required MLE
2545 echo '/* OPT_MLE=0 */' >> ${h}
2548 # Generic have-a-line-editor switch for those who need it below
2549 if [ -n "${have_mle}" ]; then
2553 if [ -n "${have_cle}" ] && feat_yes HISTORY; then
2554 echo '#define HAVE_HISTORY' >> ${h}
2556 echo '/* OPT_HISTORY=0 */' >> ${h}
2559 if [ -n "${have_mle}" ] && feat_yes KEY_BINDINGS; then
2560 echo '#define HAVE_KEY_BINDINGS' >> ${h}
2562 echo '/* OPT_KEY_BINDINGS=0 */' >> ${h}
2565 if feat_yes TERMCAP; then
2567 link_check termcap "termcap
(5) (via
${4})" \
2568 "#define HAVE_TERMCAP${3}" "${1}" << _EOT
2573 #define UNCONST(P) ((void*)(unsigned long)(void const*)(P))
2574 static int my_putc
(int c
){return putchar
(c
);}
2576 char buf
[1024+512], cmdbuf
[2048], *cpb
, *r1
;
2577 int r2
= OK
, r3
= ERR
;
2579 tgetent
(buf
, getenv
("TERM"));
2581 r1
= tgetstr
(UNCONST
("cm"), &cpb
);
2583 r2
= tgetnum
(UNCONST
("Co"));
2584 r3
= tgetflag
(UNCONST
("ut"));
2585 tputs
("cr", 1, &my_putc
);
2586 return (r1
== NULL || r2
== -1 || r3
== 0);
2592 link_check terminfo
"terminfo(5) (via ${2})" \
2593 '#define HAVE_TERMCAP
2594 #define HAVE_TERMCAP_CURSES
2595 #define HAVE_TERMINFO' "${1}" << _EOT
2599 #define UNCONST(P) ((void*)(unsigned long)(void const*)(P))
2600 static int my_putc(int c){return putchar(c);}
2606 r0 = setupterm(NULL, 1, &er);
2607 r1 = tigetflag(UNCONST("bce"));
2608 r2 = tigetnum(UNCONST("colors"));
2609 r3 = tigetstr(UNCONST("cr"));
2610 tp = tparm(r3, NULL, NULL, 0,0,0,0,0,0,0);
2611 tputs(tp, 1, &my_putc);
2612 return (r0 == ERR || r1 == -1 || r2 == -2 || r2 == -1 ||
2613 r3 == (char*)-1 || r3 == NULL);
2618 if feat_yes TERMCAP_VIA_TERMINFO
; then
2619 __terminfolib
-ltinfo -ltinfo ||
2620 __terminfolib
-lcurses -lcurses ||
2621 __terminfolib
-lcursesw -lcursesw ||
2622 feat_bail_required TERMCAP_VIA_TERMINFO
2625 if [ -z "${have_terminfo}" ]; then
2626 __termcaplib
-ltermcap '' '' '-ltermcap' ||
2627 __termcaplib
-ltermcap '#include <curses.h>' '
2628 #define HAVE_TERMCAP_CURSES' \
2629 'curses.h / -ltermcap' ||
2630 __termcaplib
-lcurses '#include <curses.h>' '
2631 #define HAVE_TERMCAP_CURSES' \
2632 'curses.h / -lcurses' ||
2633 __termcaplib
-lcursesw '#include <curses.h>' '
2634 #define HAVE_TERMCAP_CURSES' \
2635 'curses.h / -lcursesw' ||
2636 feat_bail_required TERMCAP
2638 if [ -n "${have_termcap}" ]; then
2639 run_check tgetent_null \
2640 "tgetent(3) of termcap(5) takes NULL buffer" \
2641 "#define HAVE_TGETENT_NULL_BUF" << _EOT
2642 #include <stdio.h> /* For C89 NULL */
2644 #ifdef HAVE_TERMCAP_CURSES
2645 # include <curses.h>
2649 tgetent(NULL, getenv("TERM"));
2656 echo '/* OPT_TERMCAP=0 */' >> ${h}
2657 echo '/* OPT_TERMCAP_VIA_TERMINFO=0 */' >> ${h}
2660 if feat_def SPAM_SPAMC
; then
2661 if acmd_set i spamc
; then
2662 echo "#define SPAM_SPAMC_PATH \"${i}\"" >> ${h}
2666 if feat_yes SPAM_SPAMD
&& [ -n "${have_af_unix}" ]; then
2667 echo '#define HAVE_SPAM_SPAMD' >> ${h}
2669 feat_bail_required SPAM_SPAMD
2670 echo '/* OPT_SPAM_SPAMD=0 */' >> ${h}
2673 feat_def SPAM_FILTER
2675 if feat_yes SPAM_SPAMC || feat_yes SPAM_SPAMD || feat_yes SPAM_FILTER
; then
2676 echo '#define HAVE_SPAM' >> ${h}
2678 echo '/* HAVE_SPAM */' >> ${h}
2681 if feat_yes QUOTE_FOLD
&&\
2682 [ -n "${have_c90amend1}" ] && [ -n "${have_wcwidth}" ]; then
2683 echo '#define HAVE_QUOTE_FOLD' >> ${h}
2685 feat_bail_required QUOTE_FOLD
2686 echo '/* OPT_QUOTE_FOLD=0 */' >> ${h}
2689 feat_def FILTER_HTML_TAGSOUP
2698 squeeze_em
${inc} ${tmp}
2700 squeeze_em
${lib} ${tmp}
2705 printf '#ifndef n_MK_CONFIG_H\n# define n_MK_CONFIG_H 1\n' > ${h}
2706 ${cat} ${tmp} >> ${h}
2710 # Create the string that is used by *features* and `version'.
2711 # Take this nice opportunity and generate a visual listing of included and
2712 # non-included features for the person who runs the configuration
2713 msg
'\nThe following features are included (+) or not (-):'
2714 set -- ${OPTIONS_DETECT} ${OPTIONS} ${OPTIONS_XTRA}
2715 printf '/* The "feature string" */\n' >> ${h}
2716 # Because + is expanded by *folder* if first in "echo $features", put something
2717 printf '#define VAL_FEATURES_CNT '${#}'\n#define VAL_FEATURES "#' >> ${h}
2721 sdoc
=`option_doc_of ${opt}`
2722 [ -z "${sdoc}" ] && continue
2723 sopt
="`echo ${opt} | ${tr} '[A-Z]_' '[a-z]-'`"
2724 feat_yes
${opt} && sign
=+ || sign
=-
2725 printf -- "${sep}${sign}${sopt}" >> ${h}
2727 msg " %s
%s
: %s
" ${sign} ${sopt} "${sdoc}"
2729 # TODO instead of using sh+tr+awk+printf, use awk, drop option_doc_of, inc here
2731 #${awk} -v opts="${OPTIONS_DETECT} ${OPTIONS} ${OPTIONS_XTRA}" \
2732 # -v xopts="${XOPTIONS_DETECT} ${XOPTIONS} ${XOPTIONS_XTRA}" \
2733 printf '"\n' >> ${h}
2735 # Create the real mk-config.mk
2736 # Note we cannout use explicit ./ filename prefix for source and object
2737 # pathnames because of a bug in bmake(1)
2738 ${rm} -rf ${tmp0}.* ${tmp0}*
2740 if feat_no AMALGAMATION
; then
2741 for i
in `printf '%s\n' "${SRCDIR}"*.c | ${sort}`; do
2742 i
=`basename "${i}" .c`
2743 if [ "${i}" = privsep
]; then
2746 objlist
="${objlist} ${i}.o"
2747 srclist
="${srclist} \$(SRCDIR)${i}.c"
2748 printf '%s: %s\n\t$(ECHO_CC)$(CC) $(CFLAGS) $(INCS) -c %s\n' \
2749 "${i}.o" "\$(SRCDIR)${i}.c" "\$(SRCDIR)${i}.c" >> ${mk}
2751 printf '\nAMALGAM_TARGET =\nAMALGAM_DEP =\n' >> ${mk}
2753 printf '%s:\n\t$(ECHO_CC)$(CC) $(CFLAGS) $(INCS) -c $(SRCDIR)%s\n' \
2754 "main.o
" "main.c
" >> ${mk}
2755 srclist=main.c objlist=main.o
2756 printf '\nAMALGAM_TARGET = main.o\nAMALGAM_DEP = ' >> ${mk}
2758 printf '\n/* HAVE_AMALGAMATION: include sources */\n' >> ${h}
2759 printf '#elif n_MK_CONFIG_H + 0 == 1\n' >> ${h}
2760 printf '# undef n_MK_CONFIG_H\n' >> ${h}
2761 printf '# define n_MK_CONFIG_H 2\n' >> ${h}
2762 for i in `printf '%s\n' "${SRCDIR}"*.c | ${sort}`; do
2764 if [ "${i}" = main.c ] ||
2765 [ "${i}" = privsep.c ]; then
2768 printf '$(SRCDIR)%s ' "${i}" >> ${mk}
2769 printf '# include "%s
%s
"\n' "${SRCDIR}" "${i}" >> ${h}
2773 printf 'OBJ_SRC = %s\nOBJ = %s\n' "${srclist}" "${objlist}" >> "${mk}"
2775 printf '#endif /* n_MK_CONFIG_H */\n' >> ${h}
2777 echo "LIBS = `${cat} ${lib}`" >> ${mk}
2778 echo "INCS
= `${cat} ${inc}`" >> ${mk}
2780 ${cat} "${SRCDIR}"make-config.in >> ${mk}
2785 msg ' . System-wide resource file: %s/%s' "${VAL_SYSCONFDIR}" "${VAL_SYSCONFRC}"
2786 msg ' . bindir: %s' "${VAL_BINDIR}"
2787 if feat_yes DOTLOCK; then
2788 msg ' . libexecdir: %s' "${VAL_LIBEXECDIR}"
2790 msg ' . mandir: %s' "${VAL_MANDIR}"
2791 msg ' . M(ail)T(ransfer)A(gent): %s (argv0 %s)' "${VAL_MTA}" "${VAL_MTA_ARGV0}"
2792 msg ' . $MAIL spool directory: %s' "${VAL_MAIL}"
2795 if [ -n "${have_fnmatch}" ] && [ -n "${have_fchdir}" ]; then
2799 if [ -z "${have_fnmatch}" ]; then
2800 msg ' . The function fnmatch(3) could not be found.'
2801 msg ' Filename patterns like wildcard are not supported on your system'
2803 if [ -z "${have_fchdir}" ]; then
2804 msg ' . The function fchdir(2) could not be found.'
2805 msg ' We will use chdir(2) instead.'
2806 msg ' This is a problem only if the current working directory is changed'
2807 msg ' while this program is inside of it'