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
246 # We don't "have any utility": only path adjustments and such in here!
247 [ -n "${OS}" ] || OS
=`uname -s`
250 if [ ${OS} = SunOS
]; then
251 msg
'SunOS / Solaris? Applying some "early setup" rules ...'
252 _os_early_setup_sunos
256 _os_early_setup_sunos
() {
257 # According to standards(5), this is what we need to do
258 if [ -d /usr
/xpg4
]; then :; else
259 msg
'ERROR: On SunOS / Solaris we need /usr/xpg4 environment! Sorry.'
262 PATH
="/usr/xpg4/bin:/usr/ccs/bin:/usr/bin:${PATH}"
263 [ -d /usr
/xpg6
] && PATH
="/usr/xpg6/bin:${PATH}"
268 # OSENV ends up in *build-osenv*
269 # OSFULLSPEC is used to recognize changes (i.e., machine type, updates etc.)
270 OS
=`echo ${OS} | ${tr} '[A-Z]' '[a-z]'`
271 [ -n "${OSENV}" ] || OSENV
=`uname -srm`
272 [ -n "${OSFULLSPEC}" ] || OSFULLSPEC
=`uname -a`
273 msg
'Operating system is %s' ${OS}
275 if [ ${OS} = darwin
]; then
276 msg
' . have special Darwin environmental addons...'
277 LD_LIBRARY_PATH
=${LD_LIBRARY_PATH}:${DYLD_LIBRARY_PATH}
278 elif [ ${OS} = sunos
]; then
279 msg
' . have special SunOS / Solaris "setup" rules ...'
281 elif [ ${OS} = unixware
]; then
282 if feat_yes AUTOCC
&& acmd_set CC cc
; then
283 msg
' . have special UnixWare environmental rules ...'
284 feat_yes DEBUG
&& _CFLAGS
='-v -Xa -g' || _CFLAGS
='-Xa -O'
286 CFLAGS
="${_CFLAGS} ${EXTRA_CFLAGS}"
287 LDFLAGS
="${_LDFLAGS} ${EXTRA_LDFLAGS}"
288 export CC CFLAGS LDFLAGS
289 OPT_AUTOCC
=0 had_want_autocc
=1 need_R_ldflags
=-R
291 elif [ -n "${VERBOSE}" ]; then
292 msg
' . no special treatment for this system necessary or known'
295 # Sledgehammer: better set _GNU_SOURCE
296 # And in general: oh, boy!
297 OS_DEFINES
="${OS_DEFINES}#define _GNU_SOURCE\n"
298 #OS_DEFINES="${OS_DEFINES}#define _POSIX_C_SOURCE 200809L\n"
299 #OS_DEFINES="${OS_DEFINES}#define _XOPEN_SOURCE 700\n"
300 #[ ${OS} = darwin ] && OS_DEFINES="${OS_DEFINES}#define _DARWIN_C_SOURCE\n"
302 # On pkgsrc(7) systems automatically add /usr/pkg/*
303 if [ -d /usr
/pkg
] && feat_yes USE_PKGSYS
; then
304 msg
' . found pkgsrc(7), merging C_INCLUDE_PATH and LD_LIBRARY_PATH'
305 C_INCLUDE_PATH
=/usr
/pkg
/include
:${C_INCLUDE_PATH}
306 LD_LIBRARY_PATH
=/usr
/pkg
/lib
:${LD_LIBRARY_PATH}
311 C_INCLUDE_PATH
=/usr
/xpg
4/include
:${C_INCLUDE_PATH}
312 LD_LIBRARY_PATH
=/usr
/xpg
4/lib
:${LD_LIBRARY_PATH}
315 if [ -d /opt
/csw
] && feat_yes USE_PKGSYS
; then
316 msg
' . found OpenCSW PKGSYS, merging C_INCLUDE_PATH and LD_LIBRARY_PATH'
317 C_INCLUDE_PATH
=/opt
/csw
/include
:${C_INCLUDE_PATH}
318 LD_LIBRARY_PATH
=/opt
/csw
/lib
:${LD_LIBRARY_PATH}
320 if [ -d /opt
/schily
] && feat_yes USE_PKGSYS
; then
321 msg
' . found Schily PKGSYS, merging C_INCLUDE_PATH and LD_LIBRARY_PATH'
322 C_INCLUDE_PATH
=/opt
/schily
/include
:${C_INCLUDE_PATH}
323 LD_LIBRARY_PATH
=/opt
/schily
/lib
:${LD_LIBRARY_PATH}
326 OS_DEFINES
="${OS_DEFINES}#define __EXTENSIONS__\n"
327 #OS_DEFINES="${OS_DEFINES}#define _POSIX_C_SOURCE 200112L\n"
329 [ -n "${cksum}" ] ||
cksum=/opt
/csw
/gnu
/cksum
330 if [ -x "${cksum}" ]; then :; else
331 msg
'ERROR: Not an executable program: %s' "${cksum}"
332 msg
'ERROR: We need a CRC-32 cksum(1), as specified in POSIX.'
333 msg
'ERROR: However, we do so only for tests.'
334 msg
'ERROR: If that is ok, set "cksum=/usr/bin/true", then rerun'
338 if feat_yes AUTOCC
; then
339 if acmd_set CC cc
; then
340 feat_yes DEBUG
&& _CFLAGS
="-v -Xa -g" || _CFLAGS
="-Xa -O"
342 CFLAGS
="${_CFLAGS} ${EXTRA_CFLAGS}"
343 LDFLAGS
="${_LDFLAGS} ${EXTRA_LDFLAGS}"
344 export CC CFLAGS LDFLAGS
345 OPT_AUTOCC
=0 had_want_autocc
=1 need_R_ldflags
=-R
347 cc_maxopt
=2 #force_no_stackprot=1
352 # Check out compiler ($CC) and -flags ($CFLAGS)
354 # Even though it belongs into cc_flags we will try to compile and link
355 # something, so ensure we have a clean state regarding CFLAGS/LDFLAGS or
356 # EXTRA_CFLAGS/EXTRA_LDFLAGS
357 if feat_no AUTOCC
; then
359 # Ensure those don't do any harm
360 EXTRA_CFLAGS
= EXTRA_LDFLAGS
=
361 export EXTRA_CFLAGS EXTRA_LDFLAGS
365 export CFLAGS LDFLAGS
368 [ -n "${CC}" ] && { _cc_default
; return; }
370 msg_nonl
'Searching for a usable C compiler .. $CC='
371 if acmd_set CC clang || acmd_set CC gcc ||
372 acmd_set CC tcc || acmd_set CC pcc ||
373 acmd_set CC c89 || acmd_set CC c99
; then
376 msg
'boing booom tschak'
377 msg
'ERROR: I cannot find a compiler!'
378 msg
' Neither of clang(1), gcc(1), tcc(1), pcc(1), c89(1) and c99(1).'
379 msg
' Please set ${CC} environment variable, maybe ${CFLAGS}, rerun.'
387 if [ -z "${CC}" ]; then
388 msg
'To go on like you have chosen, please set $CC, rerun.'
392 if [ -z "${VERBOSE}" ] && [ -f ${lst} ] && feat_no DEBUG
; then
395 msg
'Using C compiler ${CC}=%s' "${CC}"
400 if feat_yes AUTOCC
; then
401 if [ -f ${lst} ] && feat_no DEBUG
&& [ -z "${VERBOSE}" ]; then
403 msg
'Detecting ${CFLAGS}/${LDFLAGS} for ${CC}=%s, just a second..' \
407 msg
'Testing usable ${CFLAGS}/${LDFLAGS} for ${CC}=%s' "${CC}"
410 i=`echo "${CC}" | ${awk} 'BEGIN{FS="/"}{print $NF}'`
411 if { echo "${i}" | ${grep} tcc; } >/dev/null 2>&1; then
412 msg ' . have special tcc(1) environmental rules ...'
415 # As of pcc CVS 2016-04-02, stack protection support is announced but
416 # will break if used on Linux
417 if { echo "${i}" | ${grep} pcc; } >/dev/null 2>&1; then
423 feat_no DEBUG && _CFLAGS="-DNDEBUG ${_CFLAGS}"
424 CFLAGS="${_CFLAGS} ${EXTRA_CFLAGS}"
425 LDFLAGS="${_LDFLAGS} ${EXTRA_LDFLAGS}"
427 if feat_no DEBUG; then
428 CFLAGS="-DNDEBUG ${CFLAGS}"
432 export CFLAGS LDFLAGS
436 __cflags=${_CFLAGS} __ldflags=${_LDFLAGS}
443 if feat_yes DEBUG; then
444 # May have problems to find libtcc cc_check -b
448 if ld_check -Wl,-rpath =./ no; then
449 need_R_ldflags=-Wl,-rpath=
450 ld_check -Wl,--enable-new-dtags
451 ld_runtime_flags # update!
454 _CFLAGS="${_CFLAGS} ${__cflags}" _LDFLAGS="${_LDFLAGS} ${__ldflags}"
455 unset __cflags __ldflags
458 _cc_flags_generic() {
459 __cflags=${_CFLAGS} __ldflags=${_LDFLAGS}
461 feat_yes DEVEL && cc_check -std=c89 || cc_check -std=c99
463 # E.g., valgrind does not work well with high optimization
464 if [ ${cc_maxopt} -gt 1 ] && feat_yes NOMEMDBG &&
465 feat_no ASAN_ADDRESS && feat_no ASAN_MEMORY; then
466 msg 'OP_NOMEMDBG, setting cc_maxopt=1 (-O1)'
469 # Check -g first since some others may rely upon -g / optim. level
470 if feat_yes DEBUG; then
473 elif [ ${cc_maxopt} -gt 2 ] && cc_check -O3; then
475 elif [ ${cc_maxopt} -gt 1 ] && cc_check -O2; then
477 elif [ ${cc_maxopt} -gt 0 ] && cc_check -O1; then
483 if feat_yes AMALGAMATION; then
487 #if feat_yes DEVEL && cc_check -Weverything; then
492 cc_check -Wbad-function-cast
493 cc_check -Wcast-align
496 cc_check -Wmissing-prototypes
499 cc_check -Wwrite-strings
500 cc_check -Wno-long-long
504 if feat_yes AMALGAMATION && feat_no DEVEL; then
505 cc_check -Wno-unused-function
507 feat_no DEVEL && cc_check -Wno-unused-result # XXX do right way (pragma too)
509 cc_check -fno-unwind-tables
510 cc_check -fno-asynchronous-unwind-tables
511 cc_check -fstrict-aliasing
512 if cc_check -fstrict-overflow && feat_yes DEVEL; then
513 cc_check -Wstrict-overflow=5
516 if feat_yes DEBUG || feat_yes FORCED_STACKPROT; then
517 if [ -z "${force_no_stackprot}" ]; then
518 if cc_check -fstack-protector-strong ||
519 cc_check -fstack-protector-all; then
520 cc_check -D_FORTIFY_SOURCE=2
523 msg 'Not checking for -fstack-protector compiler option,'
524 msg 'since that caused errors in a "similar" configuration.'
525 msg 'You may turn off OPT_AUTOCC and use your own settings, rerun'
529 # LD (+ dependend CC)
531 if feat_yes ASAN_ADDRESS; then
533 if cc_check -fsanitize=address &&
534 ld_check -fsanitize=address; then
537 feat_bail_required ASAN_ADDRESS
542 if feat_yes ASAN_MEMORY; then
544 if cc_check -fsanitize=memory &&
545 ld_check -fsanitize=memory &&
546 cc_check -fsanitize-memory-track-origins=2 &&
547 ld_check -fsanitize-memory-track-origins=2; then
550 feat_bail_required ASAN_MEMORY
555 ld_check -Wl,-z,relro
557 ld_check -Wl,-z,noexecstack
558 if ld_check -Wl,-rpath =./ no; then
559 need_R_ldflags=-Wl,-rpath=
560 # Choose DT_RUNPATH (after $LD_LIBRARY_PATH) over DT_RPATH (before)
561 ld_check -Wl,--enable-new-dtags
562 ld_runtime_flags # update!
563 elif ld_check -Wl,-R ./ no; then
564 need_R_ldflags=-Wl,-R
565 ld_check -Wl,--enable-new-dtags
566 ld_runtime_flags # update!
569 # Address randomization
571 if cc_check -fPIE || cc_check -fpie; then
572 ld_check -pie || _CFLAGS=${_ccfg}
576 _CFLAGS="${_CFLAGS} ${__cflags}" _LDFLAGS="${_LDFLAGS} ${__ldflags}"
577 unset __cflags __ldflags
580 ## -- >8 - <<OS/CC | SUPPORT FUNS>> - 8< -- ##
583 ## - Heirloom sh(1) (and same origin) have _sometimes_ problems with ': >'
584 ## redirection, so use "printf '' >" instead
586 ## Very first: we undergo several states regarding I/O redirection etc.,
587 ## but need to deal with option updates from within all. Since all the
588 ## option stuff should be above the scissor line, define utility functions
589 ## and redefine them as necessary.
590 ## And, since we have those functions, simply use them for whatever
592 t1=ten10one1ten10one1
593 if ( [ ${t1##*ten10} = one1 ] && [ ${t1#*ten10} = one1ten10one1 ] &&
594 [ ${t1%%one1*} = ten10 ] && [ ${t1%one1*} = ten10one1ten10 ]
595 ) > /dev/null 2>&1; then
602 ( set -o noglob ) >/dev/null 2>&1 && noglob_shell=1 || unset noglob_shell
608 # which(1) not standardized, command(1) -v may return non-executable: unroll!
609 acmd_test() { __acmd "${1}" 1 0 0; }
610 acmd_test_fail() { __acmd "${1}" 1 1 0; }
611 acmd_set() { __acmd "${2}" 0 0 0 "${1}"; }
612 acmd_set_fail() { __acmd "${2}" 0 1 0 "${1}"; }
613 acmd_testandset() { __acmd "${2}" 1 0 0 "${1}"; }
614 acmd_testandset_fail() { __acmd "${2}" 1 1 0 "${1}"; }
615 thecmd_set() { __acmd "${2}" 0 0 1 "${1}"; }
616 thecmd_set_fail() { __acmd "${2}" 0 1 1 "${1}"; }
617 thecmd_testandset() { __acmd "${2}" 1 0 1 "${1}"; }
618 thecmd_testandset_fail() { __acmd "${2}" 1 1 1 "${1}"; }
620 pname=${1} dotest=${2} dofail=${3} verbok=${4} varname=${5}
622 if [ "${dotest}" -ne 0 ]; then
623 eval dotest=\$${varname}
624 if [ -n "${dotest}" ]; then
625 [ -n "${VERBOSE}" ] && [ ${verbok} -ne 0 ] &&
626 msg ' . ${%s} ... %s' "${pname}" "${dotest}"
632 [ -n "${noglob_shell}" ] && set -o noglob
634 [ -n "${noglob_shell}" ] && set +o noglob
638 if [ -z "${path}" ] || [ "${path}" = . ]; then
639 if [ -d "${PWD}" ]; then
645 if [ -f "${path}/${pname}" ] && [ -x "${path}/${pname}" ]; then
646 [ -n "${VERBOSE}" ] && [ ${verbok} -ne 0 ] &&
647 msg ' . ${%s} ... %s' "${pname}" "${path}/${pname}"
648 [ -n "${varname}" ] && eval ${varname}="${path}/${pname}"
653 # We may have no builtin string functions, we yet have no programs we can
654 # use, try to access once from the root, assuming it is an absolute path if
655 # that finds the executable
656 if ( cd && [ -f "${pname}" ] && [ -x "${pname}" ] ); then
657 [ -n "${VERBOSE}" ] && [ ${verbok} -ne 0 ] &&
658 msg ' . ${%s} ... %s' "${pname}" "${pname}"
659 [ -n "${varname}" ] && eval ${varname}="${pname}"
663 [ ${dofail} -eq 0 ] && return 1
664 msg 'ERROR: no trace of utility '"${pname}"
671 printf >&2 -- "${fmt}\\n" "${@}"
677 printf >&2 -- "${fmt}" "${@}"
680 # Our feature check environment
682 [ "x${1}" = x0 ] || [ "x${1}" = xn ] ||
683 [ "x${1}" = xfalse ] || [ "x${1}" = xno ] || [ "x${1}" = xoff ]
687 [ "x${1}" = x1 ] || [ "x${1}" = xy ] ||
688 [ "x${1}" = xtrue ] || [ "x${1}" = xyes ] || [ "x${1}" = xon ] ||
689 [ "x${1}" = xrequire ]
693 [ "x${1}" = xrequire ]
698 i="`echo ${i} |
${tr} '[A-Z]' '[a-z]'`"
699 if feat_val_no "${i}"; then
701 elif feat_val_yes "${i}"; then
704 msg "ERROR: %s: 0/n/false/no/off or 1/y/true/yes/on/require, got: %s" \
715 _feat_check ${1} && return 1
721 i="`echo ${i} |
${tr} '[A-Z]' '[a-z]'`"
722 [ "x${i}" = xrequire ] || [ "x${i}" = xrequired ]
725 feat_bail_required() {
726 if feat_require ${1}; then
727 msg 'ERROR: feature OPT_%s is required but not available' "${1}"
731 option_update # XXX this is rather useless here (dependency chain..)
735 # Parse one of our XOPTIONS* in $2 and assign the sh(1) compatible list of
736 # options, without documentation, to $1
738 i="`${awk} -v input
=\"${2}\" '
741 voff = match(input, /[[:alnum:]_]+(='${j}'[^'${j}']+)?/)
744 v = substr(input, voff, RLENGTH)
745 input = substr(input, voff + RLENGTH)
748 d = substr(v, doff + 2, length(v) - doff - 1)
749 v = substr(v, 1, doff - 1)
759 # Return the "documentation string" for option $1, itself if none such
761 ${awk} -v want="${1}" \
762 -v input="${XOPTIONS_DETECT}${XOPTIONS}${XOPTIONS_XTRA}" '
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)
787 # Join the values from make.rc into what currently is defined, not
788 # overwriting yet existing settings
790 # We want read(1) to perform reverse solidus escaping in order to be able to
791 # use multiline values in make.rc; the resulting sh(1)/sed(1) code was very
792 # slow in VMs (see [fa2e248]), Aharon Robbins suggested the following
793 < ${rc} ${awk} 'BEGIN{line = ""}{
794 gsub(/^[[:space:]]+/, "", $0)
795 gsub(/[[:space:]]+$/, "", $0)
796 if(gsub(/\\$/, "", $0)){
801 if(index(line, "#") == 1){
803 }else if(length(line)){
809 if [ -n "${good_shell}" ]; then
812 i=`${awk} -v LINE
="${line}" 'BEGIN{
813 gsub(/=.*$/, "", LINE)
817 if [ "${i}" = "${line}" ]; then
818 msg 'ERROR: invalid syntax in: %s' "${line}"
822 eval j="\$${i}" jx="\${${i}+x}"
823 if [ -n "${j}" ] || [ "${jx}" = x ]; then
826 j=`${awk} -v LINE
="${line}" 'BEGIN{
827 gsub(/^[^=]*=/, "", LINE)
828 gsub(/^\"*/, "", LINE)
829 gsub(/\"*$/, "", LINE)
833 [ "${i}" = "DESTDIR" ] && continue
836 # Reread the mixed version right now
841 # Expand the option values, which may contain shell snippets
842 ${rm} -f ${newlst} ${newmk} ${newh}
843 exec 5<&0 6>&1 <${tmp} >${newlst}
846 if [ -n "${good_shell}" ]; then
848 [ "${i}" != "${i#OPT_}" ] && z=1
850 i=`${awk} -v LINE
="${line}" 'BEGIN{
851 gsub(/=.*$/, "", LINE);\
854 if echo "${i}" | ${grep} '^OPT_' >/dev/null 2>&1; then
860 if [ -n "${z}" ]; then
861 j="`echo ${j} |
${tr} '[A-Z]' '[a-z]'`"
862 if [ -z "${j}" ] || feat_val_no "${j}"; then
864 printf " /* #undef ${i} */\n" >> ${newh}
865 elif feat_val_yes "${j}"; then
866 if feat_val_require "${j}"; then
871 printf " /* #define ${i} */\n" >> ${newh}
873 msg 'ERROR: cannot parse <%s>' "${line}"
877 printf "#define ${i} \"${j}\"\n" >> ${newh}
879 printf "${i} = ${j}\n" >> ${newmk}
883 exec 0<&5 1>&6 5<&- 6<&-
887 # "path_check VARNAME" or "path_check VARNAME FLAG VARNAME"
888 varname=${1} addflag=${2} flagvarname=${3}
891 [ -n "${noglob_shell}" ] && set -o noglob
893 [ -n "${noglob_shell}" ] && set +o noglob
898 [ -z "${i}" ] && continue
899 [ -d "${i}" ] || continue
900 if [ -n "${j}" ]; then
901 if { z=${y}; echo "${z}"; } | ${grep} ":${i}:" >/dev/null 2>&1; then
906 # But do not link any fakeroot path into our binaries!
907 if [ -n "${addflag}" ]; then
908 case "${i}" in *fakeroot*) continue;; esac
909 k="${k} ${addflag}${i}"
915 # But do not link any fakeroot path into our binaries!
916 if [ -n "${addflag}" ]; then
917 case "${i}" in *fakeroot*) continue;; esac
918 k="${k} ${addflag}${i}"
922 eval "${varname}=\"${j}\""
923 [ -n "${addflag}" ] && eval "${flagvarname}=\"${k}\""
928 if [ -n "${need_R_ldflags}" ]; then
931 set -- ${LD_LIBRARY_PATH}
935 # But do not link any fakeroot path into our binaries!
936 case "${i}" in *fakeroot*) continue;; esac
937 LDFLAGS="${LDFLAGS} ${need_R_ldflags}${i}"
938 _LDFLAGS="${_LDFLAGS} ${need_R_ldflags}${i}"
942 # Disable it for a possible second run.
947 [ -n "${cc_check_silent}" ] || msg_nonl ' . CC %s .. ' "${1}"
949 ${_CFLAGS} ${1} ${EXTRA_CFLAGS} ${_LDFLAGS} ${EXTRA_LDFLAGS} \
950 -o ${tmp2} ${tmp}.c ${LIBS} >/dev/null 2>&1; then
951 _CFLAGS="${_CFLAGS} ${1}"
952 [ -n "${cc_check_silent}" ] || msg 'yes'
955 [ -n "${cc_check_silent}" ] || msg 'no'
960 # $1=option [$2=option argument] [$3=if set, shall NOT be added to _LDFLAGS]
961 [ -n "${cc_check_silent}" ] || msg_nonl ' . LD %s .. ' "${1}"
962 if "${CC}" ${INCS} ${_CFLAGS} ${_LDFLAGS} ${1}${2} ${EXTRA_LDFLAGS} \
963 -o ${tmp2} ${tmp}.c ${LIBS} >/dev/null 2>&1; then
964 [ -n "${3}" ] || _LDFLAGS="${_LDFLAGS} ${1}"
965 [ -n "${cc_check_silent}" ] || msg 'yes'
968 [ -n "${cc_check_silent}" ] || msg 'no'
974 variable=$1 topic=$2 define=$3
977 msg_nonl ' . %s ... ' "${topic}"
978 echo "/* checked ${topic} */" >> ${h}
979 ${rm} -f ${tmp} ${tmp}.o
980 if [ "${dump_test_program}" = 1 ]; then
981 echo '*** test program is'
982 { echo '#include <'"${h_name}"'>'; cat; } | ${tee} ${tmp}.c
984 { echo '#include <'"${h_name}"'>'; cat; } > ${tmp}.c
986 #echo '*** the preprocessor generates'
987 #${make} -f ${makefile} ${tmp}.x
989 echo '*** tests results'
993 yesno=$1 variable=$2 topic=$3 define=$4 libs=$5 incs=$6
996 msg_nonl ' . %s ... ' "${topic}"
998 echo '*** enforced unchecked results are'
999 if feat_val_yes ${yesno}; then
1000 if [ -n "${incs}" ] || [ -n "${libs}" ]; then
1001 echo "*** adding INCS<${incs}> LIBS<${libs}>"
1002 LIBS="${LIBS} ${libs}"
1003 echo "${libs}" >> ${lib}
1004 INCS="${INCS} ${incs}"
1005 echo "${incs}" >> ${inc}
1008 echo "${define}" >> ${h}
1009 eval have_${variable}=yes
1012 echo "/* ${define} */" >> ${h}
1014 eval unset have_${variable}
1020 variable=$1 topic=$2 define=$3
1022 _check_preface "${variable}" "${topic}" "${define}"
1024 if ${make} -f ${makefile} XINCS="${INCS}" \
1025 CFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}" \
1027 [ -f ./${tmp}.o ]; then
1029 echo "${define}" >> ${h}
1030 eval have_${variable}=yes
1033 echo "/* ${define} */" >> ${h}
1035 eval unset have_${variable}
1041 run=$1 variable=$2 topic=$3 define=$4 libs=$5 incs=$6
1043 _check_preface "${variable}" "${topic}" "${define}"
1045 if feat_yes CROSS_BUILD; then
1046 if [ ${run} = 1 ]; then
1051 if ${make} -f ${makefile} XINCS="${INCS} ${incs}" \
1052 CFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}" \
1053 XLIBS="${LIBS} ${libs}" \
1056 { [ ${run} -eq 0 ] || ./${tmp}; }; then
1057 echo "*** adding INCS<${incs}> LIBS<${libs}>; executed: ${run}"
1059 echo "${define}" >> ${h}
1060 LIBS="${LIBS} ${libs}"
1061 echo "${libs}" >> ${lib}
1062 INCS="${INCS} ${incs}"
1063 echo "${incs}" >> ${inc}
1064 eval have_${variable}=yes
1068 echo "/* ${define} */" >> ${h}
1069 eval unset have_${variable}
1075 _link_mayrun 0 "${1}" "${2}" "${3}" "${4}" "${5}"
1079 _link_mayrun 1 "${1}" "${2}" "${3}" "${4}" "${5}"
1083 _link_mayrun 2 "${1}" "${2}" "${3}" "${4}" "${5}"
1087 if feat_yes ${1}; then
1088 echo '#define HAVE_'${1}'' >> ${h}
1091 echo '/* OPT_'${1}'=0 */' >> ${h}
1097 < "${1}" > "${2}" ${awk} \
1098 'BEGIN {ORS = " "} /^[^#]/ {print} {next} END {ORS = ""; print "\n"}'
1101 ## -- >8 - <<SUPPORT FUNS | RUNNING>> - 8< -- ##
1103 # First of all, create new configuration and check whether it changed
1105 # Very easy checks for the operating system in order to be able to adjust paths
1106 # or similar very basic things which we need to be able to go at all
1109 # Check those tools right now that we need before including $rc
1110 msg 'Checking for basic utility set'
1111 thecmd_testandset_fail awk awk
1112 thecmd_testandset_fail rm rm
1113 thecmd_testandset_fail tr tr
1115 # Initialize the option set
1116 msg_nonl 'Setting up configuration options ... '
1120 # Include $rc, but only take from it what wasn't overwritten by the user from
1121 # within the command line or from a chosen fixed CONFIG=
1122 # Note we leave alone the values
1123 trap "exit 1" HUP INT TERM
1124 trap "${rm} -f ${tmp}" EXIT
1126 msg_nonl 'Joining in %s ... ' ${rc}
1130 # We need to know about that now, in order to provide utility overwrites etc.
1133 msg 'Checking for remaining set of utilities'
1134 thecmd_testandset_fail grep grep
1136 # Before we step ahead with the other utilities perform a path cleanup first.
1140 thecmd_testandset_fail basename basename
1141 thecmd_testandset_fail cat cat
1142 thecmd_testandset_fail chmod chmod
1143 thecmd_testandset_fail cp cp
1144 thecmd_testandset_fail cmp cmp
1146 thecmd_testandset_fail mkdir mkdir
1147 thecmd_testandset_fail mv mv
1149 thecmd_testandset_fail sed sed
1150 thecmd_testandset_fail sort sort
1151 thecmd_testandset_fail tee tee
1153 thecmd_testandset chown chown ||
1154 PATH="/sbin:${PATH}" thecmd_set chown chown ||
1155 PATH="/usr/sbin:${PATH}" thecmd_set_fail chown chown
1157 thecmd_testandset_fail MAKE make
1160 thecmd_testandset strip strip && HAVE_STRIP=1 || HAVE_STRIP=0
1162 # For ./cc-test.sh only
1163 thecmd_testandset_fail cksum cksum
1165 # Update OPT_ options now, in order to get possible inter-dependencies right
1168 # (No functions since some shells loose non-exported variables in traps)
1169 trap "trap \"\" HUP INT TERM; exit 1" HUP INT TERM
1170 trap "trap \"\" HUP INT TERM EXIT;\
1171 ${rm} -rf ${newlst} ${tmp0}.* ${tmp0}* ${newmk} ${newev} ${newh}" EXIT
1173 # Our configuration options may at this point still contain shell snippets,
1174 # we need to evaluate them in order to get them expanded, and we need those
1175 # evaluated values not only in our new configuration file, but also at hand..
1176 msg_nonl 'Evaluating all configuration items ... '
1180 # Add the known utility and some other variables
1181 printf "#define VAL_UAGENT \"${VAL_SID}${VAL_MAILX}\"\n" >> ${newh}
1182 printf "VAL_UAGENT = ${VAL_SID}${VAL_MAILX}\n" >> ${newmk}
1184 printf "#define VAL_PRIVSEP \"${VAL_SID}${VAL_MAILX}-privsep\"\n" >> ${newh}
1185 printf "VAL_PRIVSEP = \$(VAL_UAGENT)-privsep\n" >> ${newmk}
1186 if feat_yes DOTLOCK; then
1187 printf "OPTIONAL_PRIVSEP = \$(VAL_PRIVSEP)\n" >> ${newmk}
1189 printf "OPTIONAL_PRIVSEP =\n" >> ${newmk}
1194 awk basename cat chmod chown cp cmp grep mkdir mv rm sed sort tee tr \
1195 MAKE MAKEFLAGS make SHELL strip \
1198 printf "${i} = ${j}\n" >> ${newmk}
1199 printf "${i}=${j}\n" >> ${newlst}
1200 printf "${i}=\"${j}\";export ${i}; " >> ${newev}
1202 printf "\n" >> ${newev}
1204 # Build a basic set of INCS and LIBS according to user environment.
1205 C_INCLUDE_PATH="${CWDDIR}:${SRCDIR}:${C_INCLUDE_PATH}"
1206 path_check C_INCLUDE_PATH -I _INCS
1207 INCS="${INCS} ${_INCS}"
1208 path_check LD_LIBRARY_PATH -L _LIBS
1209 LIBS="${LIBS} ${_LIBS}"
1211 export C_INCLUDE_PATH LD_LIBRARY_PATH
1213 # Some environments need runtime path flags to be able to go at all
1216 ## Detect CC, whether we can use it, and possibly which CFLAGS we can use
1220 ${cat} > ${tmp}.c << \!
1223 static void doit(char const *s);
1225 main(int argc, char **argv){
1228 doit("Hello world");
1232 doit(char const *s){
1234 memcpy(buf, s, strlen(s) +1);
1239 if "${CC}" ${INCS} ${CFLAGS} ${EXTRA_CFLAGS} ${LDFLAGS} ${EXTRA_LDFLAGS} \
1240 -o ${tmp2} ${tmp}.c ${LIBS}; then
1243 msg 'ERROR: i cannot compile a "Hello world" via'
1245 "${CC} ${INCS} ${CFLAGS} ${EXTRA_CFLAGS} ${LDFLAGS} ${EXTRA_LDFLAGS} ${LIBS}"
1246 msg 'ERROR: Please read INSTALL, rerun'
1250 # This may also update ld_runtime_flags() (again)
1257 printf -- "${i}=${j}\n" >> ${newlst}
1263 PATH C_INCLUDE_PATH LD_LIBRARY_PATH \
1267 printf -- "${i} = ${j}\n" >> ${newmk}
1268 printf -- "${i}=${j}\n" >> ${newlst}
1271 # Now finally check whether we already have a configuration and if so, whether
1272 # all those parameters are still the same.. or something has actually changed
1273 if [ -f ${lst} ] && ${cmp} ${newlst} ${lst} >/dev/null 2>&1; then
1274 echo 'Configuration is up-to-date'
1276 elif [ -f ${lst} ]; then
1277 echo 'Configuration has been updated..'
1278 ( eval "${MAKE} -f ./mk-config.mk clean" )
1281 echo 'Shiny configuration..'
1284 # Time to redefine helper 1
1286 ${rm} -f ${lst} ${h} ${mk}
1290 ${mv} -f ${newlst} ${lst}
1291 ${mv} -f ${newev} ${ev}
1292 ${mv} -f ${newh} ${h}
1293 ${mv} -f ${newmk} ${mk}
1295 if [ -z "${VERBOSE}" ]; then
1296 printf -- "ECHO_CC = @echo ' 'CC \$(@);\n" >> ${mk}
1297 printf -- "ECHO_LINK = @echo ' 'LINK \$(@);\n" >> ${mk}
1298 printf -- "ECHO_GEN = @echo ' 'GEN \$(@);\n" >> ${mk}
1299 printf -- "ECHO_TEST = @\n" >> ${mk}
1300 printf -- "ECHO_CMD = @echo ' CMD';\n" >> ${mk}
1301 printf -- "ECHO_BLOCK_BEGIN = @( \n" >> ${mk}
1302 printf -- "ECHO_BLOCK_END = ) >/dev/null\n" >> ${mk}
1305 ## Compile and link checking
1311 makefile=./${tmp0}.mk
1313 # (No function since some shells loose non-exported variables in traps)
1314 trap "trap \"\" HUP INT TERM;\
1315 ${rm} -f ${lst} ${h} ${mk} ${lib} ${inc}; exit 1" HUP INT TERM
1316 trap "trap \"\" HUP INT TERM EXIT;\
1317 ${rm} -rf ${tmp0}.* ${tmp0}*" EXIT
1319 # Time to redefine helper 2
1323 printf "*** ${fmt}\\n" "${@}"
1324 printf -- "${fmt}\\n" "${@}" >&5
1329 printf "*** ${fmt}\\n" "${@}"
1330 printf -- "${fmt}" "${@}" >&5
1334 exec 5>&2 > ${log} 2>&1
1336 echo "${LIBS}" > ${lib}
1337 echo "${INCS}" > ${inc}
1338 ${cat} > ${makefile} << \!
1339 .SUFFIXES: .o .c .x .y
1341 $(CC) -I./ $(XINCS) $(CFLAGS) -c $(<)
1343 $(CC) -I./ $(XINCS) -E $(<) > $(@)
1345 $(CC) -I./ $(XINCS) $(CFLAGS) $(LDFLAGS) -o $(@) $(<) $(XLIBS)
1350 # May be multiline..
1352 [ -n "${OS_DEFINES}" ] && printf -- "${OS_DEFINES}" >> ${h}
1353 echo '#define VAL_BUILD_OS "'"${OS}"'"' >> ${h}
1354 echo '#define VAL_BUILD_OSENV "'"${OSENV}"'"' >> ${h}
1356 # Generate n_err_number OS mappings
1359 feat_yes DEVEL && NV= || NV=noverbose
1360 SRCDIR="${SRCDIR}" TARGET="${h}" awk="${awk}" \
1361 ${SHELL} "${SRCDIR}"make-errors.sh ${NV} config
1362 ) | xrun_check oserrno 'OS error mapping table generated' || config_exit 1
1365 feat_def ALWAYS_UNICODE_LOCALE
1366 feat_def AMALGAMATION
1367 feat_def CROSS_BUILD
1371 feat_def ASAN_ADDRESS
1372 feat_def ASAN_MEMORY
1378 if xrun_check inline 'inline functions' \
1379 '#define HAVE_INLINE
1380 #define n_INLINE static inline' << \!
1381 static inline int ilf(int i){return ++i;}
1382 int main(void){return ilf(-1);}
1386 elif xrun_check inline 'inline functions (via __inline)' \
1387 '#define HAVE_INLINE
1388 #define n_INLINE static __inline' << \!
1389 static __inline int ilf(int i){return ++i;}
1390 int main(void){return ilf(-1);}
1396 ## Test for "basic" system-calls / functionality that is used by all parts
1397 ## of our program. Once this is done fork away BASE_LIBS and other BASE_*
1398 ## macros to be used by only the subprograms (potentially).
1400 if run_check clock_gettime 'clock_gettime(2)' \
1401 '#define HAVE_CLOCK_GETTIME' << \!
1407 if(!clock_gettime(CLOCK_REALTIME, &ts) || errno != ENOSYS)
1414 elif run_check clock_gettime 'clock_gettime(2) (via -lrt)' \
1415 '#define HAVE_CLOCK_GETTIME' '-lrt' << \!
1421 if(!clock_gettime(CLOCK_REALTIME, &ts) || errno != ENOSYS)
1428 elif run_check gettimeofday 'gettimeofday(2)' \
1429 '#define HAVE_GETTIMEOFDAY' << \!
1430 #include <stdio.h> /* For C89 NULL */
1431 #include <sys/time.h>
1436 if(!gettimeofday(&tv, NULL) || errno != ENOSYS)
1444 have_no_subsecond_time=1
1447 if run_check nanosleep 'nanosleep(2)' \
1448 '#define HAVE_NANOSLEEP' << \!
1455 ts.tv_nsec = 100000;
1456 if(!nanosleep(&ts, NULL) || errno != ENOSYS)
1463 elif run_check nanosleep 'nanosleep(2) (via -lrt)' \
1464 '#define HAVE_NANOSLEEP' '-lrt' << \!
1471 ts.tv_nsec = 100000;
1472 if(!nanosleep(&ts, NULL) || errno != ENOSYS)
1479 # link_check is enough for this, that function is so old, trust the proto
1480 elif link_check sleep 'sleep(3)' \
1481 '#define HAVE_SLEEP' << \!
1485 if(!sleep(1) || errno != ENOSYS)
1493 msg 'ERROR: we require one of nanosleep(2) and sleep(3).'
1497 if run_check userdb 'gete?[gu]id(2), getpwuid(3), getpwnam(3)' << \!
1506 if((gid = getgid()) != 0)
1508 if((uid = getuid()) != 0)
1510 if((pw = getpwuid(uid)) == NULL && errno == ENOSYS)
1512 if((pw = getpwnam("root")) == NULL && errno == ENOSYS)
1520 msg 'ERROR: we require user and group info / database searches.'
1521 msg 'That much Unix we indulge ourselfs.'
1525 if link_check ftruncate 'ftruncate(2)' \
1526 '#define HAVE_FTRUNCATE' << \!
1528 #include <sys/types.h>
1530 return (ftruncate(0, 0) != 0);
1536 msg 'ERROR: we require the ftruncate(2) system call.'
1540 if run_check sa_restart 'SA_RESTART (for sigaction(2))' << \!
1544 struct sigaction nact, oact;
1546 nact.sa_handler = SIG_DFL;
1547 sigemptyset(&nact.sa_mask);
1548 nact.sa_flags = SA_RESTART;
1549 return !(!sigaction(SIGCHLD, &nact, &oact) || errno != ENOSYS);
1555 msg 'ERROR: we (yet) require the SA_RESTART flag for sigaction(2).'
1559 if link_check snprintf 'snprintf(3)' << \!
1564 snprintf(b, sizeof b, "%s", "string");
1571 msg 'ERROR: we require the snprintf(3) function.'
1575 if link_check environ 'environ(3)' << \!
1576 #include <stdio.h> /* For C89 NULL */
1578 extern char **environ;
1580 return environ[0] == NULL;
1586 msg 'ERROR: we require the environ(3) array for subprocess control.'
1590 if link_check setenv '(un)?setenv(3)' '#define HAVE_SETENV' << \!
1593 setenv("s-mailx", "i want to see it cute!", 1);
1594 unsetenv("s-mailx");
1600 elif link_check setenv 'putenv(3)' '#define HAVE_PUTENV' << \!
1603 putenv("s-mailx=i want to see it cute!");
1610 msg 'ERROR: we require either the setenv(3) or putenv(3) functions.'
1614 if link_check termios 'termios.h and tc*(3) family' << \!
1615 #include <termios.h>
1617 struct termios tios;
1619 tcgetattr(0, &tios);
1620 tcsetattr(0, TCSANOW | TCSADRAIN | TCSAFLUSH, &tios);
1627 msg 'ERROR: we require termios.h and the tc*() family of functions.'
1628 msg 'That much Unix we indulge ourselfs.'
1634 if link_check vsnprintf 'vsnprintf(3)' << \!
1637 static void dome(char *buf, size_t blen, ...){
1641 vsnprintf(buf, blen, "%s", ap);
1647 dome(b, sizeof b, "string");
1654 feat_bail_required ERRORS
1657 if [ "${have_vsnprintf}" = yes ]; then
1659 link_check va_copy "va_copy(3) (as ${2})" \
1660 "#define HAVE_N_VA_COPY
1661 #define n_va_copy ${2}" <<_EOT
1665 # if defined __va_copy && !defined va_copy
1666 # define va_copy __va_copy
1669 static void dome2(char *buf, size_t blen, va_list src){
1673 vsnprintf(buf, blen, "%s", ap);
1676 static void dome(char *buf, size_t blen, ...){
1680 dome2(buf, blen, ap);
1686 dome(b, sizeof b, "string");
1691 __va_copy 0 va_copy || __va_copy 1 __va_copy
1694 run_check pathconf 'f?pathconf(2)' '#define HAVE_PATHCONF' << \!
1701 rv |= !(pathconf(".", _PC_NAME_MAX) >= 0 || errno == 0 || errno != ENOSYS);
1703 rv |= !(pathconf(".", _PC_PATH_MAX) >= 0 || errno == 0 || errno != ENOSYS);
1705 /* Only link check */
1706 fpathconf(0, _PC_NAME_MAX);
1712 run_check pipe2 'pipe2(2)' '#define HAVE_PIPE2' << \!
1719 if(!pipe2(fds, O_CLOEXEC) || errno != ENOSYS)
1725 # We use this only then for now (need NOW+1)
1726 run_check utimensat 'utimensat(2)' '#define HAVE_UTIMENSAT' << \!
1727 #include <fcntl.h> /* For AT_* */
1728 #include <sys/stat.h>
1731 struct timespec ts[2];
1733 ts[0].tv_nsec = UTIME_NOW;
1734 ts[1].tv_nsec = UTIME_OMIT;
1735 if(!utimensat(AT_FDCWD, "", ts, 0) || errno != ENOSYS)
1743 # XXX Add POSIX check once standardized
1744 if link_check posix_random 'arc4random(3)' '#define HAVE_POSIX_RANDOM 0' << \!
1753 elif link_check getrandom 'getrandom(2) (in sys/random.h)' \
1754 '#define HAVE_GETRANDOM(B,S) getrandom(B, S, 0)
1755 #define HAVE_GETRANDOM_HEADER <sys/random.h>' <<\!
1756 #include <sys/random.h>
1759 getrandom(buf, sizeof buf, 0);
1765 elif link_check getrandom 'getrandom(2) (via syscall(2))' \
1766 '#define HAVE_GETRANDOM(B,S) syscall(SYS_getrandom, B, S, 0)
1767 #define HAVE_GETRANDOM_HEADER <sys/syscall.h>' <<\!
1768 #include <sys/syscall.h>
1771 syscall(SYS_getrandom, buf, sizeof buf, 0);
1777 elif [ -n "${have_no_subsecond_time}" ]; then
1778 msg 'ERROR: %s %s' 'without a native random' \
1779 'one of clock_gettime(2) and gettimeofday(2) is required.'
1784 link_check putc_unlocked 'putc_unlocked(3)' '#define HAVE_PUTC_UNLOCKED' <<\!
1787 putc_unlocked('@', stdout);
1792 link_check fchdir 'fchdir(3)' '#define HAVE_FCHDIR' << \!
1800 if run_check realpath 'realpath(3)' '#define HAVE_REALPATH' << \!
1803 char x_buf[4096], *x = realpath(".", x_buf);
1805 return (x != NULL) ? 0 : 1;
1809 if run_check realpath_malloc 'realpath(3) takes NULL' \
1810 '#define HAVE_REALPATH_NULL' << \!
1813 char *x = realpath(".", NULL);
1817 return (x != NULL) ? 0 : 1;
1825 ## optional and selectable
1827 if feat_yes DOTLOCK; then
1828 if run_check readlink 'readlink(2)' << \!
1834 if(!readlink("here", buf, sizeof buf) || errno != ENOSYS)
1842 feat_bail_required DOTLOCK
1846 if feat_yes DOTLOCK; then
1847 if run_check fchown 'fchown(2)' << \!
1851 if(!fchown(0, 0, 0) || errno != ENOSYS)
1859 feat_bail_required DOTLOCK
1863 ## Now it is the time to fork away the BASE_ series
1866 squeeze_em ${inc} ${tmp}
1868 squeeze_em ${lib} ${tmp}
1871 echo "BASE_LIBS = `${cat} ${lib}`" >> ${mk}
1872 echo "BASE_INCS = `${cat} ${inc}`" >> ${mk}
1874 ## The remains are expected to be used only by the main MUA binary!
1877 link_check setlocale 'setlocale(3)' '#define HAVE_SETLOCALE' << \!
1880 setlocale(LC_ALL, "");
1884 [ -n "${have_setlocale}" ] && OPT_LOCALES=1
1886 OPT_MULTIBYTE_CHARSETS=0
1888 OPT_TERMINAL_CHARSET=0
1889 if [ -n "${have_setlocale}" ]; then
1890 link_check c90amend1 'ISO/IEC 9899:1990/Amendment 1:1995' \
1891 '#define HAVE_C90AMEND1' << \!
1897 char mbb[MB_LEN_MAX + 1];
1902 mbtowc(&wc, "x
", 1);
1903 mbrtowc(&wc, "x
", 1, NULL);
1905 return (mblen("\
0", 1) == 0);
1908 [ -n "${have_c90amend1}" ] && OPT_MULTIBYTE_CHARSETS=1
1910 if [ -n "${have_c90amend1}" ]; then
1911 link_check wcwidth 'wcwidth(3)' '#define HAVE_WCWIDTH' << \!
1918 [ -n "${have_wcwidth}" ] && OPT_WIDE_GLYPHS=1
1921 link_check nl_langinfo 'nl_langinfo(3)' '#define HAVE_NL_LANGINFO' << \!
1922 #include <langinfo.h>
1926 return (nl_langinfo(CODESET) == NULL);
1929 [ -n "${have_nl_langinfo}" ] && OPT_TERMINAL_CHARSET=1
1932 link_check fnmatch 'fnmatch(3)' '#define HAVE_FNMATCH' << \!
1933 #include <fnmatch.h>
1935 return (fnmatch("*", ".
", FNM_PATHNAME | FNM_PERIOD) == FNM_NOMATCH);
1939 link_check dirent_d_type 'struct dirent.d_type' '#define HAVE_DIRENT_TYPE' << \!
1943 return !(de.d_type == DT_UNKNOWN ||
1944 de.d_type == DT_DIR || de.d_type == DT_LNK);
1948 ## optional and selectable
1950 if feat_yes ICONV; then
1951 ${cat} > ${tmp2}.c << \!
1952 #include <stdio.h> /* For C89 NULL */
1957 id = iconv_open("foo
", "bar
");
1958 iconv(id, NULL, NULL, NULL, NULL);
1963 < ${tmp2}.c link_check iconv 'iconv(3) functionality' \
1964 '#define HAVE_ICONV' ||
1965 < ${tmp2}.c link_check iconv 'iconv(3) functionality (via -liconv)' \
1966 '#define HAVE_ICONV' '-liconv' ||
1967 feat_bail_required ICONV
1969 echo '/* OPT_ICONV=0 */' >> ${h}
1972 if feat_yes SOCKETS || feat_yes SPAM_SPAMD; then
1973 ${cat} > ${tmp2}.c << \!
1974 #include <sys/types.h>
1975 #include <sys/socket.h>
1979 struct sockaddr_un soun;
1981 if(socket(AF_UNIX, SOCK_STREAM, 0) == -1 && errno == ENOSYS)
1983 if(connect(0, (struct sockaddr*)&soun, 0) == -1 && errno == ENOSYS)
1985 if(shutdown(0, SHUT_RD | SHUT_WR | SHUT_RDWR) == -1 && errno == ENOSYS)
1991 < ${tmp2}.c run_check af_unix 'AF_UNIX sockets' \
1992 '#define HAVE_UNIX_SOCKETS' ||
1993 < ${tmp2}.c run_check af_unix 'AF_UNIX sockets (via -lnsl)' \
1994 '#define HAVE_UNIX_SOCKETS' '-lnsl' ||
1995 < ${tmp2}.c run_check af_unix 'AF_UNIX sockets (via -lsocket -lnsl)' \
1996 '#define HAVE_UNIX_SOCKETS' '-lsocket -lnsl'
1999 if feat_yes SOCKETS; then
2000 ${cat} > ${tmp2}.c << \!
2001 #include <sys/types.h>
2002 #include <sys/socket.h>
2003 #include <netinet/in.h>
2008 if(socket(AF_INET, SOCK_STREAM, 0) == -1 && errno == ENOSYS)
2010 if(connect(0, &s, 0) == -1 && errno == ENOSYS)
2016 < ${tmp2}.c run_check sockets 'sockets' \
2017 '#define HAVE_SOCKETS' ||
2018 < ${tmp2}.c run_check sockets 'sockets (via -lnsl)' \
2019 '#define HAVE_SOCKETS' '-lnsl' ||
2020 < ${tmp2}.c run_check sockets 'sockets (via -lsocket -lnsl)' \
2021 '#define HAVE_SOCKETS' '-lsocket -lnsl' ||
2022 feat_bail_required SOCKETS
2024 echo '/* OPT_SOCKETS=0 */' >> ${h}
2025 fi # feat_yes SOCKETS
2027 if feat_yes SOCKETS; then
2028 link_check getaddrinfo 'getaddrinfo(3)' \
2029 '#define HAVE_GETADDRINFO' << \!
2030 #include <sys/types.h>
2031 #include <sys/socket.h>
2035 struct addrinfo a, *ap;
2038 switch((lrv = getaddrinfo("foo
", "0", &a, &ap))){
2042 fprintf(stderr, "%s
\n", gai_strerror(lrv));
2051 if feat_yes SOCKETS && [ -z "${have_getaddrinfo}" ]; then
2052 compile_check arpa_inet_h '<arpa/inet.h>' \
2053 '#define HAVE_ARPA_INET_H' << \!
2054 #include <sys/types.h>
2055 #include <sys/socket.h>
2057 #include <netinet/in.h>
2058 #include <arpa/inet.h>
2061 ${cat} > ${tmp2}.c << \!
2062 #include <sys/types.h>
2063 #include <sys/socket.h>
2067 #include <netinet/in.h>
2068 #ifdef HAVE_ARPA_INET_H
2069 #include <arpa/inet.h>
2072 struct sockaddr_in servaddr;
2073 unsigned short portno;
2076 struct in_addr **pptr;
2079 if((ep = getservbyname("POPPY-PORT
", "tcp
")) != NULL)
2080 portno = (unsigned short)ep->s_port;
2082 if((hp = gethostbyname("POPPY-HOST
")) != NULL){
2083 pptr = (struct in_addr**)hp->h_addr_list;
2084 if(hp->h_addrtype != AF_INET)
2085 fprintf(stderr, "au
\n");
2088 case HOST_NOT_FOUND:
2094 fprintf(stderr, "au
\n");
2099 memset(&servaddr, 0, sizeof servaddr);
2100 servaddr.sin_family = AF_INET;
2101 servaddr.sin_port = htons(portno);
2102 memcpy(&servaddr.sin_addr, *pptr, sizeof(struct in_addr));
2103 fprintf(stderr, "Would connect to
%s
:%d ...
\n",
2104 inet_ntoa(**pptr), (int)portno);
2109 < ${tmp2}.c link_check gethostbyname 'get(serv|host)byname(3)' ||
2110 < ${tmp2}.c link_check gethostbyname \
2111 'get(serv|host)byname(3) (via -nsl)' '' '-lnsl' ||
2112 < ${tmp2}.c link_check gethostbyname \
2113 'get(serv|host)byname(3) (via -lsocket -nsl)' \
2114 '' '-lsocket -lnsl' ||
2115 feat_bail_required SOCKETS
2119 run_check setsockopt 'setsockopt(2)' '#define HAVE_SETSOCKOPT' << \!
2120 #include <sys/socket.h>
2126 if(setsockopt(sockfd, SOL_SOCKET, SO_KEEPALIVE, NULL, 0) == -1 &&
2133 feat_yes SOCKETS && [ -n "${have_setsockopt}" ] &&
2134 link_check so_sndtimeo 'SO_SNDTIMEO' '#define HAVE_SO_SNDTIMEO' << \!
2135 #include <sys/socket.h>
2143 setsockopt(sockfd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof tv);
2144 setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof tv);
2149 feat_yes SOCKETS && [ -n "${have_setsockopt}" ] &&
2150 link_check so_linger 'SO_LINGER' '#define HAVE_SO_LINGER' << \!
2151 #include <sys/socket.h>
2159 setsockopt(sockfd, SOL_SOCKET, SO_LINGER, &li, sizeof li);
2165 if feat_yes SSL; then # {{{
2166 # {{{ LibreSSL decided to define OPENSSL_VERSION_NUMBER with a useless value
2167 # instead of keeping it at the one that corresponds to the OpenSSL at fork
2168 # time: we need to test it first in order to get things right
2169 if compile_check _xssl 'TLS/SSL (LibreSSL)' \
2172 #define HAVE_XSSL_RESSL
2173 #define HAVE_XSSL_OPENSSL 0' << \!
2174 #include <openssl/opensslv.h>
2175 #ifdef LIBRESSL_VERSION_NUMBER
2182 VAL_SSL_FEATURES=libressl
2183 # TODO OPENSSL_IS_BORINGSSL, but never tried that one!
2184 elif compile_check _xssl 'TLS/SSL (OpenSSL >= v1.1.0)' \
2187 #define HAVE_XSSL_OPENSSL 0x10100' << \!
2188 #include <openssl/opensslv.h>
2189 #if OPENSSL_VERSION_NUMBER + 0 >= 0x10100000L
2196 VAL_SSL_FEATURES=libssl-0x10100
2197 elif compile_check _xssl 'TLS/SSL (OpenSSL)' \
2200 #define HAVE_XSSL_OPENSSL 0x10000' << \!
2201 #include <openssl/opensslv.h>
2202 #ifdef OPENSSL_VERSION_NUMBER
2209 VAL_SSL_FEATURES=libssl-0x10000
2211 feat_bail_required SSL
2214 if feat_yes SSL; then # {{{
2215 if [ -n "${ossl_v1_1}" ]; then
2216 without_check yes xssl 'TLS/SSL new style TLS_client_method(3ssl)' \
2217 '#define n_XSSL_CLIENT_METHOD TLS_client_method' \
2219 elif link_check xssl 'TLS/SSL new style TLS_client_method(3ssl)' \
2220 '#define n_XSSL_CLIENT_METHOD TLS_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 #ifdef OPENSSL_NO_TLS1 /* TODO only deduced from OPENSSL_NO_SSL[23]! */
2228 # error We need TLSv1.
2231 SSL_CTX *ctx = SSL_CTX_new(TLS_client_method());
2234 PEM_read_PrivateKey(0, 0, 0, 0);
2240 elif link_check xssl 'TLS/SSL old style SSLv23_client_method(3ssl)' \
2241 '#define n_XSSL_CLIENT_METHOD SSLv23_client_method' \
2242 '-lssl -lcrypto' << \!
2243 #include <openssl/ssl.h>
2244 #include <openssl/err.h>
2245 #include <openssl/x509v3.h>
2246 #include <openssl/x509.h>
2247 #include <openssl/rand.h>
2248 #if defined OPENSSL_NO_SSL3 &&\
2249 defined OPENSSL_NO_TLS1 /* TODO only deduced from OPENSSL_NO_SSL[23]! */
2250 # error We need one of SSLv3 and TLSv1.
2253 SSL_CTX *ctx = SSL_CTX_new(SSLv23_client_method());
2256 PEM_read_PrivateKey(0, 0, 0, 0);
2263 feat_bail_required SSL
2267 if feat_yes SSL; then # {{{
2268 if feat_yes SSL_ALL_ALGORITHMS; then
2269 if [ -n "${ossl_v1_1}" ]; then
2270 without_check yes ssl_all_algo 'TLS/SSL all-algorithms support' \
2271 '#define HAVE_SSL_ALL_ALGORITHMS'
2272 elif link_check ssl_all_algo 'TLS/SSL all-algorithms support' \
2273 '#define HAVE_SSL_ALL_ALGORITHMS' << \!
2274 #include <openssl/evp.h>
2276 OpenSSL_add_all_algorithms();
2277 EVP_get_cipherbyname("two cents i never exist
");
2285 feat_bail_required SSL_ALL_ALGORITHMS
2287 elif [ -n "${ossl_v1_1}" ]; then
2288 without_check yes ssl_all_algo \
2289 'TLS/SSL all-algorithms (always available in v1.1.0+)' \
2290 '#define HAVE_SSL_ALL_ALGORITHMS'
2293 if [ -n "${ossl_v1_1}" ]; then
2294 without_check yes xssl_stack_of 'TLS/SSL STACK_OF()' \
2295 '#define HAVE_XSSL_STACK_OF'
2296 elif compile_check xssl_stack_of 'TLS/SSL STACK_OF()' \
2297 '#define HAVE_XSSL_STACK_OF' << \!
2298 #include <stdio.h> /* For C89 NULL */
2299 #include <openssl/ssl.h>
2300 #include <openssl/err.h>
2301 #include <openssl/x509v3.h>
2302 #include <openssl/x509.h>
2303 #include <openssl/rand.h>
2305 STACK_OF(GENERAL_NAME) *gens = NULL;
2307 printf("%p
", gens); /* to use it */
2315 if [ -n "${ossl_v1_1}" ]; then
2316 without_check yes xssl_conf 'TLS/SSL OpenSSL_modules_load_file(3ssl)' \
2317 '#define HAVE_XSSL_CONFIG'
2318 VAL_SSL_FEATURES="${VAL_SSL_FEATURES},+modules-load-file
"
2319 elif link_check xssl_conf \
2320 'TLS/SSL OpenSSL_modules_load_file(3ssl) support' \
2321 '#define HAVE_XSSL_CONFIG' << \!
2322 #include <stdio.h> /* For C89 NULL */
2323 #include <openssl/conf.h>
2325 CONF_modules_load_file(NULL, NULL, CONF_MFLAGS_IGNORE_MISSING_FILE);
2326 CONF_modules_free();
2331 VAL_SSL_FEATURES="${VAL_SSL_FEATURES},+modules-load-file
"
2333 VAL_SSL_FEATURES="${VAL_SSL_FEATURES},-modules-load-file"
2336 if [ -n "${ossl_v1_1}" ]; then
2337 without_check yes xssl_conf_ctx 'TLS/SSL SSL_CONF_CTX support' \
2338 '#define HAVE_XSSL_CONF_CTX'
2339 VAL_SSL_FEATURES="${VAL_SSL_FEATURES},+conf-ctx
"
2340 elif link_check xssl_conf_ctx 'TLS/SSL SSL_CONF_CTX support' \
2341 '#define HAVE_XSSL_CONF_CTX' << \!
2342 #include <openssl/ssl.h>
2343 #include <openssl/err.h>
2345 SSL_CTX *ctx = SSL_CTX_new(n_XSSL_CLIENT_METHOD());
2346 SSL_CONF_CTX *cctx = SSL_CONF_CTX_new();
2348 SSL_CONF_CTX_set_flags(cctx,
2349 SSL_CONF_FLAG_FILE | SSL_CONF_FLAG_CLIENT |
2350 SSL_CONF_FLAG_CERTIFICATE | SSL_CONF_FLAG_SHOW_ERRORS);
2351 SSL_CONF_CTX_set_ssl_ctx(cctx, ctx);
2352 SSL_CONF_cmd(cctx, "Protocol
", "ALL
");
2353 SSL_CONF_CTX_finish(cctx);
2354 SSL_CONF_CTX_free(cctx);
2360 VAL_SSL_FEATURES="${VAL_SSL_FEATURES},+conf-ctx
"
2362 VAL_SSL_FEATURES="${VAL_SSL_FEATURES},-conf-ctx"
2365 if [ -n "${ossl_v1_1}" ]; then
2366 without_check yes xssl_ctx_config 'TLS/SSL SSL_CTX_config(3ssl)' \
2367 '#define HAVE_XSSL_CTX_CONFIG'
2368 VAL_SSL_FEATURES="${VAL_SSL_FEATURES},+ctx-config
"
2369 elif [ -n "${have_xssl_conf}" ] && [ -n "${have_xssl_conf_ctx}" ] &&
2370 link_check xssl_ctx_config 'TLS/SSL SSL_CTX_config(3ssl)' \
2371 '#define HAVE_XSSL_CTX_CONFIG' << \!
2372 #include <stdio.h> /* For C89 NULL */
2373 #include <openssl/ssl.h>
2375 SSL_CTX_config(NULL, "SOMEVAL
");
2380 VAL_SSL_FEATURES="${VAL_SSL_FEATURES},+ctx-config
"
2382 VAL_SSL_FEATURES="${VAL_SSL_FEATURES},-ctx-config"
2385 if [ -n "${ossl_v1_1}" ] && [ -n "${have_xssl_conf_ctx}" ]; then
2386 without_check yes xssl_set_maxmin_proto \
2387 'TLS/SSL SSL_CTX_set_min_proto_version(3ssl)' \
2388 '#define HAVE_XSSL_SET_MIN_PROTO_VERSION'
2389 VAL_SSL_FEATURES="${VAL_SSL_FEATURES},+ctx-set-maxmin-proto
"
2390 elif link_check xssl_set_maxmin_proto \
2391 'TLS/SSL SSL_CTX_set_min_proto_version(3ssl)' \
2392 '#define HAVE_XSSL_SET_MIN_PROTO_VERSION' << \!
2393 #include <stdio.h> /* For C89 NULL */
2394 #include <openssl/ssl.h>
2396 SSL_CTX_set_min_proto_version(NULL, 0);
2397 SSL_CTX_set_max_proto_version(NULL, 10);
2402 VAL_SSL_FEATURES="${VAL_SSL_FEATURES},+ctx-set-maxmin-proto
"
2404 VAL_SSL_FEATURES="${VAL_SSL_FEATURES},-ctx-set-maxmin-proto"
2407 if link_check xssl_rand_egd 'TLS/SSL RAND_egd(3ssl)' \
2408 '#define HAVE_XSSL_RAND_EGD' << \!
2409 #include <openssl/rand.h>
2411 return RAND_egd("some.where
") > 0;
2415 VAL_SSL_FEATURES="${VAL_SSL_FEATURES},+rand-egd
"
2417 VAL_SSL_FEATURES="${VAL_SSL_FEATURES},-rand-egd"
2419 fi # feat_yes SSL }}}
2421 if feat_yes SSL && feat_yes MD5 && feat_no NOEXTMD5; then # {{{
2422 run_check ssl_md5 'MD5 digest in the used crypto library' \
2423 '#define HAVE_XSSL_MD5' << \!
2426 #include <openssl/md5.h>
2428 char const dat[] = "abrakadabrafidibus
";
2429 char dig[16], hex[16 * 2];
2433 memset(dig, 0, sizeof(dig));
2434 memset(hex, 0, sizeof(hex));
2436 MD5_Update(&ctx, dat, sizeof(dat) - 1);
2437 MD5_Final(dig, &ctx);
2439 #define hexchar(n) ((n) > 9 ? (n) - 10 + 'a' : (n) + '0')
2440 for(i = 0; i < sizeof(hex) / 2; i++){
2442 hex[j] = hexchar((dig[i] & 0xf0) >> 4);
2443 hex[++j] = hexchar(dig[i] & 0x0f);
2445 return !!memcmp("6d7d0a3d949da2e96f2aa010f65d8326
", hex, sizeof(hex));
2450 echo '/* OPT_SSL=0 */' >> ${h}
2451 fi # }}} feat_yes SSL
2452 printf '#define VAL_SSL_FEATURES "#'"${VAL_SSL_FEATURES}"'"\n' >> ${h}
2454 if [ "${have_xssl}" = yes ]; then
2465 if feat_yes GSSAPI
; then
2466 ${cat} > ${tmp2}.c
<< \
!
2467 #include <gssapi/gssapi.h>
2469 gss_import_name
(0, 0, GSS_C_NT_HOSTBASED_SERVICE
, 0);
2470 gss_init_sec_context
(0,0,0,0,0,0,0,0,0,0,0,0,0);
2474 ${sed} -e '1s/gssapi\///' < ${tmp2}.c > ${tmp3}.c
2476 if acmd_set i krb5-config
; then
2477 GSS_LIBS
="`CFLAGS= ${i} --libs gssapi`"
2478 GSS_INCS
="`CFLAGS= ${i} --cflags`"
2479 i
='GSS-API via krb5-config(1)'
2483 i
='GSS-API in gssapi/gssapi.h, libgssapi'
2485 if < ${tmp2}.c link_check gss \
2486 "${i}" '#define HAVE_GSSAPI' "${GSS_LIBS}" "${GSS_INCS}" ||\
2487 < ${tmp3}.c link_check gss \
2488 'GSS-API in gssapi.h, libgssapi' \
2489 '#define HAVE_GSSAPI
2490 #define GSSAPI_REG_INCLUDE' \
2492 < ${tmp2}.c link_check gss
'GSS-API in libgssapi_krb5' \
2493 '#define HAVE_GSSAPI' \
2495 < ${tmp3}.c link_check gss \
2496 'GSS-API in libgssapi, OpenBSD-style (pre 5.3)' \
2497 '#define HAVE_GSSAPI
2498 #define GSS_REG_INCLUDE' \
2499 '-lgssapi -lkrb5 -lcrypto' \
2500 '-I/usr/include/kerberosV' ||\
2501 < ${tmp2}.c link_check gss
'GSS-API in libgss' \
2502 '#define HAVE_GSSAPI' \
2504 link_check gss
'GSS-API in libgssapi_krb5, old-style' \
2505 '#define HAVE_GSSAPI
2506 #define GSSAPI_OLD_STYLE' \
2507 '-lgssapi_krb5' << \
!
2508 #include <gssapi/gssapi.h>
2509 #include <gssapi/gssapi_generic.h>
2511 gss_import_name
(0, 0, gss_nt_service_name
, 0);
2512 gss_init_sec_context
(0,0,0,0,0,0,0,0,0,0,0,0,0);
2519 feat_bail_required GSSAPI
2522 echo '/* OPT_GSSAPI=0 */' >> ${h}
2523 fi # feat_yes GSSAPI
2528 if feat_yes IDNA
; then
2529 if link_check idna
'GNU Libidn' '#define HAVE_IDNA HAVE_IDNA_LIBIDNA' \
2532 #include <idn-free.h>
2533 #include <stringprep.h>
2535 char
*utf8
, *idna_ascii
, *idna_utf8
;
2537 utf8
= stringprep_locale_to_utf8
("does.this.work");
2538 if (idna_to_ascii_8z
(utf8
, &idna_ascii
, IDNA_USE_STD3_ASCII_RULES
)
2541 idn_free
(idna_ascii
);
2542 /* (Rather link check only here
) */
2543 idna_utf8
= stringprep_convert
(idna_ascii
, "UTF-8", "de_DE");
2549 elif link_check idna
'idnkit' '#define HAVE_IDNA HAVE_IDNA_IDNKIT' \
2552 #include <idn/api.h>
2553 #include <idn/result.h>
2557 char local_name
[256];
2559 r
= idn_encodename
(IDN_ENCODE_APP
, "does.this.work", ace_name
,
2561 if (r
!= idn_success
) {
2562 fprintf
(stderr
, "idn_encodename failed: %s\n", idn_result_tostring
(r
));
2565 r
= idn_decodename
(IDN_DECODE_APP
, ace_name
, local_name
, sizeof
(local_name
));
2566 if (r
!= idn_success
) {
2567 fprintf
(stderr
, "idn_decodename failed: %s\n", idn_result_tostring
(r
));
2576 feat_bail_required IDNA
2579 if [ -n "${have_idna}" ]; then
2580 echo '#define HAVE_IDNA_LIBIDNA 0' >> ${h}
2581 echo '#define HAVE_IDNA_IDNKIT 1' >> ${h}
2584 echo '/* OPT_IDNA=0 */' >> ${h}
2587 feat_def IMAP_SEARCH
2589 if feat_yes REGEX
; then
2590 if link_check regex
'regular expressions' '#define HAVE_REGEX' << \
!
2598 status
= regcomp
(&re
, ".*bsd", REG_EXTENDED | REG_ICASE | REG_NOSUB
);
2599 xret
= regerror
(status
, &re
, NULL
, 0);
2600 status
= regexec
(&re
, "plan9", 0,NULL
, 0);
2602 return !(status
== REG_NOMATCH
);
2608 feat_bail_required REGEX
2611 echo '/* OPT_REGEX=0 */' >> ${h}
2614 if feat_yes MLE
&& [ -n "${have_c90amend1}" ]; then
2616 echo '#define HAVE_MLE' >> ${h}
2618 feat_bail_required MLE
2619 echo '/* OPT_MLE=0 */' >> ${h}
2622 # Generic have-a-line-editor switch for those who need it below
2623 if [ -n "${have_mle}" ]; then
2627 if [ -n "${have_cle}" ] && feat_yes HISTORY
; then
2628 echo '#define HAVE_HISTORY' >> ${h}
2630 echo '/* OPT_HISTORY=0 */' >> ${h}
2633 if [ -n "${have_mle}" ] && feat_yes KEY_BINDINGS
; then
2634 echo '#define HAVE_KEY_BINDINGS' >> ${h}
2636 echo '/* OPT_KEY_BINDINGS=0 */' >> ${h}
2639 if feat_yes TERMCAP
; then
2641 link_check termcap
"termcap(5) (via ${4})" \
2642 "#define HAVE_TERMCAP${3}" "${1}" << _EOT
2647 #define UNCONST(P) ((void*)(unsigned long)(void const*)(P))
2648 static int my_putc(int c){return putchar(c);}
2650 char buf[1024+512], cmdbuf[2048], *cpb, *r1;
2651 int r2 = OK, r3 = ERR;
2653 tgetent(buf, getenv("TERM"));
2655 r1 = tgetstr(UNCONST("cm"), &cpb);
2657 r2 = tgetnum(UNCONST("Co"));
2658 r3 = tgetflag(UNCONST("ut"));
2659 tputs("cr", 1, &my_putc);
2660 return (r1 == NULL || r2 == -1 || r3 == 0);
2666 link_check terminfo
"terminfo(5) (via ${2})" \
2667 '#define HAVE_TERMCAP
2668 #define HAVE_TERMCAP_CURSES
2669 #define HAVE_TERMINFO' "${1}" << _EOT
2673 #define UNCONST(P) ((void*)(unsigned long)(void const*)(P))
2674 static int my_putc(int c){return putchar(c);}
2680 r0 = setupterm(NULL, 1, &er);
2681 r1 = tigetflag(UNCONST("bce"));
2682 r2 = tigetnum(UNCONST("colors"));
2683 r3 = tigetstr(UNCONST("cr"));
2684 tp = tparm(r3, NULL, NULL, 0,0,0,0,0,0,0);
2685 tputs(tp, 1, &my_putc);
2686 return (r0 == ERR || r1 == -1 || r2 == -2 || r2 == -1 ||
2687 r3 == (char*)-1 || r3 == NULL);
2692 if feat_yes TERMCAP_VIA_TERMINFO
; then
2693 __terminfolib
-ltinfo -ltinfo ||
2694 __terminfolib
-lcurses -lcurses ||
2695 __terminfolib
-lcursesw -lcursesw ||
2696 feat_bail_required TERMCAP_VIA_TERMINFO
2699 if [ -z "${have_terminfo}" ]; then
2700 __termcaplib
-ltermcap '' '' '-ltermcap' ||
2701 __termcaplib
-ltermcap '#include <curses.h>' '
2702 #define HAVE_TERMCAP_CURSES' \
2703 'curses.h / -ltermcap' ||
2704 __termcaplib
-lcurses '#include <curses.h>' '
2705 #define HAVE_TERMCAP_CURSES' \
2706 'curses.h / -lcurses' ||
2707 __termcaplib
-lcursesw '#include <curses.h>' '
2708 #define HAVE_TERMCAP_CURSES' \
2709 'curses.h / -lcursesw' ||
2710 feat_bail_required TERMCAP
2712 if [ -n "${have_termcap}" ]; then
2713 run_check tgetent_null \
2714 "tgetent(3) of termcap(5) takes NULL buffer" \
2715 "#define HAVE_TGETENT_NULL_BUF" << _EOT
2716 #include <stdio.h> /* For C89 NULL */
2718 #ifdef HAVE_TERMCAP_CURSES
2719 # include <curses.h>
2723 tgetent(NULL, getenv("TERM"));
2730 echo '/* OPT_TERMCAP=0 */' >> ${h}
2731 echo '/* OPT_TERMCAP_VIA_TERMINFO=0 */' >> ${h}
2734 if feat_def SPAM_SPAMC
; then
2735 if acmd_set i spamc
; then
2736 echo "#define SPAM_SPAMC_PATH \"${i}\"" >> ${h}
2740 if feat_yes SPAM_SPAMD
&& [ -n "${have_af_unix}" ]; then
2741 echo '#define HAVE_SPAM_SPAMD' >> ${h}
2743 feat_bail_required SPAM_SPAMD
2744 echo '/* OPT_SPAM_SPAMD=0 */' >> ${h}
2747 feat_def SPAM_FILTER
2749 if feat_yes SPAM_SPAMC || feat_yes SPAM_SPAMD || feat_yes SPAM_FILTER
; then
2750 echo '#define HAVE_SPAM' >> ${h}
2752 echo '/* HAVE_SPAM */' >> ${h}
2755 if feat_yes QUOTE_FOLD
&&\
2756 [ -n "${have_c90amend1}" ] && [ -n "${have_wcwidth}" ]; then
2757 echo '#define HAVE_QUOTE_FOLD' >> ${h}
2759 feat_bail_required QUOTE_FOLD
2760 echo '/* OPT_QUOTE_FOLD=0 */' >> ${h}
2763 feat_def FILTER_HTML_TAGSOUP
2772 squeeze_em
${inc} ${tmp}
2774 squeeze_em
${lib} ${tmp}
2779 printf '#ifndef n_MK_CONFIG_H\n# define n_MK_CONFIG_H 1\n' > ${h}
2780 ${cat} ${tmp} >> ${h}
2784 # Create the string that is used by *features* and `version'.
2785 # Take this nice opportunity and generate a visual listing of included and
2786 # non-included features for the person who runs the configuration
2787 msg
'\nThe following features are included (+) or not (-):'
2788 set -- ${OPTIONS_DETECT} ${OPTIONS} ${OPTIONS_XTRA}
2789 printf '/* The "feature string" */\n' >> ${h}
2790 # Because + is expanded by *folder* if first in "echo $features", put something
2791 printf '#define VAL_FEATURES_CNT '${#}'\n#define VAL_FEATURES "#' >> ${h}
2795 sdoc
=`option_doc_of ${opt}`
2796 [ -z "${sdoc}" ] && continue
2797 sopt
="`echo ${opt} | ${tr} '[A-Z]_' '[a-z]-'`"
2798 feat_yes
${opt} && sign
=+ || sign
=-
2799 printf -- "${sep}${sign}${sopt}" >> ${h}
2801 msg " %s
%s
: %s
" ${sign} ${sopt} "${sdoc}"
2803 # TODO instead of using sh+tr+awk+printf, use awk, drop option_doc_of, inc here
2805 #${awk} -v opts="${OPTIONS_DETECT} ${OPTIONS} ${OPTIONS_XTRA}" \
2806 # -v xopts="${XOPTIONS_DETECT} ${XOPTIONS} ${XOPTIONS_XTRA}" \
2807 printf '"\n' >> ${h}
2809 # Create the real mk-config.mk
2810 # Note we cannout use explicit ./ filename prefix for source and object
2811 # pathnames because of a bug in bmake(1)
2812 ${rm} -rf ${tmp0}.* ${tmp0}*
2814 if feat_no AMALGAMATION
; then
2815 for i
in `printf '%s\n' "${SRCDIR}"*.c | ${sort}`; do
2816 i
=`basename "${i}" .c`
2817 if [ "${i}" = privsep
]; then
2820 objlist
="${objlist} ${i}.o"
2821 srclist
="${srclist} \$(SRCDIR)${i}.c"
2822 printf '%s: %s\n\t$(ECHO_CC)$(CC) $(CFLAGS) $(INCS) -c %s\n' \
2823 "${i}.o" "\$(SRCDIR)${i}.c" "\$(SRCDIR)${i}.c" >> ${mk}
2825 printf '\nAMALGAM_TARGET =\nAMALGAM_DEP =\n' >> ${mk}
2827 printf '%s:\n\t$(ECHO_CC)$(CC) $(CFLAGS) $(INCS) -c $(SRCDIR)%s\n' \
2828 "main.o
" "main.c
" >> ${mk}
2829 srclist=main.c objlist=main.o
2830 printf '\nAMALGAM_TARGET = main.o\nAMALGAM_DEP = ' >> ${mk}
2832 printf '\n/* HAVE_AMALGAMATION: include sources */\n' >> ${h}
2833 printf '#elif n_MK_CONFIG_H + 0 == 1\n' >> ${h}
2834 printf '# undef n_MK_CONFIG_H\n' >> ${h}
2835 printf '# define n_MK_CONFIG_H 2\n' >> ${h}
2836 for i in `printf '%s\n' "${SRCDIR}"*.c | ${sort}`; do
2838 if [ "${i}" = main.c ] ||
2839 [ "${i}" = privsep.c ]; then
2842 printf '$(SRCDIR)%s ' "${i}" >> ${mk}
2843 printf '# include "%s
%s
"\n' "${SRCDIR}" "${i}" >> ${h}
2847 printf 'OBJ_SRC = %s\nOBJ = %s\n' "${srclist}" "${objlist}" >> "${mk}"
2849 printf '#endif /* n_MK_CONFIG_H */\n' >> ${h}
2851 echo "LIBS = `${cat} ${lib}`" >> ${mk}
2852 echo "INCS
= `${cat} ${inc}`" >> ${mk}
2854 ${cat} "${SRCDIR}"make-config.in >> ${mk}
2859 msg ' . System-wide resource file: %s/%s' "${VAL_SYSCONFDIR}" "${VAL_SYSCONFRC}"
2860 msg ' . bindir: %s' "${VAL_BINDIR}"
2861 if feat_yes DOTLOCK; then
2862 msg ' . libexecdir: %s' "${VAL_LIBEXECDIR}"
2864 msg ' . mandir: %s' "${VAL_MANDIR}"
2865 msg ' . M(ail)T(ransfer)A(gent): %s (argv0: %s)' "${VAL_MTA}" "${VAL_MTA_ARGV0}"
2866 msg ' . $MAIL spool directory: %s' "${VAL_MAIL}"
2869 if [ -n "${have_fnmatch}" ] && [ -n "${have_fchdir}" ]; then
2873 if [ -z "${have_fnmatch}" ]; then
2874 msg ' . The function fnmatch(3) could not be found.'
2875 msg ' Filename patterns like wildcard are not supported on your system'
2877 if [ -z "${have_fchdir}" ]; then
2878 msg ' . The function fchdir(2) could not be found.'
2879 msg ' We will use chdir(2) instead.'
2880 msg ' This is a problem only if the current working directory is changed'
2881 msg ' while this program is inside of it'