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 MAILDIR='Maildir E-mail directories' \
24 SOCKETS='Network support' \
25 SSL='SSL/TLS (OpenSSL / LibreSSL)' \
26 SSL_ALL_ALGORITHMS='Support of all digest and cipher algorithms' \
27 SMTP='Simple Mail Transfer Protocol client' \
28 POP3='Post Office Protocol Version 3 client' \
29 IMAP='IMAP v4r1 client' \
30 GSSAPI='Generic Security Service authentication' \
31 NETRC='.netrc file support' \
33 MD5='MD5 message digest (APOP, CRAM-MD5)' \
34 IDNA='Internationalized Domain Names for Applications (encode only)' \
35 IMAP_SEARCH='IMAP-style search expressions' \
36 REGEX='Regular expressions' \
37 MLE='Mailx Line Editor' \
38 HISTORY='Line editor history management' \
39 KEY_BINDINGS='Configurable key bindings' \
40 TERMCAP='Terminal capability queries (termcap(5))' \
41 TERMCAP_VIA_TERMINFO='Terminal capability queries use terminfo(5)' \
42 ERRORS='Log message ring' \
43 SPAM_SPAMC='Spam management via spamc(1) of spamassassin(1)' \
45 SPAM_FILTER='Freely configurable *spam-filter-..*s' \
46 DOCSTRINGS='Command documentation help strings' \
47 UISTRINGS='User interface and error message strings' \
48 QUOTE_FOLD='Extended *quote-fold*ing' \
49 FILTER_HTML_TAGSOUP='Simple built-in HTML-to-text display filter' \
50 COLOUR='Coloured message display' \
51 DOTLOCK='Dotlock files and privilege-separated dotlock program' \
54 # Options which are automatically deduced from host environment, i.e., these
55 # need special treatment all around here to warp from/to OPT_ stuff
56 # setlocale, C90AMEND1, NL_LANGINFO, wcwidth
58 LOCALES='Locale support - printable characters etc. depend on environment' \
59 MULTIBYTE_CHARSETS='Multibyte character sets' \
60 TERMINAL_CHARSET='Automatic detection of terminal character set' \
61 WIDE_GLYPHS='Wide glyph support' \
64 # Rather special options, for custom building, or which always exist.
65 # Mostly for generating the visual overview and the *features* string
67 MIME='Multipurpose Internet Mail Extensions' \
68 SMIME='S/MIME message signing, verification, en- and decryption' \
69 CROSS_BUILD='Cross-compilation: trust any detected environment' \
70 DEBUG='Debug enabled binary, not for end-users: THANKS!' \
71 DEVEL='Computers do not blunder' \
74 # To avoid too many recompilations we use a two-stage "configuration changed"
75 # detection, the first uses mk-config.lst, which only goes for actual user
76 # config settings etc. the second uses mk-config.h, which thus includes the
77 # things we have truly detected. This does not work well for multiple choice
78 # values of which only one will be really used, so those user wishes may not be
79 # placed in the header, only the really detected one (but that has to!).
80 # Used for grep(1), for portability assume fixed matching only.
81 H_BLACKLIST
='-e VAL_RANDOM -e VAL_IDNA'
83 # The problem is that we don't have any tools we can use right now, so
84 # encapsulate stuff in functions which get called in right order later on
100 OPT_DOTLOCK
=require OPT_ICONV
=require OPT_REGEX
=require
104 option_parse OPTIONS_DETECT
"${XOPTIONS_DETECT}"
105 option_parse OPTIONS
"${XOPTIONS}"
106 option_parse OPTIONS_XTRA
"${XOPTIONS_XTRA}"
109 # Predefined CONFIG= urations take precedence over anything else
110 if [ -n "${CONFIG}" ]; then
115 [nN
][uU
][lL
][lL
][iI
])
119 [mM
][iI
][nN
][iI
][mM
][aA
][lL
])
120 OPT_DOTLOCK
=require OPT_ICONV
=require OPT_REGEX
=require
128 OPT_HISTORY
=1 OPT_KEY_BINDINGS
=1
131 [nN
][eE
][tT
][sS
][eE
][nN
][dD
])
132 OPT_DOTLOCK
=require OPT_ICONV
=require OPT_REGEX
=require
136 OPT_GSSAPI
=1 OPT_NETRC
=1
145 OPT_HISTORY
=1 OPT_KEY_BINDINGS
=1
148 [mM
][aA
][xX
][iI
][mM
][aA
][lL
])
151 [dD
][eE
][vV
][eE
][lL
])
153 OPT_DEVEL
=1 OPT_DEBUG
=1 OPT_NYD2
=1
155 [oO
][dD
][eE
][vV
][eE
][lL
])
160 echo >&2 "Unknown CONFIG= setting: ${CONFIG}"
161 echo >&2 ' NULL, NULLI, MINIMAL, NETSEND, MAXIMAL'
165 msg_nonl
"CONFIG=${CONFIG} ... "
169 # Inter-relationships XXX sort this!
172 OPT_SSL_ALL_ALGORITHMS
=0
175 if feat_no SMTP
&& feat_no POP3
&& feat_no IMAP
; then
178 if feat_no SOCKETS
; then
179 if feat_require SMTP
; then
180 msg
'ERROR: need SOCKETS for required feature SMTP'
183 if feat_require POP3
; then
184 msg
'ERROR: need SOCKETS for required feature POP3'
187 if feat_require IMAP
; then
188 msg
'ERROR: need SOCKETS for required feature IMAP'
191 OPT_SSL
=0 OPT_SSL_ALL_ALGORITHMS
=0
192 OPT_SMTP
=0 OPT_POP3
=0 OPT_IMAP
=0
193 OPT_GSSAPI
=0 OPT_NETRC
=0 OPT_AGENT
=0
195 if feat_no SMTP
&& feat_no IMAP
; then
199 if feat_no ICONV
; then
200 if feat_yes IMAP
; then
201 if feat_yes ALWAYS_UNICODE_LOCALE
; then
202 msg
'WARN: no ICONV, keeping IMAP due to ALWAYS_UNICODE_LOCALE!'
203 elif feat_require IMAP
; then
204 msg
'ERROR: need ICONV for required feature IMAP'
207 msg
'ERROR: disabling IMAP due to missing ICONV'
212 if feat_yes IDNA
; then
213 if feat_require IDNA
; then
214 msg
'ERROR: need ICONV for required feature IDNA'
217 msg
'ERROR: disabling IDNA due to missing ICONV'
223 OPT_HISTORY
=0 OPT_KEY_BINDINGS
=0
226 # If we don't need MD5 leave it alone
227 if feat_no SOCKETS
; then
231 if feat_no TERMCAP
; then
232 OPT_TERMCAP_VIA_TERMINFO
=0
235 if feat_yes DEVEL
; then
241 lst
=.obj
/mk-config.lst
243 h
=.obj
/mk-config.h h_name
=mk-config.h
246 newlst
=.obj
/mk-nconfig.lst
247 newmk
=.obj
/mk-nconfig.mk
248 oldmk
=.obj
/mk-oconfig.mk
249 newev
=.obj
/mk-nconfig.ev
250 newh
=.obj
/mk-nconfig.h
251 oldh
=.obj
/mk-oconfig.h
256 ## -- >8 - << OPTIONS | OS/CC >> - 8< -- ##
258 # Note that potential duplicates in PATH, C_INCLUDE_PATH etc. will be cleaned
259 # via path_check() later on once possible
263 # TODO cc_maxopt is brute simple, we should compile test program and dig real
264 # compiler versions for known compilers, then be more specific
265 [ -n "${cc_maxopt}" ] || cc_maxopt
=100
266 #cc_force_no_stackprot=
269 #ld_rpath_not_runpath=
274 # We don't "have any utility" (see make.rc)
275 [ -n "${OS}" ] && [ -n "${OSFULLSPEC}" ] ||
276 thecmd_testandset_fail uname uname
278 [ -n "${OS}" ] || OS
=`${uname} -s`
281 if [ ${OS} = SunOS
]; then
282 # According to standards(5), this is what we need to do
283 if [ -d /usr
/xpg4
]; then :; else
284 msg
'ERROR: On SunOS / Solaris we need /usr/xpg4 environment! Sorry.'
287 PATH
="/usr/xpg4/bin:/usr/ccs/bin:/usr/bin:${PATH}"
288 [ -d /usr
/xpg6
] && PATH
="/usr/xpg6/bin:${PATH}"
294 OS
=`echo ${OS} | ${tr} '[A-Z]' '[a-z]'`
295 msg
'Operating system is %s' "${OS}"
297 # OSFULLSPEC is used to recognize changes (i.e., machine type, updates
298 # etc.), it is not baked into the binary
299 [ -n "${OSFULLSPEC}" ] || OSFULLSPEC
=`${uname} -a`
301 if [ ${OS} = darwin
]; then
302 msg
' . have special Darwin environmental addons...'
303 LD_LIBRARY_PATH
=${LD_LIBRARY_PATH}:${DYLD_LIBRARY_PATH}
304 elif [ ${OS} = sunos
]; then
305 msg
' . have special SunOS / Solaris "setup" rules ...'
307 elif [ ${OS} = unixware
]; then
308 if feat_yes AUTOCC
&& acmd_set CC cc
; then
309 msg
' . have special UnixWare environmental rules ...'
310 feat_yes DEBUG
&& _CFLAGS
='-v -Xa -g' || _CFLAGS
='-Xa -O'
312 CFLAGS
="${_CFLAGS} ${EXTRA_CFLAGS}"
313 LDFLAGS
="${_LDFLAGS} ${EXTRA_LDFLAGS}"
314 export CC CFLAGS LDFLAGS
315 OPT_AUTOCC
=0 ld_need_R_flags
=-R
317 elif [ -n "${VERBOSE}" ]; then
318 msg
' . no special treatment for this system necessary or known'
321 # Sledgehammer: better set _GNU_SOURCE
322 # And in general: oh, boy!
323 OS_DEFINES
="${OS_DEFINES}#define _GNU_SOURCE\n"
324 #OS_DEFINES="${OS_DEFINES}#define _POSIX_C_SOURCE 200809L\n"
325 #OS_DEFINES="${OS_DEFINES}#define _XOPEN_SOURCE 700\n"
326 #[ ${OS} = darwin ] && OS_DEFINES="${OS_DEFINES}#define _DARWIN_C_SOURCE\n"
328 # On pkgsrc(7) systems automatically add /usr/pkg/*
329 if [ -d /usr
/pkg
] && feat_yes USE_PKGSYS
; then
330 msg
' . found pkgsrc(7), merging C_INCLUDE_PATH and LD_LIBRARY_PATH'
331 C_INCLUDE_PATH
=/usr
/pkg
/include
:${C_INCLUDE_PATH}
332 LD_LIBRARY_PATH
=/usr
/pkg
/lib
:${LD_LIBRARY_PATH}
333 ld_rpath_not_runpath
=1
338 C_INCLUDE_PATH
=/usr
/xpg
4/include
:${C_INCLUDE_PATH}
339 LD_LIBRARY_PATH
=/usr
/xpg
4/lib
:${LD_LIBRARY_PATH}
342 if [ -d /opt
/csw
] && feat_yes USE_PKGSYS
; then
343 msg
' . found OpenCSW PKGSYS, merging C_INCLUDE_PATH and LD_LIBRARY_PATH'
344 C_INCLUDE_PATH
=/opt
/csw
/include
:${C_INCLUDE_PATH}
345 LD_LIBRARY_PATH
=/opt
/csw
/lib
:${LD_LIBRARY_PATH}
346 ld_no_bind_now
=1 ld_rpath_not_runpath
=1
348 if [ -d /opt
/schily
] && feat_yes USE_PKGSYS
; then
349 msg
' . found Schily PKGSYS, merging C_INCLUDE_PATH and LD_LIBRARY_PATH'
350 C_INCLUDE_PATH
=/opt
/schily
/include
:${C_INCLUDE_PATH}
351 LD_LIBRARY_PATH
=/opt
/schily
/lib
:${LD_LIBRARY_PATH}
352 ld_no_bind_now
=1 ld_rpath_not_runpath
=1
355 OS_DEFINES
="${OS_DEFINES}#define __EXTENSIONS__\n"
356 #OS_DEFINES="${OS_DEFINES}#define _POSIX_C_SOURCE 200112L\n"
358 [ -n "${cksum}" ] ||
cksum=/opt
/csw
/gnu
/cksum
359 if [ -x "${cksum}" ]; then :; else
360 msg
'ERROR: Not an executable program: %s' "${cksum}"
361 msg
'ERROR: We need a CRC-32 cksum(1), as specified in POSIX.'
362 msg
'ERROR: However, we do so only for tests.'
363 msg
'ERROR: If that is ok, set "cksum=/usr/bin/true", then rerun'
367 if feat_yes AUTOCC
; then
368 if acmd_set CC cc
; then
369 feat_yes DEBUG
&& _CFLAGS
="-v -Xa -g" || _CFLAGS
="-Xa -O"
371 CFLAGS
="${_CFLAGS} ${EXTRA_CFLAGS}"
372 LDFLAGS
="${_LDFLAGS} ${EXTRA_LDFLAGS}"
373 export CC CFLAGS LDFLAGS
374 OPT_AUTOCC
=0 ld_need_R_flags
=-R
376 cc_maxopt
=2 cc_force_no_stackprot
=1
381 # Check out compiler ($CC) and -flags ($CFLAGS)
383 # Even though it belongs into cc_flags we will try to compile and link
384 # something, so ensure we have a clean state regarding CFLAGS/LDFLAGS or
385 # EXTRA_CFLAGS/EXTRA_LDFLAGS
386 if feat_no AUTOCC
; then
388 # Ensure those don't do any harm
389 EXTRA_CFLAGS
= EXTRA_LDFLAGS
=
390 export EXTRA_CFLAGS EXTRA_LDFLAGS
394 export CFLAGS LDFLAGS
397 [ -n "${CC}" ] && { _cc_default
; return; }
399 msg_nonl
'Searching for a usable C compiler .. $CC='
400 if acmd_set CC clang || acmd_set CC gcc ||
401 acmd_set CC tcc || acmd_set CC pcc ||
402 acmd_set CC c89 || acmd_set CC c99
; then
405 msg
'boing booom tschak'
406 msg
'ERROR: I cannot find a compiler!'
407 msg
' Neither of clang(1), gcc(1), tcc(1), pcc(1), c89(1) and c99(1).'
408 msg
' Please set ${CC} environment variable, maybe ${CFLAGS}, rerun.'
416 if [ -z "${CC}" ]; then
417 msg
'To go on like you have chosen, please set $CC, rerun.'
421 if [ -z "${VERBOSE}" ] && [ -f ${lst} ] && feat_no DEBUG
; then
424 msg
'Using C compiler ${CC}=%s' "${CC}"
429 if feat_yes AUTOCC
; then
430 if [ -f ${lst} ] && feat_no DEBUG
&& [ -z "${VERBOSE}" ]; then
432 msg
'Detecting ${CFLAGS}/${LDFLAGS} for ${CC}=%s, just a second..' \
436 msg
'Testing usable ${CFLAGS}/${LDFLAGS} for ${CC}=%s' "${CC}"
439 i=`echo "${CC}" | ${awk} 'BEGIN{FS="/"}{print $NF}'`
440 if { echo "${i}" | ${grep} tcc; } >/dev/null 2>&1; then
441 msg ' . have special tcc(1) environmental rules ...'
444 # As of pcc CVS 2016-04-02, stack protection support is announced but
445 # will break if used on Linux
446 if { echo "${i}" | ${grep} pcc; } >/dev/null 2>&1; then
447 cc_force_no_stackprot=1
452 feat_no DEBUG && _CFLAGS="-DNDEBUG ${_CFLAGS}"
453 CFLAGS="${_CFLAGS} ${EXTRA_CFLAGS}"
454 LDFLAGS="${_LDFLAGS} ${EXTRA_LDFLAGS}"
456 if feat_no DEBUG; then
457 CFLAGS="-DNDEBUG ${CFLAGS}"
460 export CFLAGS LDFLAGS
464 __cflags=${_CFLAGS} __ldflags=${_LDFLAGS}
472 if feat_yes DEBUG; then
473 # May have problems to find libtcc cc_check -b
477 if ld_check -Wl,-rpath =./ no; then
478 ld_need_R_flags=-Wl,-rpath=
479 if [ -z "${ld_rpath_not_runpath}" ]; then
480 ld_check -Wl,--enable-new-dtags
482 msg ' ! $LD_LIBRARY_PATH adjusted, not trying --enable-new-dtags'
484 ld_runtime_flags # update!
487 _CFLAGS="${_CFLAGS} ${__cflags}" _LDFLAGS="${_LDFLAGS} ${__ldflags}"
488 unset __cflags __ldflags
491 _cc_flags_generic() {
492 __cflags=${_CFLAGS} __ldflags=${_LDFLAGS}
494 feat_yes DEVEL && cc_check -std=c89 || cc_check -std=c99
496 # E.g., valgrind does not work well with high optimization
497 if [ ${cc_maxopt} -gt 1 ] && feat_yes NOMEMDBG &&
498 feat_no ASAN_ADDRESS && feat_no ASAN_MEMORY; then
499 msg ' ! OPT_NOMEMDBG, setting cc_maxopt=1 (-O1)'
502 # Check -g first since some others may rely upon -g / optim. level
503 if feat_yes DEBUG; then
506 elif [ ${cc_maxopt} -gt 2 ] && cc_check -O3; then
508 elif [ ${cc_maxopt} -gt 1 ] && cc_check -O2; then
510 elif [ ${cc_maxopt} -gt 0 ] && cc_check -O1; then
516 if feat_yes AMALGAMATION; then
520 #if feat_yes DEVEL && cc_check -Weverything; then
526 cc_check -Wbad-function-cast
527 cc_check -Wcast-align
530 cc_check -Wmissing-prototypes
533 cc_check -Wwrite-strings
534 cc_check -Wno-long-long
538 if feat_yes AMALGAMATION && feat_no DEVEL; then
539 cc_check -Wno-unused-function
541 feat_no DEVEL && cc_check -Wno-unused-result # XXX do right way (pragma too)
543 cc_check -fno-unwind-tables
544 cc_check -fno-asynchronous-unwind-tables
545 cc_check -fstrict-aliasing
546 if cc_check -fstrict-overflow && feat_yes DEVEL; then
547 cc_check -Wstrict-overflow=5
550 if feat_yes DEBUG || feat_yes FORCED_STACKPROT; then
551 if [ -z "${cc_force_no_stackprot}" ]; then
552 if cc_check -fstack-protector-strong ||
553 cc_check -fstack-protector-all; then
554 cc_check -D_FORTIFY_SOURCE=2
557 msg ' ! Not checking for -fstack-protector compiler option,'
558 msg ' ! since that caused errors in a "similar" configuration.'
559 msg ' ! You may turn off OPT_AUTOCC and use your own settings, rerun'
563 # LD (+ dependend CC)
565 if feat_yes ASAN_ADDRESS; then
567 if cc_check -fsanitize=address && ld_check -fsanitize=address; then
570 feat_bail_required ASAN_ADDRESS
575 if feat_yes ASAN_MEMORY; then
577 if cc_check -fsanitize=memory && ld_check -fsanitize=memory &&
578 cc_check -fsanitize-memory-track-origins=2 &&
579 ld_check -fsanitize-memory-track-origins=2; then
582 feat_bail_required ASAN_MEMORY
587 if feat_yes USAN; then
589 if cc_check -fsanitize=undefined && ld_check -fsanitize=undefined; then
592 feat_bail_required USAN
597 ld_check -Wl,-z,relro
598 if [ -z "${ld_no_bind_now}" ]; then
601 msg ' ! $LD_LIBRARY_PATH adjusted, not trying -Wl,-z,now'
603 ld_check -Wl,-z,noexecstack
604 ld_check -Wl,--as-needed
605 if ld_check -Wl,-rpath =./ no; then
606 ld_need_R_flags=-Wl,-rpath=
607 # Choose DT_RUNPATH (after $LD_LIBRARY_PATH) over DT_RPATH (before)
608 if [ -z "${ld_rpath_not_runpath}" ]; then
609 ld_check -Wl,--enable-new-dtags
611 msg ' ! $LD_LIBRARY_PATH adjusted, not trying --enable-new-dtags'
613 ld_runtime_flags # update!
614 elif ld_check -Wl,-R ./ no; then
615 ld_need_R_flags=-Wl,-R
616 if [ -z "${ld_rpath_not_runpath}" ]; then
617 ld_check -Wl,--enable-new-dtags
619 msg ' ! $LD_LIBRARY_PATH adjusted, not trying --enable-new-dtags'
621 ld_runtime_flags # update!
624 # Address randomization
626 if cc_check -fPIE || cc_check -fpie; then
627 ld_check -pie || _CFLAGS=${_ccfg}
631 _CFLAGS="${_CFLAGS} ${__cflags}" _LDFLAGS="${_LDFLAGS} ${__ldflags}"
632 unset __cflags __ldflags
635 ## -- >8 - <<OS/CC | SUPPORT FUNS>> - 8< -- ##
638 ## - Heirloom sh(1) (and same origin) have _sometimes_ problems with ': >'
639 ## redirection, so use "printf '' >" instead
641 ## Very first: we undergo several states regarding I/O redirection etc.,
642 ## but need to deal with option updates from within all. Since all the
643 ## option stuff should be above the scissor line, define utility functions
644 ## and redefine them as necessary.
645 ## And, since we have those functions, simply use them for whatever
647 t1=ten10one1ten10one1
648 if ( [ ${t1##*ten10} = one1 ] && [ ${t1#*ten10} = one1ten10one1 ] &&
649 [ ${t1%%one1*} = ten10 ] && [ ${t1%one1*} = ten10one1ten10 ]
650 ) > /dev/null 2>&1; then
657 ( set -o noglob ) >/dev/null 2>&1 && noglob_shell=1 || unset noglob_shell
663 # which(1) not standardized, command(1) -v may return non-executable: unroll!
664 acmd_test() { __acmd "${1}" 1 0 0; }
665 acmd_test_fail() { __acmd "${1}" 1 1 0; }
666 acmd_set() { __acmd "${2}" 0 0 0 "${1}"; }
667 acmd_set_fail() { __acmd "${2}" 0 1 0 "${1}"; }
668 acmd_testandset() { __acmd "${2}" 1 0 0 "${1}"; }
669 acmd_testandset_fail() { __acmd "${2}" 1 1 0 "${1}"; }
670 thecmd_set() { __acmd "${2}" 0 0 1 "${1}"; }
671 thecmd_set_fail() { __acmd "${2}" 0 1 1 "${1}"; }
672 thecmd_testandset() { __acmd "${2}" 1 0 1 "${1}"; }
673 thecmd_testandset_fail() { __acmd "${2}" 1 1 1 "${1}"; }
675 pname=${1} dotest=${2} dofail=${3} verbok=${4} varname=${5}
677 if [ "${dotest}" -ne 0 ]; then
678 eval dotest=\$${varname}
679 if [ -n "${dotest}" ]; then
680 [ -n "${VERBOSE}" ] && [ ${verbok} -ne 0 ] &&
681 msg ' . ${%s} ... %s' "${pname}" "${dotest}"
687 [ -n "${noglob_shell}" ] && set -o noglob
689 [ -n "${noglob_shell}" ] && set +o noglob
693 if [ -z "${path}" ] || [ "${path}" = . ]; then
694 if [ -d "${PWD}" ]; then
700 if [ -f "${path}/${pname}" ] && [ -x "${path}/${pname}" ]; then
701 [ -n "${VERBOSE}" ] && [ ${verbok} -ne 0 ] &&
702 msg ' . ${%s} ... %s' "${pname}" "${path}/${pname}"
703 [ -n "${varname}" ] && eval ${varname}="${path}/${pname}"
708 # We may have no builtin string functions, we yet have no programs we can
709 # use, try to access once from the root, assuming it is an absolute path if
710 # that finds the executable
711 if ( cd && [ -f "${pname}" ] && [ -x "${pname}" ] ); then
712 [ -n "${VERBOSE}" ] && [ ${verbok} -ne 0 ] &&
713 msg ' . ${%s} ... %s' "${pname}" "${pname}"
714 [ -n "${varname}" ] && eval ${varname}="${pname}"
718 [ ${dofail} -eq 0 ] && return 1
719 msg 'ERROR: no trace of utility '"${pname}"
726 printf >&2 -- "${fmt}\\n" "${@}"
732 printf >&2 -- "${fmt}" "${@}"
735 # Our feature check environment
737 [ "x${1}" = x0 ] || [ "x${1}" = xn ] ||
738 [ "x${1}" = xfalse ] || [ "x${1}" = xno ] || [ "x${1}" = xoff ]
742 [ "x${1}" = x1 ] || [ "x${1}" = xy ] ||
743 [ "x${1}" = xtrue ] || [ "x${1}" = xyes ] || [ "x${1}" = xon ] ||
744 [ "x${1}" = xrequire ]
748 [ "x${1}" = xrequire ]
753 i="`echo ${i} |
${tr} '[A-Z]' '[a-z]'`"
754 if feat_val_no "${i}"; then
756 elif feat_val_yes "${i}"; then
759 msg "ERROR: %s: 0/n/false/no/off or 1/y/true/yes/on/require, got: %s" \
770 _feat_check ${1} && return 1
776 i="`echo ${i} |
${tr} '[A-Z]' '[a-z]'`"
777 [ "x${i}" = xrequire ] || [ "x${i}" = xrequired ]
780 feat_bail_required() {
781 if feat_require ${1}; then
782 msg 'ERROR: feature OPT_%s is required but not available' "${1}"
785 feat_is_unsupported "${1}"
789 [ ${#} -eq 1 ] && msg ' . (disabled: OPT_%s)' "${1}"
790 echo "/* OPT_${1} -> HAVE_${1} */" >> ${h}
793 feat_is_unsupported() {
794 msg ' ! NOTICE: unsupported: OPT_%s' "${1}"
795 echo "/* OPT_${1} -> HAVE_${1} */" >> ${h}
797 option_update # XXX this is rather useless here (dependency chain..)
801 if feat_yes ${1}; then
802 msg ' . %s ... yes' "${1}"
803 echo '#define HAVE_'${1}'' >> ${h}
806 feat_is_disabled "${@}"
812 # Parse one of our XOPTIONS* in $2 and assign the sh(1) compatible list of
813 # options, without documentation, to $1
815 i="`${awk} -v input
=\"${2}\" '
818 voff = match(input, /[[:alnum:]_]+(='${j}'[^'${j}']+)?/)
821 v = substr(input, voff, RLENGTH)
822 input = substr(input, voff + RLENGTH)
825 d = substr(v, doff + 2, length(v) - doff - 1)
826 v = substr(v, 1, doff - 1)
836 # Return the "documentation string" for option $1, itself if none such
838 ${awk} -v want="${1}" \
839 -v input="${XOPTIONS_DETECT}${XOPTIONS}${XOPTIONS_XTRA}" '
842 voff = match(input, /[[:alnum:]_]+(='${j}'[^'${j}']+)?/)
845 v = substr(input, voff, RLENGTH)
846 input = substr(input, voff + RLENGTH)
849 d = substr(v, doff + 2, length(v) - doff - 1)
850 v = substr(v, 1, doff - 1)
864 # Join the values from make.rc into what currently is defined, not
865 # overwriting yet existing settings
867 # We want read(1) to perform reverse solidus escaping in order to be able to
868 # use multiline values in make.rc; the resulting sh(1)/sed(1) code was very
869 # slow in VMs (see [fa2e248]), Aharon Robbins suggested the following
870 < ${rc} ${awk} 'BEGIN{line = ""}{
871 gsub(/^[[:space:]]+/, "", $0)
872 gsub(/[[:space:]]+$/, "", $0)
873 if(gsub(/\\$/, "", $0)){
878 if(index(line, "#") == 1){
880 }else if(length(line)){
886 if [ -n "${good_shell}" ]; then
889 i=`${awk} -v LINE
="${line}" 'BEGIN{
890 gsub(/=.*$/, "", LINE)
894 if [ "${i}" = "${line}" ]; then
895 msg 'ERROR: invalid syntax in: %s' "${line}"
899 eval j="\$${i}" jx="\${${i}+x}"
900 if [ -n "${j}" ] || [ "${jx}" = x ]; then
903 j=`${awk} -v LINE
="${line}" 'BEGIN{
904 gsub(/^[^=]*=/, "", LINE)
905 gsub(/^\"*/, "", LINE)
906 gsub(/\"*$/, "", LINE)
910 [ "${i}" = "DESTDIR" ] && continue
913 # Reread the mixed version right now
918 # Expand the option values, which may contain shell snippets
919 ${rm} -f ${newlst} ${newmk} ${newh}
920 exec 5<&0 6>&1 <${tmp} >${newlst}
923 if [ -n "${good_shell}" ]; then
925 [ "${i}" != "${i#OPT_}" ] && z=1
927 i=`${awk} -v LINE
="${line}" 'BEGIN{
928 gsub(/=.*$/, "", LINE);\
931 if echo "${i}" | ${grep} '^OPT_' >/dev/null 2>&1; then
937 if [ -n "${z}" ]; then
938 j="`echo ${j} |
${tr} '[A-Z]' '[a-z]'`"
939 if [ -z "${j}" ] || feat_val_no "${j}"; then
941 printf " /* #undef ${i} */\n" >> ${newh}
942 elif feat_val_yes "${j}"; then
943 if feat_val_require "${j}"; then
948 printf " /* #define ${i} */\n" >> ${newh}
950 msg 'ERROR: cannot parse <%s>' "${line}"
953 elif { echo ${i} | ${grep} ${H_BLACKLIST} >/dev/null 2>&1; }; then
956 printf "#define ${i} \"${j}\"\n" >> ${newh}
958 printf "${i} = ${j}\n" >> ${newmk}
962 exec 0<&5 1>&6 5<&- 6<&-
967 ${awk} -v HEAP="${2}" -v USER="${__expo__}" '
969 i = split(HEAP, ha, /[, ]/)
970 if((j = split(USER, ua, /[, ]/)) == 0)
974 if(us == "all" || us == "any")
977 for(ii = i; ii != 0; --ii)
978 if(tolower(ha[ii]) == us){
988 [ ${__rv__} -ne 0 ] && return ${__rv__}
990 if ${awk} -v USER="${__expo__}" '
992 if((j = split(USER, ua, /[, ]/)) == 0)
996 if(us == "all" || us == "any")
1002 eval "${1}"=\"${2}\"
1004 # Enfore lowercase also in otherwise unchanged user value..
1005 eval "${1}"=\""`echo ${__expo__} | ${tr} '[A-Z]_' '[a-z]-'`"\"
1011 # "path_check VARNAME
" or "path_check VARNAME FLAG VARNAME
"
1012 varname=${1} addflag=${2} flagvarname=${3}
1015 [ -n "${noglob_shell}" ] && set -o noglob
1016 eval "set -- \$
${1}"
1017 [ -n "${noglob_shell}" ] && set +o noglob
1022 [ -z "${i}" ] && continue
1023 [ -d "${i}" ] || continue
1024 if [ -n "${j}" ]; then
1025 if { z=${y}; echo "${z}"; } | ${grep} ":${i}:" >/dev
/null
2>&1; then
1030 # But do not link any fakeroot path into our binaries!
1031 if [ -n "${addflag}" ]; then
1032 case "${i}" in *fakeroot
*) continue;; esac
1033 k
="${k} ${addflag}${i}"
1039 # But do not link any fakeroot path into our binaries!
1040 if [ -n "${addflag}" ]; then
1041 case "${i}" in *fakeroot
*) continue;; esac
1042 k
="${k} ${addflag}${i}"
1046 eval "${varname}=\"${j}\""
1047 [ -n "${addflag}" ] && eval "${flagvarname}=\"${k}\""
1051 ld_runtime_flags
() {
1052 if [ -n "${ld_need_R_flags}" ]; then
1055 set -- ${LD_LIBRARY_PATH}
1059 # But do not link any fakeroot path into our binaries!
1060 case "${i}" in *fakeroot
*) continue;; esac
1061 LDFLAGS
="${LDFLAGS} ${ld_need_R_flags}${i}"
1062 _LDFLAGS
="${_LDFLAGS} ${ld_need_R_flags}${i}"
1066 # Disable it for a possible second run.
1071 [ -n "${cc_check_silent}" ] || msg_nonl
' . CC %s .. ' "${1}"
1073 ${_CFLAGS} ${1} ${EXTRA_CFLAGS} ${_LDFLAGS} ${EXTRA_LDFLAGS} \
1074 -o ${tmp2} ${tmp}.c ${LIBS} >/dev
/null
2>&1; then
1075 _CFLAGS
="${_CFLAGS} ${1}"
1076 [ -n "${cc_check_silent}" ] || msg
'yes'
1079 [ -n "${cc_check_silent}" ] || msg
'no'
1084 # $1=option [$2=option argument] [$3=if set, shall NOT be added to _LDFLAGS]
1085 [ -n "${cc_check_silent}" ] || msg_nonl
' . LD %s .. ' "${1}"
1086 if ${CC} ${INCS} ${_CFLAGS} ${_LDFLAGS} ${1}${2} ${EXTRA_LDFLAGS} \
1087 -o ${tmp2} ${tmp}.c ${LIBS} >/dev
/null
2>&1; then
1088 [ -n "${3}" ] || _LDFLAGS="${_LDFLAGS} ${1}"
1089 [ -n "${cc_check_silent}" ] || msg
'yes'
1092 [ -n "${cc_check_silent}" ] || msg
'no'
1098 variable
=$1 topic
=$2 define
=$3
1101 msg_nonl
' . %s ... ' "${topic}"
1102 #echo "/* checked ${topic} */" >> ${h}
1103 ${rm} -f ${tmp} ${tmp}.o
1104 if [ "${dump_test_program}" = 1 ]; then
1105 echo '*** test program is'
1106 { echo '#include <'"${h_name}"'>'; cat; } | ${tee} ${tmp}.c
1108 { echo '#include <'"${h_name}"'>'; cat; } > ${tmp}.c
1110 #echo '*** the preprocessor generates'
1111 #${make} -f ${makefile} ${tmp}.x
1113 echo '*** tests results'
1117 yesno=$1 variable=$2 topic=$3 define=$4 libs=$5 incs=$6
1120 msg_nonl ' . %s ... ' "${topic}"
1122 echo '*** enforced unchecked results are'
1123 if feat_val_yes ${yesno}; then
1124 if [ -n "${incs}" ] || [ -n "${libs}" ]; then
1125 echo "*** adding INCS
<${incs}> LIBS
<${libs}>"
1126 LIBS="${LIBS} ${libs}"
1127 echo "${libs}" >> ${lib}
1128 INCS="${INCS} ${incs}"
1129 echo "${incs}" >> ${inc}
1132 echo "${define}" >> ${h}
1133 eval have_${variable}=yes
1136 #echo "/* ${define} */" >> ${h}
1138 eval unset have_${variable}
1144 variable=$1 topic=$2 define=$3
1146 _check_preface "${variable}" "${topic}" "${define}"
1148 if ${make} -f ${makefile} XINCS="${INCS}" \
1149 CFLAGS
="${CFLAGS}" LDFLAGS="${LDFLAGS}" ${tmp}.o &&
1150 [ -f ${tmp}.o ]; then
1152 echo "${define}" >> ${h}
1153 eval have_${variable}=yes
1156 #echo "/* ${define} */" >> ${h}
1158 eval unset have_${variable}
1164 run=$1 variable=$2 topic=$3 define=$4 libs=$5 incs=$6
1166 _check_preface "${variable}" "${topic}" "${define}"
1168 if feat_yes CROSS_BUILD; then
1169 if [ ${run} = 1 ]; then
1174 if ${make} -f ${makefile} XINCS="${INCS} ${incs}" \
1175 CFLAGS
="${CFLAGS}" LDFLAGS
="${LDFLAGS}" \
1176 XLIBS
="${LIBS} ${libs}" ${tmp} &&
1177 [ -f ${tmp} ] && { [ ${run} -eq 0 ] || ${tmp}; }; then
1178 echo "*** adding INCS
<${incs}> LIBS<${libs}>; executed: ${run}"
1180 echo "${define}" >> ${h}
1181 LIBS="${LIBS} ${libs}"
1182 echo "${libs}" >> ${lib}
1183 INCS="${INCS} ${incs}"
1184 echo "${incs}" >> ${inc}
1185 eval have_${variable}=yes
1189 #echo "/* ${define} */" >> ${h}
1190 eval unset have_${variable}
1196 _link_mayrun 0 "${1}" "${2}" "${3}" "${4}" "${5}"
1200 _link_mayrun 1 "${1}" "${2}" "${3}" "${4}" "${5}"
1204 _link_mayrun 2 "${1}" "${2}" "${3}" "${4}" "${5}"
1208 < "${1}" > "${2}" ${awk} \
1209 'BEGIN {ORS = " "} /^[^#]/ {print} {next} END {ORS = ""; print "\n"}'
1212 ## -- >8 - <<SUPPORT FUNS | RUNNING>> - 8< -- ##
1214 # First of all, create new configuration and check whether it changed
1216 if [ -d .obj
] || mkdir .obj
; then :; else
1217 msg
'ERROR: cannot create .obj build directory'
1221 # Very easy checks for the operating system in order to be able to adjust paths
1222 # or similar very basic things which we need to be able to go at all
1225 # Check those tools right now that we need before including $rc
1226 msg
'Checking for basic utility set'
1227 thecmd_testandset_fail
awk awk
1228 thecmd_testandset_fail
rm rm
1229 thecmd_testandset_fail
tr tr
1231 # Initialize the option set
1232 msg_nonl
'Setting up configuration options ... '
1236 # Include $rc, but only take from it what wasn't overwritten by the user from
1237 # within the command line or from a chosen fixed CONFIG=
1238 # Note we leave alone the values
1239 trap "exit 1" HUP INT TERM
1240 trap "${rm} -f ${tmp}" EXIT
1242 msg_nonl
'Joining in %s ... ' ${rc}
1246 # We need to know about that now, in order to provide utility overwrites etc.
1249 msg
'Checking for remaining set of utilities'
1250 thecmd_testandset_fail
grep grep
1252 # Before we step ahead with the other utilities perform a path cleanup first.
1256 thecmd_testandset_fail
basename basename
1257 thecmd_testandset_fail
cat cat
1258 thecmd_testandset_fail
chmod chmod
1259 thecmd_testandset_fail
cp cp
1260 thecmd_testandset_fail
cmp cmp
1262 thecmd_testandset_fail mkdir mkdir
1263 thecmd_testandset_fail
mv mv
1264 # pwd(1) is needed - either for make-emerge.sh, or for ourselves
1265 [ -n "${CWDDIR}" ] || thecmd_testandset_fail
pwd pwd
1267 thecmd_testandset_fail
sed sed
1268 thecmd_testandset_fail
sort sort
1269 thecmd_testandset_fail
tee tee
1271 thecmd_testandset chown chown ||
1272 PATH
="/sbin:${PATH}" thecmd_set chown chown ||
1273 PATH
="/usr/sbin:${PATH}" thecmd_set_fail chown chown
1275 thecmd_testandset_fail MAKE
make
1278 thecmd_testandset strip strip
&& HAVE_STRIP
=1 || HAVE_STRIP
=0
1280 # For ./cc-test.sh only
1281 thecmd_testandset_fail
cksum cksum
1283 # Now that we have pwd(1), set our build paths unless make-emerge.sh has been
1284 # used; it would have created a makefile with the full paths, then
1285 [ -n "${CWDDIR}" ] || CWDDIR
=`${pwd}`/
1286 [ -n "${SRCDIR}" ] || SRCDIR
=${CWDDIR}
1288 # Update OPT_ options now, in order to get possible inter-dependencies right
1291 # (No functions since some shells loose non-exported variables in traps)
1292 trap "trap \"\" HUP INT TERM; exit 1" HUP INT TERM
1293 trap "trap \"\" HUP INT TERM EXIT;\
1294 ${rm} -rf ${newlst} ${tmp0}.* ${tmp0}* \
1295 ${newmk} ${oldmk} ${newev} ${newh} ${oldh}" EXIT
1297 # Our configuration options may at this point still contain shell snippets,
1298 # we need to evaluate them in order to get them expanded, and we need those
1299 # evaluated values not only in our new configuration file, but also at hand..
1300 msg_nonl
'Evaluating all configuration items ... '
1305 printf "#define VAL_UAGENT \"${VAL_SID}${VAL_MAILX}\"\n" >> ${newh}
1306 printf "VAL_UAGENT
= ${VAL_SID}${VAL_MAILX}\n" >> ${newmk}
1308 # The problem now is that the test should be able to run in the users linker
1309 # and path environment, so we need to place the test: rule first, before
1310 # injecting the relevant make variables. Set up necessary environment
1311 if [ -z "${VERBOSE}" ]; then
1312 printf -- "ECHO_CC = @echo ' 'CC \$(@);\n" >> ${newmk}
1313 printf -- "ECHO_LINK = @echo ' 'LINK \$(@);\n" >> ${newmk}
1314 printf -- "ECHO_GEN = @echo ' 'GEN \$(@);\n" >> ${newmk}
1315 printf -- "ECHO_TEST = @\n" >> ${newmk}
1316 printf -- "ECHO_CMD = @echo ' CMD';\n" >> ${newmk}
1317 printf -- "ECHO_BLOCK_BEGIN = @( \n" >> ${newmk}
1318 printf -- "ECHO_BLOCK_END = ) >/dev/null\n" >> ${newmk}
1320 printf 'test: all\n\t$(ECHO_TEST)%s %scc-test.sh --check-only %s\n' \
1321 "${SHELL}" "${SRCDIR}" "./${VAL_SID}${VAL_MAILX}" >> ${newmk}
1322 printf 'citest: all\n\t$(ECHO_TEST)%s %scc-test.sh --ci-test %s\n' \
1323 "${SHELL}" "${SRCDIR}" "./${VAL_SID}${VAL_MAILX}" >> ${newmk}
1325 # Add the known utility and some other variables
1326 printf "#define VAL_PRIVSEP \"${VAL_SID}${VAL_MAILX}-privsep\"\n" >> ${newh}
1327 printf "VAL_PRIVSEP
= \$
(VAL_UAGENT
)-privsep\n" >> ${newmk}
1328 if feat_yes DOTLOCK; then
1329 printf "OPTIONAL_PRIVSEP
= \$
(VAL_PRIVSEP
)\n" >> ${newmk}
1331 printf "OPTIONAL_PRIVSEP
=\n" >> ${newmk}
1336 awk basename cat chmod chown cp cmp grep mkdir mv rm sed sort tee tr \
1337 MAKE MAKEFLAGS make SHELL strip \
1340 printf -- "${i} = ${j}\n" >> ${newmk}
1341 printf -- "${i}=${j}\n" >> ${newlst}
1342 printf -- "${i}=\"${j}\";export ${i}; " >> ${newev}
1344 # Note that makefile reads and eval'uates one line of this file, whereas other
1345 # consumers source it via .(1)
1346 printf "\n" >> ${newev}
1348 # Build a basic set of INCS and LIBS according to user environment.
1349 C_INCLUDE_PATH
="${CWDDIR}:${CWDDIR}.obj:${SRCDIR}:${C_INCLUDE_PATH}"
1350 path_check C_INCLUDE_PATH
-I _INCS
1351 INCS
="${INCS} ${_INCS}"
1352 path_check LD_LIBRARY_PATH
-L _LIBS
1353 LIBS
="${LIBS} ${_LIBS}"
1355 export C_INCLUDE_PATH LD_LIBRARY_PATH
1357 # Some environments need runtime path flags to be able to go at all
1360 ## Detect CC, whether we can use it, and possibly which CFLAGS we can use
1364 ${cat} > ${tmp}.c
<< \
!
1367 static void doit
(char const
*s
);
1369 main
(int argc
, char
**argv
){
1372 doit
("Hello world");
1376 doit
(char const
*s
){
1378 memcpy
(buf
, s
, strlen
(s
) +1);
1383 if ${CC} ${INCS} ${CFLAGS} ${EXTRA_CFLAGS} ${LDFLAGS} ${EXTRA_LDFLAGS} \
1384 -o ${tmp2} ${tmp}.c ${LIBS}; then
1387 msg
'ERROR: i cannot compile a "Hello world" via'
1389 "${CC} ${INCS} ${CFLAGS} ${EXTRA_CFLAGS} ${LDFLAGS} ${EXTRA_LDFLAGS} ${LIBS}"
1390 msg
'ERROR: Please read INSTALL, rerun'
1394 # This may also update ld_runtime_flags() (again)
1402 printf -- "${i}=${j}\n" >> ${newlst}
1408 PATH C_INCLUDE_PATH LD_LIBRARY_PATH \
1412 if [ -n "${j}" ]; then
1413 printf -- "${i} = ${j}\n" >> ${newmk}
1414 printf -- "${i}=${j}\n" >> ${newlst}
1418 # Now finally check whether we already have a configuration and if so, whether
1419 # all those parameters are still the same.. or something has actually changed
1421 if [ -f ${lst} ] && ${cmp} ${newlst} ${lst} >/dev/null 2>&1; then
1422 echo 'Configuration is up-to-date'
1424 elif [ -f ${lst} ]; then
1426 echo 'Configuration has been updated..'
1428 echo 'Shiny configuration..'
1431 # Time to redefine helper 1
1433 ${rm} -f ${lst} ${h} ${mk}
1437 ${mv} -f ${newlst} ${lst}
1438 ${mv} -f ${newev} ${ev}
1439 [ -f ${h} ] && ${mv} -f ${h} ${oldh}
1440 ${mv} -f ${newh} ${h}
1441 [ -f ${mk} ] && ${mv} -f ${mk} ${oldmk}
1442 ${mv} -f ${newmk} ${mk}
1444 ## Compile and link checking
1447 log=.obj/mk-config.log
1448 lib=.obj/mk-config.lib
1449 inc=.obj/mk-config.inc
1452 # (No function since some shells loose non-exported variables in traps)
1453 trap "trap \"\" HUP INT TERM
;\
1454 ${rm} -f ${lst} ${oldh} ${h} ${oldmk} ${mk} ${lib} ${inc}; exit 1" \
1456 trap "trap \"\" HUP INT TERM EXIT
;\
1457 ${rm} -rf ${oldh} ${oldmk} ${tmp0}.* ${tmp0}*" EXIT
1459 # Time to redefine helper 2
1463 printf "*** ${fmt}\\n
" "${@}"
1464 printf -- "${fmt}\\n
" "${@}" >&5
1469 printf "*** ${fmt}\\n
" "${@}"
1470 printf -- "${fmt}" "${@}" >&5
1474 exec 5>&2 > ${log} 2>&1
1476 echo "${LIBS}" > ${lib}
1477 echo "${INCS}" > ${inc}
1478 ${cat} > ${makefile} << \!
1479 .SUFFIXES: .o .c .x .y
1481 $(CC) -I./ $(XINCS) $(CFLAGS) -o $(@) -c $(<)
1483 $(CC) -I./ $(XINCS) -E $(<) > $(@)
1485 $(CC) -I./ $(XINCS) $(CFLAGS) $(LDFLAGS) -o $(@) $(<) $(XLIBS)
1490 # May be multiline..
1492 [ -n "${OS_DEFINES}" ] && printf -- "${OS_DEFINES}" >> ${h}
1493 echo '#define VAL_BUILD_OS "'"${OS}"'"' >> ${h}
1495 # Generate n_err_number OS mappings
1498 feat_yes DEVEL
&& NV
= || NV
=noverbose
1499 SRCDIR
="${SRCDIR}" TARGET="${h}" awk="${awk}" \
1500 ${SHELL} "${SRCDIR}"make-errors.sh ${NV} config
1501 ) | xrun_check oserrno
'OS error mapping table generated' || config_exit
1
1504 feat_def ALWAYS_UNICODE_LOCALE
1505 feat_def AMALGAMATION
0
1506 feat_def CROSS_BUILD
1512 feat_def ASAN_ADDRESS
0
1513 feat_def ASAN_MEMORY
0
1519 if xrun_check inline
'inline functions' \
1520 '#define HAVE_INLINE
1521 #define n_INLINE static inline' << \
!
1522 static inline int ilf
(int i
){return ++i
;}
1523 int main
(void
){return ilf
(-1);}
1527 elif xrun_check inline
'inline functions (via __inline)' \
1528 '#define HAVE_INLINE
1529 #define n_INLINE static __inline' << \
!
1530 static __inline int ilf
(int i
){return ++i
;}
1531 int main
(void
){return ilf
(-1);}
1537 ## Test for "basic" system-calls / functionality that is used by all parts
1538 ## of our program. Once this is done fork away BASE_LIBS and other BASE_*
1539 ## macros to be used by only the subprograms (potentially).
1541 if run_check clock_gettime
'clock_gettime(2)' \
1542 '#define HAVE_CLOCK_GETTIME' << \
!
1548 if(!clock_gettime
(CLOCK_REALTIME
, &ts
) || errno
!= ENOSYS
)
1555 elif run_check clock_gettime
'clock_gettime(2) (via -lrt)' \
1556 '#define HAVE_CLOCK_GETTIME' '-lrt' << \
!
1562 if(!clock_gettime
(CLOCK_REALTIME
, &ts
) || errno
!= ENOSYS
)
1569 elif run_check gettimeofday
'gettimeofday(2)' \
1570 '#define HAVE_GETTIMEOFDAY' << \
!
1571 #include <stdio.h> /* For C89 NULL */
1572 #include <sys/time.h>
1577 if(!gettimeofday
(&tv
, NULL
) || errno
!= ENOSYS
)
1585 have_no_subsecond_time
=1
1588 if run_check nanosleep
'nanosleep(2)' \
1589 '#define HAVE_NANOSLEEP' << \
!
1596 ts.tv_nsec
= 100000;
1597 if(!nanosleep
(&ts
, NULL
) || errno
!= ENOSYS
)
1604 elif run_check nanosleep
'nanosleep(2) (via -lrt)' \
1605 '#define HAVE_NANOSLEEP' '-lrt' << \
!
1612 ts.tv_nsec
= 100000;
1613 if(!nanosleep
(&ts
, NULL
) || errno
!= ENOSYS
)
1620 # link_check is enough for this, that function is so old, trust the proto
1621 elif link_check
sleep 'sleep(3)' \
1622 '#define HAVE_SLEEP' << \
!
1626 if(!sleep(1) || errno
!= ENOSYS
)
1634 msg
'ERROR: we require one of nanosleep(2) and sleep(3).'
1638 if run_check userdb
'gete?[gu]id(2), getpwuid(3), getpwnam(3)' << \
!
1647 if((gid
= getgid
()) != 0)
1649 if((uid
= getuid
()) != 0)
1651 if((pw
= getpwuid
(uid
)) == NULL
&& errno
== ENOSYS
)
1653 if((pw
= getpwnam
("root")) == NULL
&& errno
== ENOSYS
)
1661 msg
'ERROR: we require user and group info / database searches.'
1662 msg
'That much Unix we indulge ourselfs.'
1666 if link_check ftruncate
'ftruncate(2)' \
1667 '#define HAVE_FTRUNCATE' << \
!
1669 #include <sys/types.h>
1671 return (ftruncate
(0, 0) != 0);
1677 # TODO support HAVE_FTRUNCATE *everywhere*, do not require this syscall!
1678 msg
'ERROR: we require the ftruncate(2) system call.'
1682 if run_check sa_restart
'SA_RESTART (for sigaction(2))' << \
!
1686 struct sigaction nact
, oact
;
1688 nact.sa_handler
= SIG_DFL
;
1689 sigemptyset
(&nact.sa_mask
);
1690 nact.sa_flags
= SA_RESTART
;
1691 return !(!sigaction
(SIGCHLD
, &nact
, &oact
) || errno
!= ENOSYS
);
1697 msg
'ERROR: we (yet) require the SA_RESTART flag for sigaction(2).'
1701 if link_check snprintf
'snprintf(3)' << \
!
1706 snprintf
(b
, sizeof b
, "%s", "string");
1713 msg
'ERROR: we require the snprintf(3) function.'
1717 if link_check environ
'environ(3)' << \
!
1718 #include <stdio.h> /* For C89 NULL */
1720 extern char
**environ
;
1722 return environ
[0] == NULL
;
1728 msg
'ERROR: we require the environ(3) array for subprocess control.'
1732 if link_check setenv
'(un)?setenv(3)' '#define HAVE_SETENV' << \
!
1735 setenv
("s-mailx", "i want to see it cute!", 1);
1736 unsetenv
("s-mailx");
1742 elif link_check setenv
'putenv(3)' '#define HAVE_PUTENV' << \
!
1745 putenv
("s-mailx=i want to see it cute!");
1752 msg
'ERROR: we require either the setenv(3) or putenv(3) functions.'
1756 if link_check termios
'termios.h and tc*(3) family' << \
!
1757 #include <termios.h>
1759 struct termios tios
;
1761 tcgetattr
(0, &tios
);
1762 tcsetattr
(0, TCSANOW | TCSADRAIN | TCSAFLUSH
, &tios
);
1769 msg
'ERROR: we require termios.h and the tc[gs]etattr() family of functions.'
1770 msg
'That much Unix we indulge ourselfs.'
1776 if link_check vsnprintf
'vsnprintf(3)' << \
!
1779 static void dome
(char
*buf
, size_t blen
, ...
){
1783 vsnprintf
(buf
, blen
, "%s", ap
);
1789 dome
(b
, sizeof b
, "string");
1796 feat_bail_required ERRORS
1799 if [ "${have_vsnprintf}" = yes ]; then
1801 link_check va_copy
"va_copy(3) (as ${2})" \
1802 "#define HAVE_N_VA_COPY
1803 #define n_va_copy ${2}" <<_EOT
1807 # if defined __va_copy && !defined va_copy
1808 # define va_copy __va_copy
1811 static void dome2(char *buf, size_t blen, va_list src){
1815 vsnprintf(buf, blen, "%s", ap);
1818 static void dome(char *buf, size_t blen, ...){
1822 dome2(buf, blen, ap);
1828 dome(b, sizeof b, "string");
1833 __va_copy
0 va_copy || __va_copy
1 __va_copy
1836 run_check pathconf
'f?pathconf(2)' '#define HAVE_PATHCONF' << \
!
1843 rv |
= !(pathconf
(".", _PC_NAME_MAX
) >= 0 || errno
== 0 || errno
!= ENOSYS
);
1845 rv |
= !(pathconf
(".", _PC_PATH_MAX
) >= 0 || errno
== 0 || errno
!= ENOSYS
);
1847 /* Only link check
*/
1848 fpathconf
(0, _PC_NAME_MAX
);
1854 run_check pipe2
'pipe2(2)' '#define HAVE_PIPE2' << \
!
1861 if(!pipe2
(fds
, O_CLOEXEC
) || errno
!= ENOSYS
)
1867 link_check tcgetwinsize
'tcgetwinsize(3)' '#define HAVE_TCGETWINSIZE' << \
!
1868 #include <termios.h>
1872 tcgetwinsize
(0, &ws
);
1877 # We use this only then for now (need NOW+1)
1878 run_check utimensat
'utimensat(2)' '#define HAVE_UTIMENSAT' << \
!
1879 #include <fcntl.h> /* For AT_* */
1880 #include <sys/stat.h>
1883 struct timespec ts
[2];
1885 ts
[0].tv_nsec
= UTIME_NOW
;
1886 ts
[1].tv_nsec
= UTIME_OMIT
;
1887 if(!utimensat
(AT_FDCWD
, "", ts
, 0) || errno
!= ENOSYS
)
1895 # The random check has been moved to below SSL detection due to multiple choice
1896 # selection for PRG sources
1898 link_check putc_unlocked
'putc_unlocked(3)' '#define HAVE_PUTC_UNLOCKED' <<\
!
1901 putc_unlocked
('@', stdout
);
1906 link_check fchdir
'fchdir(3)' '#define HAVE_FCHDIR' << \
!
1914 if link_check realpath
'realpath(3)' '#define HAVE_REALPATH' << \
!
1917 char x_buf
[4096], *x
= realpath
(".", x_buf
);
1919 return (x
!= NULL
) ?
0 : 1;
1923 if run_check realpath_malloc
'realpath(3) takes NULL' \
1924 '#define HAVE_REALPATH_NULL' << \
!
1927 char
*x
= realpath
(".", NULL
);
1931 return (x
!= NULL
) ?
0 : 1;
1940 ## optional and selectable
1943 if feat_yes DOTLOCK
; then
1944 if run_check readlink
'readlink(2)' << \
!
1950 if(!readlink
("here", buf
, sizeof buf
) || errno
!= ENOSYS
)
1958 feat_bail_required DOTLOCK
1962 if feat_yes DOTLOCK
; then
1963 if run_check fchown
'fchown(2)' << \
!
1967 if(!fchown
(0, 0, 0) || errno
!= ENOSYS
)
1975 feat_bail_required DOTLOCK
1979 if feat_yes DOTLOCK
; then
1980 if run_check prctl_dumpable
'prctl(2) + PR_SET_DUMPABLE' \
1981 '#define HAVE_PRCTL_DUMPABLE' << \
!
1982 #include <sys/prctl.h>
1985 if(!prctl
(PR_SET_DUMPABLE
, 0) || errno
!= ENOSYS
)
1992 elif run_check prtrace_deny
'ptrace(2) + PT_DENY_ATTACH' \
1993 '#define HAVE_PTRACE_DENY' << \
!
1994 #include <sys/ptrace.h>
1997 if(ptrace
(PT_DENY_ATTACH
, 0, 0, 0) != -1 || errno
!= ENOSYS
)
2004 elif run_check setpflags_protect
'setpflags(2) + __PROC_PROTECT' \
2005 '#define HAVE_SETPFLAGS_PROTECT' << \
!
2009 if(!setpflags
(__PROC_PROTECT
, 1) || errno
!= ENOSYS
)
2019 ## Now it is the time to fork away the BASE_ series
2022 squeeze_em
${inc} ${tmp}
2024 squeeze_em
${lib} ${tmp}
2027 echo "BASE_LIBS = `${cat} ${lib}`" >> ${mk}
2028 echo "BASE_INCS
= `${cat} ${inc}`" >> ${mk}
2030 ## The remains are expected to be used only by the main MUA binary!
2033 link_check setlocale 'setlocale(3)' '#define HAVE_SETLOCALE' << \!
2036 setlocale(LC_ALL, "");
2040 [ -n "${have_setlocale}" ] && OPT_LOCALES=1
2042 OPT_MULTIBYTE_CHARSETS=0
2044 OPT_TERMINAL_CHARSET=0
2045 if [ -n "${have_setlocale}" ]; then
2046 link_check c90amend1 'ISO/IEC 9899:1990/Amendment 1:1995' \
2047 '#define HAVE_C90AMEND1' << \!
2053 char mbb[MB_LEN_MAX + 1];
2058 mbtowc(&wc, "x", 1);
2059 mbrtowc(&wc, "x", 1, NULL);
2061 return (mblen("\0", 1) == 0);
2064 [ -n "${have_c90amend1}" ] && OPT_MULTIBYTE_CHARSETS=1
2066 if [ -n "${have_c90amend1}" ]; then
2067 link_check wcwidth 'wcwidth(3)' '#define HAVE_WCWIDTH' << \!
2074 [ -n "${have_wcwidth}" ] && OPT_WIDE_GLYPHS=1
2077 link_check nl_langinfo 'nl_langinfo(3)' '#define HAVE_NL_LANGINFO' << \!
2078 #include <langinfo.h>
2082 return (nl_langinfo(CODESET) == NULL);
2085 [ -n "${have_nl_langinfo}" ] && OPT_TERMINAL_CHARSET=1
2088 link_check fnmatch 'fnmatch(3)' '#define HAVE_FNMATCH' << \!
2089 #include <fnmatch.h>
2091 return (fnmatch("*", ".", FNM_PATHNAME | FNM_PERIOD) == FNM_NOMATCH);
2095 link_check dirent_d_type 'struct dirent.d_type' '#define HAVE_DIRENT_TYPE' << \!
2099 return !(de.d_type == DT_UNKNOWN ||
2100 de.d_type == DT_DIR || de.d_type == DT_LNK);
2104 ## optional and selectable
2106 if feat_yes ICONV; then
2107 # To be able to create tests we need to figure out which replacement
2108 # sequence the iconv(3) implementation creates
2109 ${cat} > ${tmp2}.c << \!
2110 #include <stdio.h> /* For C89 NULL */
2114 char inb[16], oub[16], *inbp, *oubp;
2118 memcpy(inbp = inb, "\342\200\223", sizeof("\342\200\223"));
2119 inl = sizeof("\342\200\223") -1;
2123 if((id = iconv_open("ascii", "utf-8")) == (iconv_t)-1)
2125 if(iconv(id, &inbp, &inl, &oubp, &oul) == (size_t)-1)
2130 oul = (size_t)(oubp - oub);
2133 /* Character-wise replacement? */
2141 /* Byte-wise replacement? */
2142 if(oul == sizeof("\342\200\223") -1){
2143 if(!memcmp(oub, "???????", sizeof("\342\200\223") -1))
2145 if(!memcmp(oub, "*******", sizeof("\342\200\223") -1))
2152 < ${tmp2}.c link_check iconv 'iconv(3) functionality' \
2153 '#define HAVE_ICONV' ||
2154 < ${tmp2}.c link_check iconv 'iconv(3) functionality (via -liconv)' \
2155 '#define HAVE_ICONV' '-liconv' ||
2156 feat_bail_required ICONV
2158 if feat_no CROSS_BUILD; then
2159 { ${tmp}; } >/dev/null 2>&1
2161 2) echo 'MAILX_ICONV_MODE=2;export MAILX_ICONV_MODE;' >> ${ev};;
2162 3) echo 'MAILX_ICONV_MODE=3;export MAILX_ICONV_MODE;' >> ${ev};;
2163 12) echo 'MAILX_ICONV_MODE=12;export MAILX_ICONV_MODE;' >> ${ev};;
2164 13) echo 'MAILX_ICONV_MODE=13;export MAILX_ICONV_MODE;' >> ${ev};;
2165 *) msg 'WARN: will restrict iconv(3) tests due to unknown replacement';;
2169 feat_is_disabled ICONV
2172 if feat_yes SOCKETS || feat_yes SPAM_SPAMD; then
2173 ${cat} > ${tmp2}.c << \!
2174 #include <sys/types.h>
2175 #include <sys/socket.h>
2179 struct sockaddr_un soun;
2181 if(socket(AF_UNIX, SOCK_STREAM, 0) == -1 && errno == ENOSYS)
2183 if(connect(0, (struct sockaddr*)&soun, 0) == -1 && errno == ENOSYS)
2185 if(shutdown(0, SHUT_RD | SHUT_WR | SHUT_RDWR) == -1 && errno == ENOSYS)
2191 < ${tmp2}.c run_check af_unix 'AF_UNIX sockets' \
2192 '#define HAVE_UNIX_SOCKETS' ||
2193 < ${tmp2}.c run_check af_unix 'AF_UNIX sockets (via -lnsl)' \
2194 '#define HAVE_UNIX_SOCKETS' '-lnsl' ||
2195 < ${tmp2}.c run_check af_unix 'AF_UNIX sockets (via -lsocket -lnsl)' \
2196 '#define HAVE_UNIX_SOCKETS' '-lsocket -lnsl'
2199 if feat_yes SOCKETS; then
2200 ${cat} > ${tmp2}.c << \!
2201 #include <sys/types.h>
2202 #include <sys/socket.h>
2203 #include <netinet/in.h>
2208 if(socket(AF_INET, SOCK_STREAM, 0) == -1 && errno == ENOSYS)
2210 if(connect(0, &s, 0) == -1 && errno == ENOSYS)
2216 < ${tmp2}.c run_check sockets 'sockets' \
2217 '#define HAVE_SOCKETS' ||
2218 < ${tmp2}.c run_check sockets 'sockets (via -lnsl)' \
2219 '#define HAVE_SOCKETS' '-lnsl' ||
2220 < ${tmp2}.c run_check sockets 'sockets (via -lsocket -lnsl)' \
2221 '#define HAVE_SOCKETS' '-lsocket -lnsl' ||
2222 feat_bail_required SOCKETS
2224 feat_is_disabled SOCKETS
2225 fi # feat_yes SOCKETS
2228 link_check sockopt '[gs]etsockopt(2)' '#define HAVE_SOCKOPT' << \!
2229 #include <sys/socket.h>
2234 int sockfd = 3, soe;
2237 if(getsockopt(sockfd, SOL_SOCKET, SO_ERROR, &soe, &sol) == -1 &&
2240 if(setsockopt(sockfd, SOL_SOCKET, SO_KEEPALIVE, NULL, 0) == -1 &&
2248 link_check nonblocksock 'non-blocking sockets' \
2249 '#define HAVE_NONBLOCKSOCK' << \!
2250 #include <sys/types.h>
2251 #include <sys/select.h>
2252 #include <sys/socket.h>
2253 #include <sys/time.h>
2254 #include <arpa/inet.h>
2255 #include <netinet/in.h>
2263 struct sockaddr_in sin;
2267 if((sofd = socket(AF_INET, SOCK_STREAM, 0)) == -1 && errno == ENOSYS)
2269 if(fcntl(sofd, F_SETFL, O_NONBLOCK) != 0)
2272 sin.sin_family = AF_INET;
2273 sin.sin_addr.s_addr = inet_addr("127.0.0.1");
2274 sin.sin_port = htons(80);
2275 if(connect(sofd, &sin, sizeof sin) == -1 && errno == ENOSYS)
2279 FD_SET(sofd, &fdset);
2282 if((soe = select(sofd + 1, NULL, &fdset, NULL, &tv)) == 1){
2284 getsockopt(sofd, SOL_SOCKET, SO_ERROR, &soe, &sol);
2287 }else if(soe == -1 && errno == ENOSYS)
2295 if feat_yes SOCKETS; then
2296 link_check getaddrinfo 'getaddrinfo(3)' \
2297 '#define HAVE_GETADDRINFO' << \!
2298 #include <sys/types.h>
2299 #include <sys/socket.h>
2303 struct addrinfo a, *ap;
2306 switch((lrv = getaddrinfo("foo", "0", &a, &ap))){
2310 fprintf(stderr, "%s\n", gai_strerror(lrv));
2319 if feat_yes SOCKETS && [ -z "${have_getaddrinfo}" ]; then
2320 compile_check arpa_inet_h '<arpa/inet.h>' \
2321 '#define HAVE_ARPA_INET_H' << \!
2322 #include <sys/types.h>
2323 #include <sys/socket.h>
2325 #include <netinet/in.h>
2326 #include <arpa/inet.h>
2329 ${cat} > ${tmp2}.c << \!
2330 #include <sys/types.h>
2331 #include <sys/socket.h>
2335 #include <netinet/in.h>
2336 #ifdef HAVE_ARPA_INET_H
2337 #include <arpa/inet.h>
2340 struct sockaddr_in servaddr;
2341 unsigned short portno;
2344 struct in_addr **pptr;
2347 if((ep = getservbyname("POPPY-PORT", "tcp")) != NULL)
2348 portno = (unsigned short)ep->s_port;
2350 if((hp = gethostbyname("POPPY-HOST")) != NULL){
2351 pptr = (struct in_addr**)hp->h_addr_list;
2352 if(hp->h_addrtype != AF_INET)
2353 fprintf(stderr, "au\n");
2356 case HOST_NOT_FOUND:
2362 fprintf(stderr, "au\n");
2367 memset(&servaddr, 0, sizeof servaddr);
2368 servaddr.sin_family = AF_INET;
2369 servaddr.sin_port = htons(portno);
2370 memcpy(&servaddr.sin_addr, *pptr, sizeof(struct in_addr));
2371 fprintf(stderr, "Would connect to %s:%d ...\n",
2372 inet_ntoa(**pptr), (int)portno);
2377 < ${tmp2}.c link_check gethostbyname 'get(serv|host)byname(3)' ||
2378 < ${tmp2}.c link_check gethostbyname \
2379 'get(serv|host)byname(3) (via -nsl)' '' '-lnsl' ||
2380 < ${tmp2}.c link_check gethostbyname \
2381 'get(serv|host)byname(3) (via -lsocket -nsl)' \
2382 '' '-lsocket -lnsl' ||
2383 feat_bail_required SOCKETS
2386 feat_yes SOCKETS && [ -n "${have_sockopt}" ] &&
2387 link_check so_xtimeo 'SO_{RCV,SND}TIMEO' '#define HAVE_SO_XTIMEO' << \!
2388 #include <sys/socket.h>
2396 setsockopt(sockfd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof tv);
2397 setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof tv);
2402 feat_yes SOCKETS && [ -n "${have_sockopt}" ] &&
2403 link_check so_linger 'SO_LINGER' '#define HAVE_SO_LINGER' << \!
2404 #include <sys/socket.h>
2412 setsockopt(sockfd, SOL_SOCKET, SO_LINGER, &li, sizeof li);
2418 if feat_yes SSL; then # {{{
2419 # {{{ LibreSSL decided to define OPENSSL_VERSION_NUMBER with a useless value
2420 # instead of keeping it at the one that corresponds to the OpenSSL at fork
2421 # time: we need to test it first in order to get things right
2422 if compile_check _xssl 'TLS/SSL (LibreSSL)' \
2425 #define HAVE_XSSL_RESSL
2426 #define HAVE_XSSL_OPENSSL 0' << \!
2427 #include <openssl/opensslv.h>
2428 #ifdef LIBRESSL_VERSION_NUMBER
2435 VAL_SSL_FEATURES=libressl
2436 # TODO OPENSSL_IS_BORINGSSL, but never tried that one!
2437 elif compile_check _xssl 'TLS/SSL (OpenSSL >= v1.1.0)' \
2440 #define HAVE_XSSL_OPENSSL 0x10100' << \!
2441 #include <openssl/opensslv.h>
2442 #if OPENSSL_VERSION_NUMBER + 0 >= 0x10100000L
2449 VAL_SSL_FEATURES=libssl-0x10100
2450 elif compile_check _xssl 'TLS/SSL (OpenSSL)' \
2453 #define HAVE_XSSL_OPENSSL 0x10000' << \!
2454 #include <openssl/opensslv.h>
2455 #ifdef OPENSSL_VERSION_NUMBER
2462 VAL_SSL_FEATURES=libssl-0x10000
2464 feat_bail_required SSL
2467 if feat_yes SSL; then # {{{
2468 if [ -n "${ossl_v1_1}" ]; then
2469 without_check yes xssl 'TLS/SSL new style TLS_client_method(3ssl)' \
2470 '#define n_XSSL_CLIENT_METHOD TLS_client_method' \
2472 elif link_check xssl 'TLS/SSL new style TLS_client_method(3ssl)' \
2473 '#define n_XSSL_CLIENT_METHOD TLS_client_method' \
2474 '-lssl -lcrypto' << \!
2475 #include <openssl/ssl.h>
2476 #include <openssl/err.h>
2477 #include <openssl/x509v3.h>
2478 #include <openssl/x509.h>
2479 #include <openssl/rand.h>
2480 #ifdef OPENSSL_NO_TLS1 /* TODO only deduced from OPENSSL_NO_SSL[23]! */
2481 # error We need TLSv1.
2484 SSL_CTX *ctx = SSL_CTX_new(TLS_client_method());
2487 PEM_read_PrivateKey(0, 0, 0, 0);
2493 elif link_check xssl 'TLS/SSL old style SSLv23_client_method(3ssl)' \
2494 '#define n_XSSL_CLIENT_METHOD SSLv23_client_method' \
2495 '-lssl -lcrypto' << \!
2496 #include <openssl/ssl.h>
2497 #include <openssl/err.h>
2498 #include <openssl/x509v3.h>
2499 #include <openssl/x509.h>
2500 #include <openssl/rand.h>
2501 #if defined OPENSSL_NO_SSL3 &&\
2502 defined OPENSSL_NO_TLS1 /* TODO only deduced from OPENSSL_NO_SSL[23]! */
2503 # error We need one of SSLv3 and TLSv1.
2506 SSL_CTX *ctx = SSL_CTX_new(SSLv23_client_method());
2509 PEM_read_PrivateKey(0, 0, 0, 0);
2516 feat_bail_required SSL
2520 if feat_yes SSL; then # {{{
2521 if feat_yes SSL_ALL_ALGORITHMS; then
2522 if [ -n "${ossl_v1_1}" ]; then
2523 without_check yes ssl_all_algo 'TLS/SSL all-algorithms support' \
2524 '#define HAVE_SSL_ALL_ALGORITHMS'
2525 elif link_check ssl_all_algo 'TLS/SSL all-algorithms support' \
2526 '#define HAVE_SSL_ALL_ALGORITHMS' << \!
2527 #include <openssl/evp.h>
2529 OpenSSL_add_all_algorithms();
2530 EVP_get_cipherbyname("two cents i never exist");
2538 feat_bail_required SSL_ALL_ALGORITHMS
2540 elif [ -n "${ossl_v1_1}" ]; then
2541 without_check yes ssl_all_algo \
2542 'TLS/SSL all-algorithms (always available in v1.1.0+)' \
2543 '#define HAVE_SSL_ALL_ALGORITHMS'
2546 if [ -n "${ossl_v1_1}" ]; then
2547 without_check yes xssl_stack_of 'TLS/SSL STACK_OF()' \
2548 '#define HAVE_XSSL_STACK_OF'
2549 elif compile_check xssl_stack_of 'TLS/SSL STACK_OF()' \
2550 '#define HAVE_XSSL_STACK_OF' << \!
2551 #include <stdio.h> /* For C89 NULL */
2552 #include <openssl/ssl.h>
2553 #include <openssl/err.h>
2554 #include <openssl/x509v3.h>
2555 #include <openssl/x509.h>
2556 #include <openssl/rand.h>
2558 STACK_OF(GENERAL_NAME) *gens = NULL;
2560 printf("%p", gens); /* to use it */
2568 if [ -n "${ossl_v1_1}" ]; then
2569 without_check yes xssl_conf 'TLS/SSL OpenSSL_modules_load_file(3ssl)' \
2570 '#define HAVE_XSSL_CONFIG'
2571 VAL_SSL_FEATURES="${VAL_SSL_FEATURES},+modules-load-file"
2572 elif link_check xssl_conf \
2573 'TLS/SSL OpenSSL_modules_load_file(3ssl) support' \
2574 '#define HAVE_XSSL_CONFIG' << \!
2575 #include <stdio.h> /* For C89 NULL */
2576 #include <openssl/conf.h>
2578 CONF_modules_load_file(NULL, NULL, CONF_MFLAGS_IGNORE_MISSING_FILE);
2579 CONF_modules_free();
2584 VAL_SSL_FEATURES="${VAL_SSL_FEATURES},+modules-load-file"
2586 VAL_SSL_FEATURES="${VAL_SSL_FEATURES},-modules-load-file"
2589 if [ -n "${ossl_v1_1}" ]; then
2590 without_check yes xssl_conf_ctx 'TLS/SSL SSL_CONF_CTX support' \
2591 '#define HAVE_XSSL_CONF_CTX'
2592 VAL_SSL_FEATURES="${VAL_SSL_FEATURES},+conf-ctx"
2593 elif link_check xssl_conf_ctx 'TLS/SSL SSL_CONF_CTX support' \
2594 '#define HAVE_XSSL_CONF_CTX' << \!
2595 #include <openssl/ssl.h>
2596 #include <openssl/err.h>
2598 SSL_CTX *ctx = SSL_CTX_new(n_XSSL_CLIENT_METHOD());
2599 SSL_CONF_CTX *cctx = SSL_CONF_CTX_new();
2601 SSL_CONF_CTX_set_flags(cctx,
2602 SSL_CONF_FLAG_FILE | SSL_CONF_FLAG_CLIENT |
2603 SSL_CONF_FLAG_CERTIFICATE | SSL_CONF_FLAG_SHOW_ERRORS);
2604 SSL_CONF_CTX_set_ssl_ctx(cctx, ctx);
2605 SSL_CONF_cmd(cctx, "Protocol", "ALL");
2606 SSL_CONF_CTX_finish(cctx);
2607 SSL_CONF_CTX_free(cctx);
2613 VAL_SSL_FEATURES="${VAL_SSL_FEATURES},+conf-ctx"
2615 VAL_SSL_FEATURES="${VAL_SSL_FEATURES},-conf-ctx"
2618 if [ -n "${ossl_v1_1}" ]; then
2619 without_check yes xssl_ctx_config 'TLS/SSL SSL_CTX_config(3ssl)' \
2620 '#define HAVE_XSSL_CTX_CONFIG'
2621 VAL_SSL_FEATURES="${VAL_SSL_FEATURES},+ctx-config"
2622 elif [ -n "${have_xssl_conf}" ] && [ -n "${have_xssl_conf_ctx}" ] &&
2623 link_check xssl_ctx_config 'TLS/SSL SSL_CTX_config(3ssl)' \
2624 '#define HAVE_XSSL_CTX_CONFIG' << \!
2625 #include <stdio.h> /* For C89 NULL */
2626 #include <openssl/ssl.h>
2628 SSL_CTX_config(NULL, "SOMEVAL");
2633 VAL_SSL_FEATURES="${VAL_SSL_FEATURES},+ctx-config"
2635 VAL_SSL_FEATURES="${VAL_SSL_FEATURES},-ctx-config"
2638 if [ -n "${ossl_v1_1}" ] && [ -n "${have_xssl_conf_ctx}" ]; then
2639 without_check yes xssl_set_maxmin_proto \
2640 'TLS/SSL SSL_CTX_set_min_proto_version(3ssl)' \
2641 '#define HAVE_XSSL_SET_MIN_PROTO_VERSION'
2642 VAL_SSL_FEATURES="${VAL_SSL_FEATURES},+ctx-set-maxmin-proto"
2643 elif link_check xssl_set_maxmin_proto \
2644 'TLS/SSL SSL_CTX_set_min_proto_version(3ssl)' \
2645 '#define HAVE_XSSL_SET_MIN_PROTO_VERSION' << \!
2646 #include <stdio.h> /* For C89 NULL */
2647 #include <openssl/ssl.h>
2649 SSL_CTX_set_min_proto_version(NULL, 0);
2650 SSL_CTX_set_max_proto_version(NULL, 10);
2655 VAL_SSL_FEATURES="${VAL_SSL_FEATURES},+ctx-set-maxmin-proto"
2657 VAL_SSL_FEATURES="${VAL_SSL_FEATURES},-ctx-set-maxmin-proto"
2660 if [ -n "${ossl_v1_1}" ] && [ -n "${have_xssl_conf_ctx}" ]; then
2661 without_check yes xssl_set_ciphersuites \
2662 'TLSv1.3 SSL_CTX_set_ciphersuites(3ssl)' \
2663 '#define HAVE_XSSL_SET_CIPHERSUITES'
2664 VAL_SSL_FEATURES="${VAL_SSL_FEATURES},+ctx-set-ciphersuites"
2665 elif link_check xssl_set_ciphersuites \
2666 'TLSv1.3 SSL_CTX_set_ciphersuites(3ssl)' \
2667 '#define HAVE_XSSL_SET_CIPHERSUITES' << \!
2668 #include <stdio.h> /* For C89 NULL */
2669 #include <openssl/ssl.h>
2671 SSL_CTX_set_ciphersuites(NULL, NULL);
2676 VAL_SSL_FEATURES="${VAL_SSL_FEATURES},+ctx-set-ciphersuites"
2678 VAL_SSL_FEATURES="${VAL_SSL_FEATURES},-ctx-set-ciphersuites"
2681 if link_check xssl_rand_egd 'TLS/SSL RAND_egd(3ssl)' \
2682 '#define HAVE_XSSL_RAND_EGD' << \!
2683 #include <openssl/rand.h>
2685 return RAND_egd("some.where") > 0;
2689 VAL_SSL_FEATURES="${VAL_SSL_FEATURES},+rand-egd"
2691 VAL_SSL_FEATURES="${VAL_SSL_FEATURES},-rand-egd"
2693 fi # feat_yes SSL }}}
2695 if feat_yes SSL && feat_yes MD5 && feat_no NOEXTMD5; then # {{{
2696 run_check ssl_md5 'MD5 digest in the used crypto library' \
2697 '#define HAVE_XSSL_MD5' << \!
2700 #include <openssl/md5.h>
2702 char const dat[] = "abrakadabrafidibus";
2703 char dig[16], hex[16 * 2];
2707 memset(dig, 0, sizeof(dig));
2708 memset(hex, 0, sizeof(hex));
2710 MD5_Update(&ctx, dat, sizeof(dat) - 1);
2711 MD5_Final(dig, &ctx);
2713 #define hexchar(n) ((n) > 9 ? (n) - 10 + 'a' : (n) + '0')
2714 for(i = 0; i < sizeof(hex) / 2; i++){
2716 hex[j] = hexchar((dig[i] & 0xf0) >> 4);
2717 hex[++j] = hexchar(dig[i] & 0x0f);
2719 return !!memcmp("6d7d0a3d949da2e96f2aa010f65d8326", hex, sizeof(hex));
2724 if feat_yes SSL; then
2725 feat_def SSL_ALL_ALGORITHMS
2727 feat_bail_required SSL_ALL_ALGORITHMS
2730 feat_is_disabled SSL
2731 feat_is_disabled SSL_ALL_ALGORITHMS
2732 fi # }}} feat_yes SSL
2733 printf '#define VAL_SSL_FEATURES "#'"${VAL_SSL_FEATURES}"'"\n' >> ${h}
2735 if [ "${have_xssl}" = yes ]; then
2743 if val_allof VAL_RANDOM \
2744 "arc4,ssl,libgetrandom,sysgetrandom,urandom,builtin,error"; then
2747 msg 'ERROR: VAL_RANDOM with invalid entries: %s' "${VAL_RANDOM}"
2752 link_check arc4random 'VAL_RANDOM: arc4random(3)' \
2753 '#define HAVE_RANDOM n_RANDOM_IMPL_ARC4' << \!
2763 if feat_yes SSL; then
2764 msg ' . VAL_RANDOM: ssl ... yes'
2765 echo '#define HAVE_RANDOM n_RANDOM_IMPL_SSL' >> ${h}
2768 msg ' . VAL_RANDOM: ssl ... no'
2773 val_random_libgetrandom() {
2774 link_check getrandom 'VAL_RANDOM: getrandom(3) (in sys/random.h)' \
2775 '#define HAVE_RANDOM n_RANDOM_IMPL_GETRANDOM
2776 #define n_RANDOM_GETRANDOM_FUN(B,S) getrandom(B, S, 0)
2777 #define n_RANDOM_GETRANDOM_H <sys/random.h>' <<\!
2778 #include <sys/random.h>
2781 getrandom(buf, sizeof buf, 0);
2787 val_random_sysgetrandom() {
2788 link_check getrandom 'VAL_RANDOM: getrandom(2) (via syscall(2))' \
2789 '#define HAVE_RANDOM n_RANDOM_IMPL_GETRANDOM
2790 #define n_RANDOM_GETRANDOM_FUN(B,S) syscall(SYS_getrandom, B, S, 0)
2791 #define n_RANDOM_GETRANDOM_H <sys/syscall.h>' <<\!
2792 #include <sys/syscall.h>
2795 syscall(SYS_getrandom, buf, sizeof buf, 0);
2801 val_random_urandom() {
2802 msg_nonl ' . VAL_RANDOM: /dev/urandom ... '
2803 if feat_yes CROSS_BUILD; then
2804 msg 'yes (unchecked)'
2805 echo '#define HAVE_RANDOM n_RANDOM_IMPL_URANDOM' >> ${h}
2806 elif [ -f /dev/urandom ]; then
2808 echo '#define HAVE_RANDOM n_RANDOM_IMPL_URANDOM' >> ${h}
2816 val_random_builtin() {
2817 msg_nonl ' . VAL_RANDOM: builtin ... '
2818 if [ -n "${have_no_subsecond_time}" ]; then
2819 msg 'no\nERROR: %s %s' 'without a specialized PRG ' \
2820 'one of clock_gettime(2) and gettimeofday(2) is required.'
2824 echo '#define HAVE_RANDOM n_RANDOM_IMPL_BUILTIN' >> ${h}
2828 val_random_error() {
2829 msg 'ERROR: VAL_RANDOM search reached "error" entry'
2835 VAL_RANDOM="${VAL_RANDOM},error"
2836 set -- ${VAL_RANDOM}
2840 eval val_random_$randfun && break
2848 if feat_yes GSSAPI; then
2849 ${cat} > ${tmp2}.c << \!
2850 #include <gssapi/gssapi.h>
2852 gss_import_name(0, 0, GSS_C_NT_HOSTBASED_SERVICE, 0);
2853 gss_init_sec_context(0,0,0,0,0,0,0,0,0,0,0,0,0);
2857 ${sed} -e '1s/gssapi\///' < ${tmp2}.c > ${tmp3}.c
2859 if acmd_set i krb5-config; then
2860 GSS_LIBS="`CFLAGS
= ${i} --libs gssapi
`"
2861 GSS_INCS="`CFLAGS
= ${i} --cflags`"
2862 i='GSS-API via krb5-config(1)'
2866 i='GSS-API in gssapi/gssapi.h, libgssapi'
2868 if < ${tmp2}.c link_check gss \
2869 "${i}" '#define HAVE_GSSAPI' "${GSS_LIBS}" "${GSS_INCS}" ||\
2870 < ${tmp3}.c link_check gss \
2871 'GSS-API in gssapi.h, libgssapi' \
2872 '#define HAVE_GSSAPI
2873 #define GSSAPI_REG_INCLUDE' \
2875 < ${tmp2}.c link_check gss 'GSS-API in libgssapi_krb5' \
2876 '#define HAVE_GSSAPI' \
2878 < ${tmp3}.c link_check gss \
2879 'GSS-API in libgssapi, OpenBSD-style (pre 5.3)' \
2880 '#define HAVE_GSSAPI
2881 #define GSS_REG_INCLUDE' \
2882 '-lgssapi -lkrb5 -lcrypto' \
2883 '-I/usr/include/kerberosV' ||\
2884 < ${tmp2}.c link_check gss 'GSS-API in libgss' \
2885 '#define HAVE_GSSAPI' \
2887 link_check gss 'GSS-API in libgssapi_krb5, old-style' \
2888 '#define HAVE_GSSAPI
2889 #define GSSAPI_OLD_STYLE' \
2890 '-lgssapi_krb5' << \!
2891 #include <gssapi/gssapi.h>
2892 #include <gssapi/gssapi_generic.h>
2894 gss_import_name(0, 0, gss_nt_service_name, 0);
2895 gss_init_sec_context(0,0,0,0,0,0,0,0,0,0,0,0,0);
2902 feat_bail_required GSSAPI
2905 feat_is_disabled GSSAPI
2906 fi # feat_yes GSSAPI
2911 if feat_yes IDNA; then # {{{
2912 if val_allof VAL_IDNA "idnkit,idn2,idn"; then
2915 msg 'ERROR: VAL_IDNA with invalid entries: %s' "${VAL_IDNA}"
2920 link_check idna 'OPT_IDNA: GNU Libidn2' \
2921 '#define HAVE_IDNA n_IDNA_IMPL_LIBIDN2' '-lidn2' << \!
2924 char *idna_utf8, *idna_lc;
2926 if(idn2_to_ascii_8z("does.this.work", &idna_utf8,
2927 IDN2_NONTRANSITIONAL | IDN2_TRANSITIONAL) != IDN2_OK)
2929 if(idn2_to_unicode_8zlz(idna_utf8, &idna_lc, 0) != IDN2_OK)
2932 idn2_free(idna_utf8);
2939 link_check idna 'OPT_IDNA: GNU Libidn' \
2940 '#define HAVE_IDNA n_IDNA_IMPL_LIBIDN' '-lidn' << \!
2942 #include <idn-free.h>
2943 #include <stringprep.h> /* XXX we actually use our own iconv instead */
2945 char *utf8, *idna_ascii, *idna_utf8;
2947 utf8 = stringprep_locale_to_utf8("does.this.work");
2948 if (idna_to_ascii_8z(utf8, &idna_ascii, IDNA_USE_STD3_ASCII_RULES)
2951 idn_free(idna_ascii);
2952 /* (Rather link check only here) */
2953 idna_utf8 = stringprep_convert(idna_ascii, "UTF-8", "de_DE");
2960 link_check idna 'OPT_IDNA: idnkit' \
2961 '#define HAVE_IDNA n_IDNA_IMPL_IDNKIT' '-lidnkit' << \!
2963 #include <idn/api.h>
2964 #include <idn/result.h>
2968 char local_name[256];
2970 r = idn_encodename(IDN_ENCODE_APP, "does.this.work", ace_name,
2972 if (r != idn_success) {
2973 fprintf(stderr, "idn_encodename failed: %s\n", idn_result_tostring(r));
2976 r = idn_decodename(IDN_DECODE_APP, ace_name, local_name, sizeof(local_name));
2977 if (r != idn_success) {
2978 fprintf(stderr, "idn_decodename failed: %s\n", idn_result_tostring(r));
2987 feat_bail_required IDNA
2992 VAL_IDNA="${VAL_IDNA},bye"
2997 eval val_idna_$randfun && break
3000 feat_is_disabled IDNA
3003 feat_def IMAP_SEARCH
3005 if feat_yes REGEX; then
3006 if link_check regex 'regular expressions' '#define HAVE_REGEX' << \!
3014 status = regcomp(&re, ".*bsd", REG_EXTENDED | REG_ICASE | REG_NOSUB);
3015 xret = regerror(status, &re, NULL, 0);
3016 status = regexec(&re, "plan9", 0,NULL, 0);
3018 return !(status == REG_NOMATCH);
3024 feat_bail_required REGEX
3027 feat_is_disabled REGEX
3030 if feat_yes MLE; then
3031 if [ -n "${have_c90amend1}" ]; then
3033 echo '#define HAVE_MLE' >> ${h}
3035 feat_bail_required MLE
3038 feat_is_disabled MLE
3041 # Generic have-a-line-editor switch for those who need it below
3042 if [ -n "${have_mle}" ]; then
3046 if feat_yes HISTORY; then
3047 if [ -n "${have_cle}" ]; then
3048 echo '#define HAVE_HISTORY' >> ${h}
3050 feat_is_unsupported HISTORY
3053 feat_is_disabled HISTORY
3056 if feat_yes KEY_BINDINGS; then
3057 if [ -n "${have_mle}" ]; then
3058 echo '#define HAVE_KEY_BINDINGS' >> ${h}
3060 feat_is_unsupported KEY_BINDINGS
3063 feat_is_disabled KEY_BINDINGS
3066 if feat_yes TERMCAP; then # {{{
3069 link_check termcap "termcap(5) (via ${4}${ADDINC})" \
3070 "#define HAVE_TERMCAP${3}" "${1}" "${ADDINC}" << _EOT
3075 #define UNCONST(P) ((void*)(unsigned long)(void const*)(P))
3076 static int my_putc(int c){return putchar(c);}
3078 char buf[1024+512], cmdbuf[2048], *cpb, *r1;
3079 int r2 = OK, r3 = ERR;
3081 tgetent(buf, getenv("TERM"));
3083 r1 = tgetstr(UNCONST("cm"), &cpb);
3085 r2 = tgetnum(UNCONST("Co"));
3086 r3 = tgetflag(UNCONST("ut"));
3087 tputs("cr", 1, &my_putc);
3088 return (r1 == NULL || r2 == -1 || r3 == 0);
3094 link_check terminfo "terminfo(5) (via ${2}${ADDINC})" \
3095 '#define HAVE_TERMCAP
3096 #define HAVE_TERMCAP_CURSES
3097 #define HAVE_TERMINFO' "${1}" "${ADDINC}" << _EOT
3101 #define UNCONST(P) ((void*)(unsigned long)(void const*)(P))
3102 static int my_putc(int c){return putchar(c);}
3108 r0 = setupterm(NULL, 1, &er);
3109 r1 = tigetflag(UNCONST("bce"));
3110 r2 = tigetnum(UNCONST("colors"));
3111 r3 = tigetstr(UNCONST("cr"));
3112 tp = tparm(r3, NULL, NULL, 0,0,0,0,0,0,0);
3113 tputs(tp, 1, &my_putc);
3114 return (r0 == ERR || r1 == -1 || r2 == -2 || r2 == -1 ||
3115 r3 == (char*)-1 || r3 == NULL);
3120 if feat_yes TERMCAP_VIA_TERMINFO; then
3124 __terminfolib -ltinfo -ltinfo ||
3125 __terminfolib -lcurses -lcurses ||
3126 __terminfolib -lcursesw -lcursesw ||
3130 if [ -n "${xbail}" ] && [ -d /usr/local/include/ncurses ]; then
3131 ADDINC=' -I/usr/local/include/ncurses'
3134 if [ -n "${xbail}" ] && [ -d /usr/include/ncurses ]; then
3135 ADDINC=' -I/usr/include/ncurses'
3138 [ -n "${xbail}" ] && feat_bail_required TERMCAP_VIA_TERMINFO
3141 if [ -z "${have_terminfo}" ]; then
3145 __termcaplib -ltermcap '' '' '-ltermcap' ||
3146 __termcaplib -ltermcap '#include <curses.h>' '
3147 #define HAVE_TERMCAP_CURSES' \
3148 'curses.h / -ltermcap' ||
3149 __termcaplib -lcurses '#include <curses.h>' '
3150 #define HAVE_TERMCAP_CURSES' \
3151 'curses.h / -lcurses' ||
3152 __termcaplib -lcursesw '#include <curses.h>' '
3153 #define HAVE_TERMCAP_CURSES' \
3154 'curses.h / -lcursesw' ||
3158 if [ -n "${xbail}" ] && [ -d /usr/local/include/ncurses ]; then
3159 ADDINC=' -I/usr/local/include/ncurses'
3162 if [ -n "${xbail}" ] && [ -d /usr/include/ncurses ]; then
3163 ADDINC=' -I/usr/include/ncurses'
3166 [ -n "${xbail}" ] && feat_bail_required TERMCAP
3168 if [ -n "${have_termcap}" ]; then
3169 run_check tgetent_null \
3170 "tgetent(3) of termcap(5) takes NULL buffer" \
3171 "#define HAVE_TGETENT_NULL_BUF" << _EOT
3172 #include <stdio.h> /* For C89 NULL */
3174 #ifdef HAVE_TERMCAP_CURSES
3175 # include <curses.h>
3179 tgetent(NULL, getenv("TERM"));
3187 feat_is_disabled TERMCAP
3188 feat_is_disabled TERMCAP_VIA_TERMINFO
3191 if feat_def SPAM_SPAMC; then
3192 if acmd_set i spamc; then
3193 echo "#define SPAM_SPAMC_PATH \"${i}\"" >> ${h}
3197 if feat_yes SPAM_SPAMD; then
3198 if [ -n "${have_af_unix}" ]; then
3199 echo '#define HAVE_SPAM_SPAMD' >> ${h}
3201 feat_bail_required SPAM_SPAMD
3204 feat_is_disabled SPAM_SPAMD
3207 feat_def SPAM_FILTER
3209 if feat_yes SPAM_SPAMC || feat_yes SPAM_SPAMD || feat_yes SPAM_FILTER; then
3210 echo '#define HAVE_SPAM' >> ${h}
3212 echo '/* HAVE_SPAM */' >> ${h}
3215 if feat_yes QUOTE_FOLD; then
3216 if [ -n "${have_c90amend1}" ] && [ -n "${have_wcwidth}" ]; then
3217 echo '#define HAVE_QUOTE_FOLD' >> ${h}
3219 feat_bail_required QUOTE_FOLD
3222 feat_is_disabled QUOTE_FOLD
3225 feat_def FILTER_HTML_TAGSOUP
3233 squeeze_em ${inc} ${tmp}
3235 squeeze_em ${lib} ${tmp}
3238 echo "LIBS = `${cat} ${lib}`" >> ${mk}
3239 echo "INCS = `${cat} ${inc}`" >> ${mk}
3244 printf '#ifndef n_MK_CONFIG_H\n# define n_MK_CONFIG_H 1\n' > ${h}
3245 ${cat} ${tmp} >> ${h}
3247 # Also need these for correct "second stage configuration changed
" detection */
3249 if (${CC} --version) >/dev/null 2>&1; then
3250 i=`${CC} --version 2>&1 | ${awk} '
3252 {if(length($0)) {if(l) l = l "\\\\n
"; l = l "@
" $0}}
3253 END{gsub(/"/, "", l
); print
"\\\\n" l
}
3255 elif (${CC} -v) >/dev/null 2>&1; then
3256 i=`${CC} -v 2>&1 | ${awk} '
3258 {if(length
($0)) {if(l
) l
= l
"\\\\n"; l
= l
"@" $0}}
3259 END
{gsub
(/"/, "", l); print "\\\\n
" l}
3262 printf '#define VAL_BUILD_CC "%s
%s
%s
%s
"\n' \
3263 "${CC}" "${CFLAGS}" "" "${i}" >> ${h}
3264 printf '#define VAL_BUILD_LD "%s %s %s"\n' \
3265 "${CC}" "${LDFLAGS}" "`${cat} ${lib}`" >> ${h}
3266 printf '#define VAL_BUILD_REST "%s
"\n' "${COMMLINE}" >> ${h}
3269 # Throw away all temporaries
3270 ${rm} -rf ${tmp0}.* ${tmp0}*
3272 # Create the string that is used by *features* and `version'.
3273 # Take this nice opportunity and generate a visual listing of included and
3274 # non-included features for the person who runs the configuration
3275 echo 'The following features are included (+) or not (-):' > ${tmp}
3276 set -- ${OPTIONS_DETECT} ${OPTIONS} ${OPTIONS_XTRA}
3277 printf '/* The "feature string
" */\n' >> ${h}
3278 # Because + is expanded by *folder* if first in "echo $features", put something
3279 printf '#define VAL_FEATURES_CNT '${#}'\n#define VAL_FEATURES "#' >> ${h}
3283 sdoc
=`option_doc_of ${opt}`
3284 [ -z "${sdoc}" ] && continue
3285 sopt
="`echo ${opt} | ${tr} '[A-Z]_' '[a-z]-'`"
3286 feat_yes
${opt} && sign
=+ || sign
=-
3287 printf -- "${sep}${sign}${sopt}" >> ${h}
3289 printf ' %s %s: %s\n' ${sign} ${sopt} "${sdoc}" >> ${tmp}
3291 # TODO instead of using sh+tr+awk+printf, use awk, drop option_doc_of, inc here
3293 #${awk} -v opts="${OPTIONS_DETECT} ${OPTIONS} ${OPTIONS_XTRA}" \
3294 # -v xopts="${XOPTIONS_DETECT} ${XOPTIONS} ${XOPTIONS_XTRA}" \
3295 printf '"\n' >> ${h}
3297 # Create the real mk-config.mk
3298 # Note we cannout use explicit ./ filename prefix for source and object
3299 # pathnames because of a bug in bmake(1)
3301 if feat_no AMALGAMATION
; then
3302 for i
in `printf '%s\n' "${SRCDIR}"*.c | ${sort}`; do
3303 i
=`basename "${i}" .c`
3304 if [ "${i}" = privsep
]; then
3307 objlist
="${objlist} ${i}.o"
3308 srclist
="${srclist} \$(SRCDIR)${i}.c"
3309 printf '%s: %s\n\t$(ECHO_CC)$(CC) $(CFLAGS) $(INCS) -c %s\n' \
3310 "${i}.o" "\$(SRCDIR)${i}.c" "\$(SRCDIR)${i}.c" >> ${mk}
3312 printf '\nAMALGAM_TARGET =\nAMALGAM_DEP =\n' >> ${mk}
3314 printf '%s:\n\t$(ECHO_CC)$(CC) $(CFLAGS) $(INCS) -c $(SRCDIR)%s\n' \
3315 "main.o
" "main.c
" >> ${mk}
3316 srclist=main.c objlist=main.o
3317 printf '\nAMALGAM_TARGET = main.o\nAMALGAM_DEP = ' >> ${mk}
3319 printf '\n/* HAVE_AMALGAMATION: include sources */\n' >> ${h}
3320 printf '#elif n_MK_CONFIG_H + 0 == 1\n' >> ${h}
3321 printf '# undef n_MK_CONFIG_H\n' >> ${h}
3322 printf '# define n_MK_CONFIG_H 2\n' >> ${h}
3323 for i in `printf '%s\n' "${SRCDIR}"*.c | ${sort}`; do
3325 if [ "${i}" = main.c ] ||
3326 [ "${i}" = privsep.c ]; then
3329 printf '$(SRCDIR)%s ' "${i}" >> ${mk}
3330 printf '# include "%s
%s
"\n' "${SRCDIR}" "${i}" >> ${h}
3334 printf 'OBJ_SRC = %s\nOBJ = %s\n' "${srclist}" "${objlist}" >> "${mk}"
3336 printf '#endif /* n_MK_CONFIG_H */\n' >> ${h}
3339 ${cat} "${SRCDIR}"make-config.in >> ${mk}
3343 # We have completed the new configuration header. Check whether *really*
3344 # Do the "second stage configuration changed" detection, exit if nothing to do
3345 if [ -f ${oldh} ]; then
3346 if ${cmp} ${h} ${oldh} >/dev
/null
2>&1; then
3347 ${mv} -f ${oldh} ${h}
3348 msg
'Effective configuration is up-to-date'
3353 msg
'Effective configuration has been updated..'
3356 if [ -n "${config_updated}" ]; then
3357 msg
'Wiping away old objects and such..'
3358 ( cd .obj
; oldmk
=`${basename} ${oldmk}`; ${MAKE} -f ${oldmk} clean )
3362 while read l; do msg "${l}"; done < ${tmp}
3365 msg ' . System-wide resource file: %s/%s' "${VAL_SYSCONFDIR}" "${VAL_SYSCONFRC}"
3366 msg ' . bindir: %s' "${VAL_BINDIR}"
3367 if feat_yes DOTLOCK; then
3368 msg ' . libexecdir: %s' "${VAL_LIBEXECDIR}"
3370 msg ' . mandir: %s' "${VAL_MANDIR}"
3371 msg ' . M(ail)T(ransfer)A(gent): %s (argv0: %s)' "${VAL_MTA}" "${VAL_MTA_ARGV0}"
3372 msg ' . $MAIL spool directory: %s' "${VAL_MAIL}"
3375 if [ -n "${have_fnmatch}" ] && [ -n "${have_fchdir}" ]; then
3379 if [ -z "${have_fnmatch}" ]; then
3380 msg ' . The function fnmatch(3) could not be found.'
3381 msg ' Filename patterns like wildcard are not supported on your system'
3383 if [ -z "${have_fchdir}" ]; then
3384 msg ' . The function fchdir(2) could not be found.'
3385 msg ' We will use chdir(2) instead.'
3386 msg ' This is a problem only if the current working directory is changed'
3387 msg ' while this program is inside of it'