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 TLS='Transport Layer Security (OpenSSL / LibreSSL)' \
26 TLS_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_TLS_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_TLS
=0 OPT_TLS_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`
280 msg
'Operating system is %s' "${OS}"
282 if [ ${OS} = SunOS
]; then
283 # According to standards(5), this is what we need to do
284 if [ -d /usr
/xpg4
]; then :; else
285 msg
'ERROR: On SunOS / Solaris we need /usr/xpg4 environment! Sorry.'
288 PATH
="/usr/xpg4/bin:/usr/ccs/bin:/usr/bin:${PATH}"
289 [ -d /usr
/xpg6
] && PATH
="/usr/xpg6/bin:${PATH}"
295 # OSFULLSPEC is used to recognize changes (i.e., machine type, updates
296 # etc.), it is not baked into the binary
297 [ -n "${OSFULLSPEC}" ] || OSFULLSPEC
=`${uname} -a`
299 if [ ${OS} = darwin
]; then
300 msg
' . have special Darwin environmental addons...'
301 LD_LIBRARY_PATH
=${LD_LIBRARY_PATH}:${DYLD_LIBRARY_PATH}
302 elif [ ${OS} = sunos
]; then
303 msg
' . have special SunOS / Solaris "setup" rules ...'
305 elif [ ${OS} = unixware
]; then
306 if feat_yes AUTOCC
&& acmd_set CC cc
; then
307 msg
' . have special UnixWare environmental rules ...'
308 feat_yes DEBUG
&& _CFLAGS
='-v -Xa -g' || _CFLAGS
='-Xa -O'
310 CFLAGS
="${_CFLAGS} ${EXTRA_CFLAGS}"
311 LDFLAGS
="${_LDFLAGS} ${EXTRA_LDFLAGS}"
312 export CC CFLAGS LDFLAGS
313 OPT_AUTOCC
=0 ld_need_R_flags
=-R
315 elif [ -n "${VERBOSE}" ]; then
316 msg
' . no special treatment for this system necessary or known'
319 # Sledgehammer: better set _GNU_SOURCE
320 # And in general: oh, boy!
321 OS_DEFINES
="${OS_DEFINES}#define _GNU_SOURCE\n"
322 #OS_DEFINES="${OS_DEFINES}#define _POSIX_C_SOURCE 200809L\n"
323 #OS_DEFINES="${OS_DEFINES}#define _XOPEN_SOURCE 700\n"
324 #[ ${OS} = darwin ] && OS_DEFINES="${OS_DEFINES}#define _DARWIN_C_SOURCE\n"
326 # On pkgsrc(7) systems automatically add /usr/pkg/*
327 if [ -d /usr
/pkg
] && feat_yes USE_PKGSYS
; then
328 msg
' . found pkgsrc(7), merging C_INCLUDE_PATH and LD_LIBRARY_PATH'
329 C_INCLUDE_PATH
=/usr
/pkg
/include
:${C_INCLUDE_PATH}
330 LD_LIBRARY_PATH
=/usr
/pkg
/lib
:${LD_LIBRARY_PATH}
331 ld_rpath_not_runpath
=1
336 C_INCLUDE_PATH
=/usr
/xpg
4/include
:${C_INCLUDE_PATH}
337 LD_LIBRARY_PATH
=/usr
/xpg
4/lib
:${LD_LIBRARY_PATH}
340 if [ -d /opt
/csw
] && feat_yes USE_PKGSYS
; then
341 msg
' . found OpenCSW PKGSYS, merging C_INCLUDE_PATH and LD_LIBRARY_PATH'
342 C_INCLUDE_PATH
=/opt
/csw
/include
:${C_INCLUDE_PATH}
343 LD_LIBRARY_PATH
=/opt
/csw
/lib
:${LD_LIBRARY_PATH}
344 ld_no_bind_now
=1 ld_rpath_not_runpath
=1
346 if [ -d /opt
/schily
] && feat_yes USE_PKGSYS
; then
347 msg
' . found Schily PKGSYS, merging C_INCLUDE_PATH and LD_LIBRARY_PATH'
348 C_INCLUDE_PATH
=/opt
/schily
/include
:${C_INCLUDE_PATH}
349 LD_LIBRARY_PATH
=/opt
/schily
/lib
:${LD_LIBRARY_PATH}
350 ld_no_bind_now
=1 ld_rpath_not_runpath
=1
353 OS_DEFINES
="${OS_DEFINES}#define __EXTENSIONS__\n"
354 #OS_DEFINES="${OS_DEFINES}#define _POSIX_C_SOURCE 200112L\n"
356 if feat_yes AUTOCC
; then
357 if acmd_set CC cc
; then
358 feat_yes DEBUG
&& _CFLAGS
="-v -Xa -g" || _CFLAGS
="-Xa -O"
360 CFLAGS
="${_CFLAGS} ${EXTRA_CFLAGS}"
361 LDFLAGS
="${_LDFLAGS} ${EXTRA_LDFLAGS}"
362 export CC CFLAGS LDFLAGS
363 OPT_AUTOCC
=0 ld_need_R_flags
=-R
365 cc_maxopt
=2 cc_force_no_stackprot
=1
370 # Check out compiler ($CC) and -flags ($CFLAGS)
372 # Even though it belongs into cc_flags we will try to compile and link
373 # something, so ensure we have a clean state regarding CFLAGS/LDFLAGS or
374 # EXTRA_CFLAGS/EXTRA_LDFLAGS
375 if feat_no AUTOCC
; then
377 # Ensure those don't do any harm
378 EXTRA_CFLAGS
= EXTRA_LDFLAGS
=
379 export EXTRA_CFLAGS EXTRA_LDFLAGS
383 export CFLAGS LDFLAGS
386 [ -n "${CC}" ] && { _cc_default
; return; }
388 msg_nonl
'Searching for a usable C compiler .. $CC='
389 if acmd_set CC clang || acmd_set CC gcc ||
390 acmd_set CC tcc || acmd_set CC pcc ||
391 acmd_set CC c89 || acmd_set CC c99
; then
394 msg
'boing booom tschak'
395 msg
'ERROR: I cannot find a compiler!'
396 msg
' Neither of clang(1), gcc(1), tcc(1), pcc(1), c89(1) and c99(1).'
397 msg
' Please set ${CC} environment variable, maybe ${CFLAGS}, rerun.'
405 if [ -z "${CC}" ]; then
406 msg
'To go on like you have chosen, please set $CC, rerun.'
410 if [ -z "${VERBOSE}" ] && [ -f ${lst} ] && feat_no DEBUG
; then
413 msg
'Using C compiler ${CC}=%s' "${CC}"
418 if feat_yes AUTOCC
; then
419 if [ -f ${lst} ] && feat_no DEBUG
&& [ -z "${VERBOSE}" ]; then
421 msg
'Detecting ${CFLAGS}/${LDFLAGS} for ${CC}=%s, just a second..' \
425 msg
'Testing usable ${CFLAGS}/${LDFLAGS} for ${CC}=%s' "${CC}"
428 i=`echo "${CC}" | ${awk} 'BEGIN{FS="/"}{print $NF}'`
429 if { echo "${i}" | ${grep} tcc; } >/dev/null 2>&1; then
430 msg ' . have special tcc(1) environmental rules ...'
433 # As of pcc CVS 2016-04-02, stack protection support is announced but
434 # will break if used on Linux
435 if { echo "${i}" | ${grep} pcc; } >/dev/null 2>&1; then
436 cc_force_no_stackprot=1
441 feat_no DEBUG && _CFLAGS="-DNDEBUG ${_CFLAGS}"
442 CFLAGS="${_CFLAGS} ${EXTRA_CFLAGS}"
443 LDFLAGS="${_LDFLAGS} ${EXTRA_LDFLAGS}"
445 if feat_no DEBUG; then
446 CFLAGS="-DNDEBUG ${CFLAGS}"
449 export CFLAGS LDFLAGS
453 __cflags=${_CFLAGS} __ldflags=${_LDFLAGS}
461 if feat_yes DEBUG; then
462 # May have problems to find libtcc cc_check -b
466 if ld_check -Wl,-rpath =./ no; then
467 ld_need_R_flags=-Wl,-rpath=
468 if [ -z "${ld_rpath_not_runpath}" ]; then
469 ld_check -Wl,--enable-new-dtags
471 msg ' ! $LD_LIBRARY_PATH adjusted, not trying --enable-new-dtags'
473 ld_runtime_flags # update!
476 _CFLAGS="${_CFLAGS} ${__cflags}" _LDFLAGS="${_LDFLAGS} ${__ldflags}"
477 unset __cflags __ldflags
480 _cc_flags_generic() {
481 __cflags=${_CFLAGS} __ldflags=${_LDFLAGS}
483 feat_yes DEVEL && cc_check -std=c89 || cc_check -std=c99
485 # E.g., valgrind does not work well with high optimization
486 if [ ${cc_maxopt} -gt 1 ] && feat_yes NOMEMDBG &&
487 feat_no ASAN_ADDRESS && feat_no ASAN_MEMORY; then
488 msg ' ! OPT_NOMEMDBG, setting cc_maxopt=1 (-O1)'
491 # Check -g first since some others may rely upon -g / optim. level
492 if feat_yes DEBUG; then
495 elif [ ${cc_maxopt} -gt 2 ] && cc_check -O3; then
497 elif [ ${cc_maxopt} -gt 1 ] && cc_check -O2; then
499 elif [ ${cc_maxopt} -gt 0 ] && cc_check -O1; then
505 if feat_yes AMALGAMATION; then
509 #if feat_yes DEVEL && cc_check -Weverything; then
515 cc_check -Wbad-function-cast
516 cc_check -Wcast-align
519 cc_check -Wmissing-prototypes
522 cc_check -Wwrite-strings
523 cc_check -Wno-long-long
527 if feat_yes AMALGAMATION && feat_no DEVEL; then
528 cc_check -Wno-unused-function
530 feat_no DEVEL && cc_check -Wno-unused-result # XXX do right way (pragma too)
532 cc_check -fno-unwind-tables
533 cc_check -fno-asynchronous-unwind-tables
534 cc_check -fstrict-aliasing
535 if cc_check -fstrict-overflow && feat_yes DEVEL; then
536 cc_check -Wstrict-overflow=5
539 if feat_yes DEBUG || feat_yes FORCED_STACKPROT; then
540 if [ -z "${cc_force_no_stackprot}" ]; then
541 if cc_check -fstack-protector-strong ||
542 cc_check -fstack-protector-all; then
543 cc_check -D_FORTIFY_SOURCE=2
546 msg ' ! Not checking for -fstack-protector compiler option,'
547 msg ' ! since that caused errors in a "similar" configuration.'
548 msg ' ! You may turn off OPT_AUTOCC and use your own settings, rerun'
552 # LD (+ dependend CC)
554 if feat_yes ASAN_ADDRESS; then
556 if cc_check -fsanitize=address && ld_check -fsanitize=address; then
559 feat_bail_required ASAN_ADDRESS
564 if feat_yes ASAN_MEMORY; then
566 if cc_check -fsanitize=memory && ld_check -fsanitize=memory &&
567 cc_check -fsanitize-memory-track-origins=2 &&
568 ld_check -fsanitize-memory-track-origins=2; then
571 feat_bail_required ASAN_MEMORY
576 if feat_yes USAN; then
578 if cc_check -fsanitize=undefined && ld_check -fsanitize=undefined; then
581 feat_bail_required USAN
586 ld_check -Wl,-z,relro
587 if [ -z "${ld_no_bind_now}" ]; then
590 msg ' ! $LD_LIBRARY_PATH adjusted, not trying -Wl,-z,now'
592 ld_check -Wl,-z,noexecstack
593 ld_check -Wl,--as-needed
594 if ld_check -Wl,-rpath =./ no; then
595 ld_need_R_flags=-Wl,-rpath=
596 # Choose DT_RUNPATH (after $LD_LIBRARY_PATH) over DT_RPATH (before)
597 if [ -z "${ld_rpath_not_runpath}" ]; then
598 ld_check -Wl,--enable-new-dtags
600 msg ' ! $LD_LIBRARY_PATH adjusted, not trying --enable-new-dtags'
602 ld_runtime_flags # update!
603 elif ld_check -Wl,-R ./ no; then
604 ld_need_R_flags=-Wl,-R
605 if [ -z "${ld_rpath_not_runpath}" ]; then
606 ld_check -Wl,--enable-new-dtags
608 msg ' ! $LD_LIBRARY_PATH adjusted, not trying --enable-new-dtags'
610 ld_runtime_flags # update!
613 # Address randomization
615 if cc_check -fPIE || cc_check -fpie; then
616 ld_check -pie || _CFLAGS=${_ccfg}
620 _CFLAGS="${_CFLAGS} ${__cflags}" _LDFLAGS="${_LDFLAGS} ${__ldflags}"
621 unset __cflags __ldflags
624 ## -- >8 - <<OS/CC | SUPPORT FUNS>> - 8< -- ##
627 ## - Heirloom sh(1) (and same origin) have _sometimes_ problems with ': >'
628 ## redirection, so use "printf '' >" instead
630 ## Very first: we undergo several states regarding I/O redirection etc.,
631 ## but need to deal with option updates from within all. Since all the
632 ## option stuff should be above the scissor line, define utility functions
633 ## and redefine them as necessary.
634 ## And, since we have those functions, simply use them for whatever
636 t1=ten10one1ten10one1
637 if ( [ ${t1##*ten10} = one1 ] && [ ${t1#*ten10} = one1ten10one1 ] &&
638 [ ${t1%%one1*} = ten10 ] && [ ${t1%one1*} = ten10one1ten10 ]
639 ) > /dev/null 2>&1; then
646 ( set -o noglob ) >/dev/null 2>&1 && noglob_shell=1 || unset noglob_shell
652 # which(1) not standardized, command(1) -v may return non-executable: unroll!
653 acmd_test() { __acmd "${1}" 1 0 0; }
654 acmd_test_fail() { __acmd "${1}" 1 1 0; }
655 acmd_set() { __acmd "${2}" 0 0 0 "${1}"; }
656 acmd_set_fail() { __acmd "${2}" 0 1 0 "${1}"; }
657 acmd_testandset() { __acmd "${2}" 1 0 0 "${1}"; }
658 acmd_testandset_fail() { __acmd "${2}" 1 1 0 "${1}"; }
659 thecmd_set() { __acmd "${2}" 0 0 1 "${1}"; }
660 thecmd_set_fail() { __acmd "${2}" 0 1 1 "${1}"; }
661 thecmd_testandset() { __acmd "${2}" 1 0 1 "${1}"; }
662 thecmd_testandset_fail() { __acmd "${2}" 1 1 1 "${1}"; }
664 pname=${1} dotest=${2} dofail=${3} verbok=${4} varname=${5}
666 if [ "${dotest}" -ne 0 ]; then
667 eval dotest=\$${varname}
668 if [ -n "${dotest}" ]; then
669 [ -n "${VERBOSE}" ] && [ ${verbok} -ne 0 ] &&
670 msg ' . ${%s} ... %s' "${pname}" "${dotest}"
676 [ -n "${noglob_shell}" ] && set -o noglob
678 [ -n "${noglob_shell}" ] && set +o noglob
682 if [ -z "${path}" ] || [ "${path}" = . ]; then
683 if [ -d "${PWD}" ]; then
689 if [ -f "${path}/${pname}" ] && [ -x "${path}/${pname}" ]; then
690 [ -n "${VERBOSE}" ] && [ ${verbok} -ne 0 ] &&
691 msg ' . ${%s} ... %s' "${pname}" "${path}/${pname}"
692 [ -n "${varname}" ] && eval ${varname}="${path}/${pname}"
697 # We may have no builtin string functions, we yet have no programs we can
698 # use, try to access once from the root, assuming it is an absolute path if
699 # that finds the executable
700 if ( cd && [ -f "${pname}" ] && [ -x "${pname}" ] ); then
701 [ -n "${VERBOSE}" ] && [ ${verbok} -ne 0 ] &&
702 msg ' . ${%s} ... %s' "${pname}" "${pname}"
703 [ -n "${varname}" ] && eval ${varname}="${pname}"
707 [ ${dofail} -eq 0 ] && return 1
708 msg 'ERROR: no trace of utility '"${pname}"
715 printf >&2 -- "${fmt}\\n" "${@}"
721 printf >&2 -- "${fmt}" "${@}"
724 # Our feature check environment
726 [ "x${1}" = x0 ] || [ "x${1}" = xn ] ||
727 [ "x${1}" = xfalse ] || [ "x${1}" = xno ] || [ "x${1}" = xoff ]
731 [ "x${1}" = x1 ] || [ "x${1}" = xy ] ||
732 [ "x${1}" = xtrue ] || [ "x${1}" = xyes ] || [ "x${1}" = xon ] ||
733 [ "x${1}" = xrequire ]
737 [ "x${1}" = xrequire ]
742 i="`echo ${i} |
${tr} '[A-Z]' '[a-z]'`"
743 if feat_val_no "${i}"; then
745 elif feat_val_yes "${i}"; then
748 msg "ERROR: %s: 0/n/false/no/off or 1/y/true/yes/on/require, got: %s" \
759 _feat_check ${1} && return 1
765 i="`echo ${i} |
${tr} '[A-Z]' '[a-z]'`"
766 [ "x${i}" = xrequire ] || [ "x${i}" = xrequired ]
769 feat_bail_required() {
770 if feat_require ${1}; then
771 msg 'ERROR: feature OPT_%s is required but not available' "${1}"
774 feat_is_unsupported "${1}"
778 [ ${#} -eq 1 ] && msg ' . (disabled: OPT_%s)' "${1}"
779 echo "/* OPT_${1} -> HAVE_${1} */" >> ${h}
782 feat_is_unsupported() {
783 msg ' ! NOTICE: unsupported: OPT_%s' "${1}"
784 echo "/* OPT_${1} -> HAVE_${1} */" >> ${h}
786 option_update # XXX this is rather useless here (dependency chain..)
790 if feat_yes ${1}; then
791 msg ' . %s ... yes' "${1}"
792 echo '#define HAVE_'${1}'' >> ${h}
795 feat_is_disabled "${@}"
801 # Parse one of our XOPTIONS* in $2 and assign the sh(1) compatible list of
802 # options, without documentation, to $1
804 i="`${awk} -v input
=\"${2}\" '
807 voff = match(input, /[[:alnum:]_]+(='${j}'[^'${j}']+)?/)
810 v = substr(input, voff, RLENGTH)
811 input = substr(input, voff + RLENGTH)
814 d = substr(v, doff + 2, length(v) - doff - 1)
815 v = substr(v, 1, doff - 1)
825 # Return the "documentation string" for option $1, itself if none such
827 ${awk} -v want="${1}" \
828 -v input="${XOPTIONS_DETECT}${XOPTIONS}${XOPTIONS_XTRA}" '
831 voff = match(input, /[[:alnum:]_]+(='${j}'[^'${j}']+)?/)
834 v = substr(input, voff, RLENGTH)
835 input = substr(input, voff + RLENGTH)
838 d = substr(v, doff + 2, length(v) - doff - 1)
839 v = substr(v, 1, doff - 1)
853 # Join the values from make.rc into what currently is defined, not
854 # overwriting yet existing settings
856 # We want read(1) to perform reverse solidus escaping in order to be able to
857 # use multiline values in make.rc; the resulting sh(1)/sed(1) code was very
858 # slow in VMs (see [fa2e248]), Aharon Robbins suggested the following
859 < ${rc} ${awk} 'BEGIN{line = ""}{
860 gsub(/^[[:space:]]+/, "", $0)
861 gsub(/[[:space:]]+$/, "", $0)
862 if(gsub(/\\$/, "", $0)){
867 if(index(line, "#") == 1){
869 }else if(length(line)){
875 if [ -n "${good_shell}" ]; then
878 i=`${awk} -v LINE
="${line}" 'BEGIN{
879 gsub(/=.*$/, "", LINE)
883 if [ "${i}" = "${line}" ]; then
884 msg 'ERROR: invalid syntax in: %s' "${line}"
888 eval j="\$${i}" jx="\${${i}+x}"
889 if [ -n "${j}" ] || [ "${jx}" = x ]; then
892 j=`${awk} -v LINE
="${line}" 'BEGIN{
893 gsub(/^[^=]*=/, "", LINE)
894 gsub(/^\"*/, "", LINE)
895 gsub(/\"*$/, "", LINE)
899 [ "${i}" = "DESTDIR" ] && continue
902 # Reread the mixed version right now
907 # Expand the option values, which may contain shell snippets
908 ${rm} -f ${newlst} ${newmk} ${newh}
909 exec 5<&0 6>&1 <${tmp} >${newlst}
912 if [ -n "${good_shell}" ]; then
914 [ "${i}" != "${i#OPT_}" ] && z=1
916 i=`${awk} -v LINE
="${line}" 'BEGIN{
917 gsub(/=.*$/, "", LINE);\
920 if echo "${i}" | ${grep} '^OPT_' >/dev/null 2>&1; then
926 if [ -n "${z}" ]; then
927 j="`echo ${j} |
${tr} '[A-Z]' '[a-z]'`"
928 if [ -z "${j}" ] || feat_val_no "${j}"; then
930 printf " /* #undef ${i} */\n" >> ${newh}
931 elif feat_val_yes "${j}"; then
932 if feat_val_require "${j}"; then
937 printf " /* #define ${i} */\n" >> ${newh}
939 msg 'ERROR: cannot parse <%s>' "${line}"
942 elif { echo ${i} | ${grep} ${H_BLACKLIST} >/dev/null 2>&1; }; then
945 printf "#define ${i} \"${j}\"\n" >> ${newh}
947 printf "${i} = ${j}\n" >> ${newmk}
951 exec 0<&5 1>&6 5<&- 6<&-
956 ${awk} -v HEAP="${2}" -v USER="${__expo__}" '
958 i = split(HEAP, ha, /[, ]/)
959 if((j = split(USER, ua, /[, ]/)) == 0)
963 if(us == "all" || us == "any")
966 for(ii = i; ii != 0; --ii)
967 if(tolower(ha[ii]) == us){
977 [ ${__rv__} -ne 0 ] && return ${__rv__}
979 if ${awk} -v USER="${__expo__}" '
981 if((j = split(USER, ua, /[, ]/)) == 0)
985 if(us == "all" || us == "any")
993 # Enfore lowercase also in otherwise unchanged user value..
994 eval "${1}"=\""`echo ${__expo__} | ${tr} '[A-Z]_' '[a-z]-'`"\"
1000 # "path_check VARNAME
" or "path_check VARNAME FLAG VARNAME
"
1001 varname=${1} addflag=${2} flagvarname=${3}
1004 [ -n "${noglob_shell}" ] && set -o noglob
1005 eval "set -- \$
${1}"
1006 [ -n "${noglob_shell}" ] && set +o noglob
1011 [ -z "${i}" ] && continue
1012 [ -d "${i}" ] || continue
1013 if [ -n "${j}" ]; then
1014 if { z=${y}; echo "${z}"; } | ${grep} ":${i}:" >/dev
/null
2>&1; then
1019 # But do not link any fakeroot path into our binaries!
1020 if [ -n "${addflag}" ]; then
1021 case "${i}" in *fakeroot
*) continue;; esac
1022 k
="${k} ${addflag}${i}"
1028 # But do not link any fakeroot path into our binaries!
1029 if [ -n "${addflag}" ]; then
1030 case "${i}" in *fakeroot
*) continue;; esac
1031 k
="${k} ${addflag}${i}"
1035 eval "${varname}=\"${j}\""
1036 [ -n "${addflag}" ] && eval "${flagvarname}=\"${k}\""
1040 ld_runtime_flags
() {
1041 if [ -n "${ld_need_R_flags}" ]; then
1044 set -- ${LD_LIBRARY_PATH}
1048 # But do not link any fakeroot path into our binaries!
1049 case "${i}" in *fakeroot
*) continue;; esac
1050 LDFLAGS
="${LDFLAGS} ${ld_need_R_flags}${i}"
1051 _LDFLAGS
="${_LDFLAGS} ${ld_need_R_flags}${i}"
1055 # Disable it for a possible second run.
1060 [ -n "${cc_check_silent}" ] || msg_nonl
' . CC %s .. ' "${1}"
1062 ${_CFLAGS} ${1} ${EXTRA_CFLAGS} ${_LDFLAGS} ${EXTRA_LDFLAGS} \
1063 -o ${tmp2} ${tmp}.c ${LIBS} >/dev
/null
2>&1; then
1064 _CFLAGS
="${_CFLAGS} ${1}"
1065 [ -n "${cc_check_silent}" ] || msg
'yes'
1068 [ -n "${cc_check_silent}" ] || msg
'no'
1073 # $1=option [$2=option argument] [$3=if set, shall NOT be added to _LDFLAGS]
1074 [ -n "${cc_check_silent}" ] || msg_nonl
' . LD %s .. ' "${1}"
1075 if ${CC} ${INCS} ${_CFLAGS} ${_LDFLAGS} ${1}${2} ${EXTRA_LDFLAGS} \
1076 -o ${tmp2} ${tmp}.c ${LIBS} >/dev
/null
2>&1; then
1077 [ -n "${3}" ] || _LDFLAGS="${_LDFLAGS} ${1}"
1078 [ -n "${cc_check_silent}" ] || msg
'yes'
1081 [ -n "${cc_check_silent}" ] || msg
'no'
1087 variable
=$1 topic
=$2 define
=$3
1090 msg_nonl
' . %s ... ' "${topic}"
1091 #echo "/* checked ${topic} */" >> ${h}
1092 ${rm} -f ${tmp} ${tmp}.o
1093 if [ "${dump_test_program}" = 1 ]; then
1094 echo '*** test program is'
1095 { echo '#include <'"${h_name}"'>'; cat; } | ${tee} ${tmp}.c
1097 { echo '#include <'"${h_name}"'>'; cat; } > ${tmp}.c
1099 #echo '*** the preprocessor generates'
1100 #${make} -f ${makefile} ${tmp}.x
1102 echo '*** tests results'
1106 yesno=$1 variable=$2 topic=$3 define=$4 libs=$5 incs=$6
1109 msg_nonl ' . %s ... ' "${topic}"
1111 echo '*** enforced unchecked results are'
1112 if feat_val_yes ${yesno}; then
1113 if [ -n "${incs}" ] || [ -n "${libs}" ]; then
1114 echo "*** adding INCS
<${incs}> LIBS
<${libs}>"
1115 LIBS="${LIBS} ${libs}"
1116 echo "${libs}" >> ${lib}
1117 INCS="${INCS} ${incs}"
1118 echo "${incs}" >> ${inc}
1121 echo "${define}" >> ${h}
1122 eval have_${variable}=yes
1125 #echo "/* ${define} */" >> ${h}
1127 eval unset have_${variable}
1133 variable=$1 topic=$2 define=$3
1135 _check_preface "${variable}" "${topic}" "${define}"
1137 if ${make} -f ${makefile} XINCS="${INCS}" \
1138 CFLAGS
="${CFLAGS}" LDFLAGS="${LDFLAGS}" ${tmp}.o &&
1139 [ -f ${tmp}.o ]; then
1141 echo "${define}" >> ${h}
1142 eval have_${variable}=yes
1145 #echo "/* ${define} */" >> ${h}
1147 eval unset have_${variable}
1153 run=$1 variable=$2 topic=$3 define=$4 libs=$5 incs=$6
1155 _check_preface "${variable}" "${topic}" "${define}"
1157 if feat_yes CROSS_BUILD; then
1158 if [ ${run} = 1 ]; then
1163 if ${make} -f ${makefile} XINCS="${INCS} ${incs}" \
1164 CFLAGS
="${CFLAGS}" LDFLAGS
="${LDFLAGS}" \
1165 XLIBS
="${LIBS} ${libs}" ${tmp} &&
1166 [ -f ${tmp} ] && { [ ${run} -eq 0 ] || ${tmp}; }; then
1167 echo "*** adding INCS
<${incs}> LIBS<${libs}>; executed: ${run}"
1169 echo "${define}" >> ${h}
1170 LIBS="${LIBS} ${libs}"
1171 echo "${libs}" >> ${lib}
1172 INCS="${INCS} ${incs}"
1173 echo "${incs}" >> ${inc}
1174 eval have_${variable}=yes
1178 #echo "/* ${define} */" >> ${h}
1179 eval unset have_${variable}
1185 _link_mayrun 0 "${1}" "${2}" "${3}" "${4}" "${5}"
1189 _link_mayrun 1 "${1}" "${2}" "${3}" "${4}" "${5}"
1193 _link_mayrun 2 "${1}" "${2}" "${3}" "${4}" "${5}"
1197 < "${1}" > "${2}" ${awk} \
1198 'BEGIN {ORS = " "} /^[^#]/ {print} {next} END {ORS = ""; print "\n"}'
1201 ## -- >8 - <<SUPPORT FUNS | RUNNING>> - 8< -- ##
1203 # First of all, create new configuration and check whether it changed
1205 if [ -d .obj
] || mkdir .obj
; then :; else
1206 msg
'ERROR: cannot create .obj build directory'
1210 # Very easy checks for the operating system in order to be able to adjust paths
1211 # or similar very basic things which we need to be able to go at all
1214 # Check those tools right now that we need before including $rc
1215 msg
'Checking for basic utility set'
1216 thecmd_testandset_fail
awk awk
1217 thecmd_testandset_fail
rm rm
1218 thecmd_testandset_fail
tr tr
1220 # Lowercase this now in order to isolate all the remains from case matters
1221 OS
=`echo ${OS} | ${tr} '[A-Z]' '[a-z]'`
1224 # Initialize the option set
1225 msg_nonl
'Setting up configuration options ... '
1229 # Include $rc, but only take from it what wasn't overwritten by the user from
1230 # within the command line or from a chosen fixed CONFIG=
1231 # Note we leave alone the values
1232 trap "exit 1" HUP INT TERM
1233 trap "${rm} -f ${tmp}" EXIT
1235 msg_nonl
'Joining in %s ... ' ${rc}
1239 # We need to know about that now, in order to provide utility overwrites etc.
1242 msg
'Checking for remaining set of utilities'
1243 thecmd_testandset_fail
grep grep
1245 # Before we step ahead with the other utilities perform a path cleanup first.
1249 thecmd_testandset_fail
basename basename
1250 thecmd_testandset_fail
cat cat
1251 thecmd_testandset_fail
chmod chmod
1252 thecmd_testandset_fail
cp cp
1253 thecmd_testandset_fail
cmp cmp
1255 thecmd_testandset_fail mkdir mkdir
1256 thecmd_testandset_fail
mv mv
1257 # pwd(1) is needed - either for make-emerge.sh, or for ourselves
1258 [ -n "${CWDDIR}" ] || thecmd_testandset_fail
pwd pwd
1260 thecmd_testandset_fail
sed sed
1261 thecmd_testandset_fail
sort sort
1262 thecmd_testandset_fail
tee tee
1264 thecmd_testandset chown chown ||
1265 PATH
="/sbin:${PATH}" thecmd_set chown chown ||
1266 PATH
="/usr/sbin:${PATH}" thecmd_set_fail chown chown
1268 thecmd_testandset_fail MAKE
make
1271 thecmd_testandset strip strip
&& HAVE_STRIP
=1 || HAVE_STRIP
=0
1273 # For ./cc-test.sh only
1274 thecmd_testandset_fail
cksum cksum
1276 # Now that we have pwd(1), set our build paths unless make-emerge.sh has been
1277 # used; it would have created a makefile with the full paths, then
1278 [ -n "${CWDDIR}" ] || CWDDIR
=`${pwd}`/
1279 [ -n "${SRCDIR}" ] || SRCDIR
=${CWDDIR}
1281 # Update OPT_ options now, in order to get possible inter-dependencies right
1284 # (No functions since some shells loose non-exported variables in traps)
1285 trap "trap \"\" HUP INT TERM; exit 1" HUP INT TERM
1286 trap "trap \"\" HUP INT TERM EXIT;\
1287 ${rm} -rf ${newlst} ${tmp0}.* ${tmp0}* \
1288 ${newmk} ${oldmk} ${newev} ${newh} ${oldh}" EXIT
1290 # Our configuration options may at this point still contain shell snippets,
1291 # we need to evaluate them in order to get them expanded, and we need those
1292 # evaluated values not only in our new configuration file, but also at hand..
1293 msg_nonl
'Evaluating all configuration items ... '
1298 printf "#define VAL_UAGENT \"${VAL_SID}${VAL_MAILX}\"\n" >> ${newh}
1299 printf "VAL_UAGENT
= ${VAL_SID}${VAL_MAILX}\n" >> ${newmk}
1301 # The problem now is that the test should be able to run in the users linker
1302 # and path environment, so we need to place the test: rule first, before
1303 # injecting the relevant make variables. Set up necessary environment
1304 if [ -z "${VERBOSE}" ]; then
1305 printf -- "ECHO_CC = @echo ' 'CC \$(@);\n" >> ${newmk}
1306 printf -- "ECHO_LINK = @echo ' 'LINK \$(@);\n" >> ${newmk}
1307 printf -- "ECHO_GEN = @echo ' 'GEN \$(@);\n" >> ${newmk}
1308 printf -- "ECHO_TEST = @\n" >> ${newmk}
1309 printf -- "ECHO_CMD = @echo ' CMD';\n" >> ${newmk}
1310 printf -- "ECHO_BLOCK_BEGIN = @( \n" >> ${newmk}
1311 printf -- "ECHO_BLOCK_END = ) >/dev/null\n" >> ${newmk}
1313 printf 'test: all\n\t$(ECHO_TEST)%s %scc-test.sh --check-only %s\n' \
1314 "${SHELL}" "${SRCDIR}" "./${VAL_SID}${VAL_MAILX}" >> ${newmk}
1316 # Add the known utility and some other variables
1317 printf "#define VAL_PRIVSEP \"${VAL_SID}${VAL_MAILX}-privsep\"\n" >> ${newh}
1318 printf "VAL_PRIVSEP = \$(VAL_UAGENT)-privsep\n" >> ${newmk}
1319 if feat_yes DOTLOCK
; then
1320 printf "OPTIONAL_PRIVSEP = \$(VAL_PRIVSEP)\n" >> ${newmk}
1322 printf "OPTIONAL_PRIVSEP =\n" >> ${newmk}
1327 awk basename cat chmod chown
cp cmp grep mkdir
mv rm sed sort tee tr \
1328 MAKE MAKEFLAGS
make SHELL strip \
1331 printf -- "${i} = ${j}\n" >> ${newmk}
1332 printf -- "${i}=${j}\n" >> ${newlst}
1333 printf -- "${i}=\"${j}\";export ${i}; " >> ${newev}
1335 # Note that makefile reads and eval'uates one line of this file, whereas other
1336 # consumers source it via .(1)
1337 printf "\n" >> ${newev}
1339 # Build a basic set of INCS and LIBS according to user environment.
1340 C_INCLUDE_PATH="${CWDDIR}:${CWDDIR}.obj:${SRCDIR}:${C_INCLUDE_PATH}"
1341 path_check C_INCLUDE_PATH -I _INCS
1342 INCS="${INCS} ${_INCS}"
1343 path_check LD_LIBRARY_PATH -L _LIBS
1344 LIBS="${LIBS} ${_LIBS}"
1346 export C_INCLUDE_PATH LD_LIBRARY_PATH
1348 # Some environments need runtime path flags to be able to go at all
1351 ## Detect CC, whether we can use it, and possibly which CFLAGS we can use
1355 ${cat} > ${tmp}.c << \!
1358 static void doit(char const *s);
1360 main(int argc, char **argv){
1363 doit("Hello world
");
1367 doit(char const *s){
1369 memcpy(buf, s, strlen(s) +1);
1374 if ${CC} ${INCS} ${CFLAGS} ${EXTRA_CFLAGS} ${LDFLAGS} ${EXTRA_LDFLAGS} \
1375 -o ${tmp2} ${tmp}.c ${LIBS}; then
1378 msg 'ERROR: i cannot compile a "Hello world
" via'
1380 "${CC} ${INCS} ${CFLAGS} ${EXTRA_CFLAGS} ${LDFLAGS} ${EXTRA_LDFLAGS} ${LIBS}"
1381 msg 'ERROR: Please read INSTALL, rerun'
1385 # This may also update ld_runtime_flags() (again)
1393 printf -- "${i}=${j}\n" >> ${newlst}
1399 PATH C_INCLUDE_PATH LD_LIBRARY_PATH \
1403 if [ -n "${j}" ]; then
1404 printf -- "${i} = ${j}\n" >> ${newmk}
1405 printf -- "${i}=${j}\n" >> ${newlst}
1409 # Now finally check whether we already have a configuration and if so, whether
1410 # all those parameters are still the same.. or something has actually changed
1412 if [ -f ${lst} ] && ${cmp} ${newlst} ${lst} >/dev
/null
2>&1; then
1413 echo 'Configuration is up-to-date'
1415 elif [ -f ${lst} ]; then
1417 echo 'Configuration has been updated..'
1419 echo 'Shiny configuration..'
1422 # Time to redefine helper 1
1424 ${rm} -f ${lst} ${h} ${mk}
1428 ${mv} -f ${newlst} ${lst}
1429 ${mv} -f ${newev} ${ev}
1430 [ -f ${h} ] && ${mv} -f ${h} ${oldh}
1431 ${mv} -f ${newh} ${h}
1432 [ -f ${mk} ] && ${mv} -f ${mk} ${oldmk}
1433 ${mv} -f ${newmk} ${mk}
1435 ## Compile and link checking
1438 log
=.obj
/mk-config.log
1439 lib
=.obj
/mk-config.lib
1440 inc
=.obj
/mk-config.inc
1443 # (No function since some shells loose non-exported variables in traps)
1444 trap "trap \"\" HUP INT TERM;\
1445 ${rm} -f ${lst} ${oldh} ${h} ${oldmk} ${mk} ${lib} ${inc}; exit 1" \
1447 trap "trap \"\" HUP INT TERM EXIT;\
1448 ${rm} -rf ${oldh} ${oldmk} ${tmp0}.* ${tmp0}*" EXIT
1450 # Time to redefine helper 2
1454 printf "*** ${fmt}\\n" "${@}"
1455 printf -- "${fmt}\\n" "${@}" >&5
1460 printf "*** ${fmt}\\n" "${@}"
1461 printf -- "${fmt}" "${@}" >&5
1465 exec 5>&2 > ${log} 2>&1
1467 echo "${LIBS}" > ${lib}
1468 echo "${INCS}" > ${inc}
1469 ${cat} > ${makefile} << \
!
1470 .SUFFIXES
: .o .c .x .y
1472 $
(CC
) -I.
/ $
(XINCS
) $
(CFLAGS
) -o $
(@
) -c $
(<)
1474 $
(CC
) -I.
/ $
(XINCS
) -E $
(<) > $
(@
)
1476 $
(CC
) -I.
/ $
(XINCS
) $
(CFLAGS
) $
(LDFLAGS
) -o $
(@
) $
(<) $
(XLIBS
)
1481 # May be multiline..
1483 [ -n "${OS_DEFINES}" ] && printf -- "${OS_DEFINES}" >> ${h}
1484 echo '#define VAL_BUILD_OS "'"${OS}"'"' >> ${h}
1486 # Generate n_err_number OS mappings
1489 feat_yes DEVEL && NV= || NV=noverbose
1490 SRCDIR="${SRCDIR}" TARGET="${h}" awk="${awk}" \
1491 ${SHELL} "${SRCDIR}"make-errors.sh ${NV} config
1492 ) | xrun_check oserrno 'OS error mapping table generated' || config_exit 1
1495 feat_def ALWAYS_UNICODE_LOCALE
1496 feat_def AMALGAMATION 0
1497 feat_def CROSS_BUILD
1503 feat_def ASAN_ADDRESS 0
1504 feat_def ASAN_MEMORY 0
1510 if xrun_check inline 'inline functions' \
1511 '#define HAVE_INLINE
1512 #define n_INLINE static inline' << \!
1513 static inline int ilf(int i){return ++i;}
1514 int main(void){return ilf(-1);}
1518 elif xrun_check inline 'inline functions (via __inline)' \
1519 '#define HAVE_INLINE
1520 #define n_INLINE static __inline' << \!
1521 static __inline int ilf(int i){return ++i;}
1522 int main(void){return ilf(-1);}
1528 ## Test for "basic
" system-calls / functionality that is used by all parts
1529 ## of our program. Once this is done fork away BASE_LIBS and other BASE_*
1530 ## macros to be used by only the subprograms (potentially).
1532 if run_check clock_gettime 'clock_gettime(2)' \
1533 '#define HAVE_CLOCK_GETTIME' << \!
1539 if(!clock_gettime(CLOCK_REALTIME, &ts) || errno != ENOSYS)
1546 elif run_check clock_gettime 'clock_gettime(2) (via -lrt)' \
1547 '#define HAVE_CLOCK_GETTIME' '-lrt' << \!
1553 if(!clock_gettime(CLOCK_REALTIME, &ts) || errno != ENOSYS)
1560 elif run_check gettimeofday 'gettimeofday(2)' \
1561 '#define HAVE_GETTIMEOFDAY' << \!
1562 #include <stdio.h> /* For C89 NULL */
1563 #include <sys/time.h>
1568 if(!gettimeofday(&tv, NULL) || errno != ENOSYS)
1576 have_no_subsecond_time=1
1579 if run_check nanosleep 'nanosleep(2)' \
1580 '#define HAVE_NANOSLEEP' << \!
1587 ts.tv_nsec = 100000;
1588 if(!nanosleep(&ts, NULL) || errno != ENOSYS)
1595 elif run_check nanosleep 'nanosleep(2) (via -lrt)' \
1596 '#define HAVE_NANOSLEEP' '-lrt' << \!
1603 ts.tv_nsec = 100000;
1604 if(!nanosleep(&ts, NULL) || errno != ENOSYS)
1611 # link_check is enough for this, that function is so old, trust the proto
1612 elif link_check sleep 'sleep(3)' \
1613 '#define HAVE_SLEEP' << \!
1617 if(!sleep(1) || errno != ENOSYS)
1625 msg 'ERROR: we require one of nanosleep(2) and sleep(3).'
1629 if run_check userdb 'gete?[gu]id(2), getpwuid(3), getpwnam(3)' << \!
1638 if((gid = getgid()) != 0)
1640 if((uid = getuid()) != 0)
1642 if((pw = getpwuid(uid)) == NULL && errno == ENOSYS)
1644 if((pw = getpwnam("root
")) == NULL && errno == ENOSYS)
1652 msg 'ERROR: we require user and group info / database searches.'
1653 msg 'That much Unix we indulge ourselfs.'
1657 if link_check ftruncate 'ftruncate(2)' \
1658 '#define HAVE_FTRUNCATE' << \!
1660 #include <sys/types.h>
1662 return (ftruncate(0, 0) != 0);
1668 # TODO support HAVE_FTRUNCATE *everywhere*, do not require this syscall!
1669 msg 'ERROR: we require the ftruncate(2) system call.'
1673 if run_check sa_restart 'SA_RESTART (for sigaction(2))' << \!
1677 struct sigaction nact, oact;
1679 nact.sa_handler = SIG_DFL;
1680 sigemptyset(&nact.sa_mask);
1681 nact.sa_flags = SA_RESTART;
1682 return !(!sigaction(SIGCHLD, &nact, &oact) || errno != ENOSYS);
1688 msg 'ERROR: we (yet) require the SA_RESTART flag for sigaction(2).'
1692 if link_check snprintf 'snprintf(3)' << \!
1697 snprintf(b, sizeof b, "%s
", "string
");
1704 msg 'ERROR: we require the snprintf(3) function.'
1708 if link_check environ 'environ(3)' << \!
1709 #include <stdio.h> /* For C89 NULL */
1711 extern char **environ;
1713 return environ[0] == NULL;
1719 msg 'ERROR: we require the environ(3) array for subprocess control.'
1723 if link_check setenv '(un)?setenv(3)' '#define HAVE_SETENV' << \!
1726 setenv("s-mailx
", "i want to see it cute
!", 1);
1727 unsetenv("s-mailx
");
1733 elif link_check setenv 'putenv(3)' '#define HAVE_PUTENV' << \!
1736 putenv("s-mailx
=i want to see it cute
!");
1743 msg 'ERROR: we require either the setenv(3) or putenv(3) functions.'
1747 if link_check termios 'termios.h and tc*(3) family' << \!
1748 #include <termios.h>
1750 struct termios tios;
1752 tcgetattr(0, &tios);
1753 tcsetattr(0, TCSANOW | TCSADRAIN | TCSAFLUSH, &tios);
1760 msg 'ERROR: we require termios.h and the tc[gs]etattr() family of functions.'
1761 msg 'That much Unix we indulge ourselfs.'
1767 if link_check vsnprintf 'vsnprintf(3)' << \!
1770 static void dome(char *buf, size_t blen, ...){
1774 vsnprintf(buf, blen, "%s
", ap);
1780 dome(b, sizeof b, "string
");
1787 feat_bail_required ERRORS
1790 if [ "${have_vsnprintf}" = yes ]; then
1792 link_check va_copy "va_copy
(3) (as
${2})" \
1793 "#define HAVE_N_VA_COPY
1794 #define n_va_copy ${2}" <<_EOT
1798 # if defined __va_copy && !defined va_copy
1799 # define va_copy __va_copy
1802 static void dome2
(char
*buf
, size_t blen
, va_list src
){
1806 vsnprintf
(buf
, blen
, "%s", ap
);
1809 static void dome
(char
*buf
, size_t blen
, ...
){
1813 dome2
(buf
, blen
, ap
);
1819 dome
(b
, sizeof b
, "string");
1824 __va_copy
0 va_copy || __va_copy
1 __va_copy
1827 run_check pathconf
'f?pathconf(2)' '#define HAVE_PATHCONF' << \
!
1834 rv |
= !(pathconf
(".", _PC_NAME_MAX
) >= 0 || errno
== 0 || errno
!= ENOSYS
);
1836 rv |
= !(pathconf
(".", _PC_PATH_MAX
) >= 0 || errno
== 0 || errno
!= ENOSYS
);
1838 /* Only link check
*/
1839 fpathconf
(0, _PC_NAME_MAX
);
1845 run_check pipe2
'pipe2(2)' '#define HAVE_PIPE2' << \
!
1852 if(!pipe2
(fds
, O_CLOEXEC
) || errno
!= ENOSYS
)
1858 link_check tcgetwinsize
'tcgetwinsize(3)' '#define HAVE_TCGETWINSIZE' << \
!
1859 #include <termios.h>
1863 tcgetwinsize
(0, &ws
);
1868 # We use this only then for now (need NOW+1)
1869 run_check utimensat
'utimensat(2)' '#define HAVE_UTIMENSAT' << \
!
1870 #include <fcntl.h> /* For AT_* */
1871 #include <sys/stat.h>
1874 struct timespec ts
[2];
1876 ts
[0].tv_nsec
= UTIME_NOW
;
1877 ts
[1].tv_nsec
= UTIME_OMIT
;
1878 if(!utimensat
(AT_FDCWD
, "", ts
, 0) || errno
!= ENOSYS
)
1886 # The random check has been moved to below TLS detection due to multiple choice
1887 # selection for PRG sources
1889 link_check putc_unlocked
'putc_unlocked(3)' '#define HAVE_PUTC_UNLOCKED' <<\
!
1892 putc_unlocked
('@', stdout
);
1897 link_check fchdir
'fchdir(3)' '#define HAVE_FCHDIR' << \
!
1905 if link_check realpath
'realpath(3)' '#define HAVE_REALPATH' << \
!
1908 char x_buf
[4096], *x
= realpath
(".", x_buf
);
1910 return (x
!= NULL
) ?
0 : 1;
1914 if run_check realpath_malloc
'realpath(3) takes NULL' \
1915 '#define HAVE_REALPATH_NULL' << \
!
1918 char
*x
= realpath
(".", NULL
);
1922 return (x
!= NULL
) ?
0 : 1;
1931 ## optional and selectable
1934 if feat_yes DOTLOCK
; then
1935 if run_check readlink
'readlink(2)' << \
!
1941 if(!readlink
("here", buf
, sizeof buf
) || errno
!= ENOSYS
)
1949 feat_bail_required DOTLOCK
1953 if feat_yes DOTLOCK
; then
1954 if run_check fchown
'fchown(2)' << \
!
1958 if(!fchown
(0, 0, 0) || errno
!= ENOSYS
)
1966 feat_bail_required DOTLOCK
1970 if feat_yes DOTLOCK
; then
1971 if run_check prctl_dumpable
'prctl(2) + PR_SET_DUMPABLE' \
1972 '#define HAVE_PRCTL_DUMPABLE' << \
!
1973 #include <sys/prctl.h>
1976 if(!prctl
(PR_SET_DUMPABLE
, 0) || errno
!= ENOSYS
)
1983 elif run_check prtrace_deny
'ptrace(2) + PT_DENY_ATTACH' \
1984 '#define HAVE_PTRACE_DENY' << \
!
1985 #include <sys/ptrace.h>
1988 if(ptrace
(PT_DENY_ATTACH
, 0, 0, 0) != -1 || errno
!= ENOSYS
)
1995 elif run_check setpflags_protect
'setpflags(2) + __PROC_PROTECT' \
1996 '#define HAVE_SETPFLAGS_PROTECT' << \
!
2000 if(!setpflags
(__PROC_PROTECT
, 1) || errno
!= ENOSYS
)
2010 ## Now it is the time to fork away the BASE_ series
2013 squeeze_em
${inc} ${tmp}
2015 squeeze_em
${lib} ${tmp}
2018 echo "BASE_LIBS = `${cat} ${lib}`" >> ${mk}
2019 echo "BASE_INCS
= `${cat} ${inc}`" >> ${mk}
2021 ## The remains are expected to be used only by the main MUA binary!
2024 link_check setlocale 'setlocale(3)' '#define HAVE_SETLOCALE' << \!
2027 setlocale(LC_ALL, "");
2031 [ -n "${have_setlocale}" ] && OPT_LOCALES=1
2033 OPT_MULTIBYTE_CHARSETS=0
2035 OPT_TERMINAL_CHARSET=0
2036 if [ -n "${have_setlocale}" ]; then
2037 link_check c90amend1 'ISO/IEC 9899:1990/Amendment 1:1995' \
2038 '#define HAVE_C90AMEND1' << \!
2044 char mbb[MB_LEN_MAX + 1];
2049 mbtowc(&wc, "x", 1);
2050 mbrtowc(&wc, "x", 1, NULL);
2052 return (mblen("\0", 1) == 0);
2055 [ -n "${have_c90amend1}" ] && OPT_MULTIBYTE_CHARSETS=1
2057 if [ -n "${have_c90amend1}" ]; then
2058 link_check wcwidth 'wcwidth(3)' '#define HAVE_WCWIDTH' << \!
2065 [ -n "${have_wcwidth}" ] && OPT_WIDE_GLYPHS=1
2068 link_check nl_langinfo 'nl_langinfo(3)' '#define HAVE_NL_LANGINFO' << \!
2069 #include <langinfo.h>
2073 return (nl_langinfo(CODESET) == NULL);
2076 [ -n "${have_nl_langinfo}" ] && OPT_TERMINAL_CHARSET=1
2079 link_check fnmatch 'fnmatch(3)' '#define HAVE_FNMATCH' << \!
2080 #include <fnmatch.h>
2082 return (fnmatch("*", ".", FNM_PATHNAME | FNM_PERIOD) == FNM_NOMATCH);
2086 link_check dirent_d_type 'struct dirent.d_type' '#define HAVE_DIRENT_TYPE' << \!
2090 return !(de.d_type == DT_UNKNOWN ||
2091 de.d_type == DT_DIR || de.d_type == DT_LNK);
2095 ## optional and selectable
2097 if feat_yes ICONV; then
2098 # To be able to create tests we need to figure out which replacement
2099 # sequence the iconv(3) implementation creates
2100 ${cat} > ${tmp2}.c << \!
2101 #include <stdio.h> /* For C89 NULL */
2105 char inb[16], oub[16], *inbp, *oubp;
2109 memcpy(inbp = inb, "\342\200\223", sizeof("\342\200\223"));
2110 inl = sizeof("\342\200\223") -1;
2114 if((id = iconv_open("ascii", "utf-8")) == (iconv_t)-1)
2116 if(iconv(id, &inbp, &inl, &oubp, &oul) == (size_t)-1)
2121 oul = (size_t)(oubp - oub);
2124 /* Character-wise replacement? */
2132 /* Byte-wise replacement? */
2133 if(oul == sizeof("\342\200\223") -1){
2134 if(!memcmp(oub, "???????", sizeof("\342\200\223") -1))
2136 if(!memcmp(oub, "*******", sizeof("\342\200\223") -1))
2143 < ${tmp2}.c link_check iconv 'iconv(3) functionality' \
2144 '#define HAVE_ICONV' ||
2145 < ${tmp2}.c link_check iconv 'iconv(3) functionality (via -liconv)' \
2146 '#define HAVE_ICONV' '-liconv' ||
2147 feat_bail_required ICONV
2149 if feat_no CROSS_BUILD; then
2150 { ${tmp}; } >/dev/null 2>&1
2152 2) echo 'MAILX_ICONV_MODE=2;export MAILX_ICONV_MODE;' >> ${ev};;
2153 3) echo 'MAILX_ICONV_MODE=3;export MAILX_ICONV_MODE;' >> ${ev};;
2154 12) echo 'MAILX_ICONV_MODE=12;export MAILX_ICONV_MODE;' >> ${ev};;
2155 13) echo 'MAILX_ICONV_MODE=13;export MAILX_ICONV_MODE;' >> ${ev};;
2156 *) msg 'WARN: will restrict iconv(3) tests due to unknown replacement';;
2160 feat_is_disabled ICONV
2163 if feat_yes SOCKETS || feat_yes SPAM_SPAMD; then
2164 ${cat} > ${tmp2}.c << \!
2165 #include <sys/types.h>
2166 #include <sys/socket.h>
2170 struct sockaddr_un soun;
2172 if(socket(AF_UNIX, SOCK_STREAM, 0) == -1 && errno == ENOSYS)
2174 if(connect(0, (struct sockaddr*)&soun, 0) == -1 && errno == ENOSYS)
2176 if(shutdown(0, SHUT_RD | SHUT_WR | SHUT_RDWR) == -1 && errno == ENOSYS)
2182 < ${tmp2}.c run_check af_unix 'AF_UNIX sockets' \
2183 '#define HAVE_UNIX_SOCKETS' ||
2184 < ${tmp2}.c run_check af_unix 'AF_UNIX sockets (via -lnsl)' \
2185 '#define HAVE_UNIX_SOCKETS' '-lnsl' ||
2186 < ${tmp2}.c run_check af_unix 'AF_UNIX sockets (via -lsocket -lnsl)' \
2187 '#define HAVE_UNIX_SOCKETS' '-lsocket -lnsl'
2190 if feat_yes SOCKETS; then
2191 ${cat} > ${tmp2}.c << \!
2192 #include <sys/types.h>
2193 #include <sys/socket.h>
2194 #include <netinet/in.h>
2199 if(socket(AF_INET, SOCK_STREAM, 0) == -1 && errno == ENOSYS)
2201 if(connect(0, &s, 0) == -1 && errno == ENOSYS)
2207 < ${tmp2}.c run_check sockets 'sockets' \
2208 '#define HAVE_SOCKETS' ||
2209 < ${tmp2}.c run_check sockets 'sockets (via -lnsl)' \
2210 '#define HAVE_SOCKETS' '-lnsl' ||
2211 < ${tmp2}.c run_check sockets 'sockets (via -lsocket -lnsl)' \
2212 '#define HAVE_SOCKETS' '-lsocket -lnsl' ||
2213 feat_bail_required SOCKETS
2215 feat_is_disabled SOCKETS
2216 fi # feat_yes SOCKETS
2219 link_check sockopt '[gs]etsockopt(2)' '#define HAVE_SOCKOPT' << \!
2220 #include <sys/socket.h>
2225 int sockfd = 3, soe;
2228 if(getsockopt(sockfd, SOL_SOCKET, SO_ERROR, &soe, &sol) == -1 &&
2231 if(setsockopt(sockfd, SOL_SOCKET, SO_KEEPALIVE, NULL, 0) == -1 &&
2239 link_check nonblocksock 'non-blocking sockets' \
2240 '#define HAVE_NONBLOCKSOCK' << \!
2241 #include <sys/types.h>
2242 #include <sys/select.h>
2243 #include <sys/socket.h>
2244 #include <sys/time.h>
2245 #include <arpa/inet.h>
2246 #include <netinet/in.h>
2254 struct sockaddr_in sin;
2258 if((sofd = socket(AF_INET, SOCK_STREAM, 0)) == -1 && errno == ENOSYS)
2260 if(fcntl(sofd, F_SETFL, O_NONBLOCK) != 0)
2263 sin.sin_family = AF_INET;
2264 sin.sin_addr.s_addr = inet_addr("127.0.0.1");
2265 sin.sin_port = htons(80);
2266 if(connect(sofd, &sin, sizeof sin) == -1 && errno == ENOSYS)
2270 FD_SET(sofd, &fdset);
2273 if((soe = select(sofd + 1, NULL, &fdset, NULL, &tv)) == 1){
2275 getsockopt(sofd, SOL_SOCKET, SO_ERROR, &soe, &sol);
2278 }else if(soe == -1 && errno == ENOSYS)
2286 if feat_yes SOCKETS; then
2287 link_check getaddrinfo 'getaddrinfo(3)' \
2288 '#define HAVE_GETADDRINFO' << \!
2289 #include <sys/types.h>
2290 #include <sys/socket.h>
2294 struct addrinfo a, *ap;
2297 switch((lrv = getaddrinfo("foo", "0", &a, &ap))){
2301 fprintf(stderr, "%s\n", gai_strerror(lrv));
2310 if feat_yes SOCKETS && [ -z "${have_getaddrinfo}" ]; then
2311 compile_check arpa_inet_h '<arpa/inet.h>' \
2312 '#define HAVE_ARPA_INET_H' << \!
2313 #include <sys/types.h>
2314 #include <sys/socket.h>
2316 #include <netinet/in.h>
2317 #include <arpa/inet.h>
2320 ${cat} > ${tmp2}.c << \!
2321 #include <sys/types.h>
2322 #include <sys/socket.h>
2326 #include <netinet/in.h>
2327 #ifdef HAVE_ARPA_INET_H
2328 #include <arpa/inet.h>
2331 struct sockaddr_in servaddr;
2332 unsigned short portno;
2335 struct in_addr **pptr;
2338 if((ep = getservbyname("POPPY-PORT", "tcp")) != NULL)
2339 portno = (unsigned short)ep->s_port;
2341 if((hp = gethostbyname("POPPY-HOST")) != NULL){
2342 pptr = (struct in_addr**)hp->h_addr_list;
2343 if(hp->h_addrtype != AF_INET)
2344 fprintf(stderr, "au\n");
2347 case HOST_NOT_FOUND:
2353 fprintf(stderr, "au\n");
2358 memset(&servaddr, 0, sizeof servaddr);
2359 servaddr.sin_family = AF_INET;
2360 servaddr.sin_port = htons(portno);
2361 memcpy(&servaddr.sin_addr, *pptr, sizeof(struct in_addr));
2362 fprintf(stderr, "Would connect to %s:%d ...\n",
2363 inet_ntoa(**pptr), (int)portno);
2368 < ${tmp2}.c link_check gethostbyname 'get(serv|host)byname(3)' ||
2369 < ${tmp2}.c link_check gethostbyname \
2370 'get(serv|host)byname(3) (via -nsl)' '' '-lnsl' ||
2371 < ${tmp2}.c link_check gethostbyname \
2372 'get(serv|host)byname(3) (via -lsocket -nsl)' \
2373 '' '-lsocket -lnsl' ||
2374 feat_bail_required SOCKETS
2377 feat_yes SOCKETS && [ -n "${have_sockopt}" ] &&
2378 link_check so_xtimeo 'SO_{RCV,SND}TIMEO' '#define HAVE_SO_XTIMEO' << \!
2379 #include <sys/socket.h>
2387 setsockopt(sockfd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof tv);
2388 setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof tv);
2393 feat_yes SOCKETS && [ -n "${have_sockopt}" ] &&
2394 link_check so_linger 'SO_LINGER' '#define HAVE_SO_LINGER' << \!
2395 #include <sys/socket.h>
2403 setsockopt(sockfd, SOL_SOCKET, SO_LINGER, &li, sizeof li);
2409 if feat_yes TLS; then # {{{
2410 # {{{ LibreSSL decided to define OPENSSL_VERSION_NUMBER with a useless value
2411 # instead of keeping it at the one that corresponds to the OpenSSL at fork
2412 # time: we need to test it first in order to get things right
2413 if compile_check _xtls 'TLS (LibreSSL)' \
2416 #define HAVE_XTLS_RESSL
2417 #define HAVE_XTLS_OPENSSL 0' << \!
2418 #include <openssl/opensslv.h>
2419 #ifdef LIBRESSL_VERSION_NUMBER
2426 VAL_TLS_FEATURES=libressl
2427 # TODO OPENSSL_IS_BORINGSSL, but never tried that one!
2428 elif compile_check _xtls 'TLS (OpenSSL >= v1.1.0)' \
2431 #define HAVE_XTLS_OPENSSL 0x10100' << \!
2432 #include <openssl/opensslv.h>
2433 #if OPENSSL_VERSION_NUMBER + 0 >= 0x10100000L
2440 VAL_TLS_FEATURES=libssl-0x10100
2441 elif compile_check _xtls 'TLS (OpenSSL)' \
2444 #define HAVE_XTLS_OPENSSL 0x10000' << \!
2445 #include <openssl/opensslv.h>
2446 #ifdef OPENSSL_VERSION_NUMBER
2453 VAL_TLS_FEATURES=libssl-0x10000
2455 feat_bail_required TLS
2458 if feat_yes TLS; then # {{{
2459 if [ -n "${ossl_v1_1}" ]; then
2460 without_check yes xtls 'TLS new style TLS_client_method(3ssl)' \
2461 '#define n_XTLS_CLIENT_METHOD TLS_client_method' \
2463 elif link_check xtls 'TLS new style TLS_client_method(3ssl)' \
2464 '#define n_XTLS_CLIENT_METHOD TLS_client_method' \
2465 '-lssl -lcrypto' << \!
2466 #include <openssl/ssl.h>
2467 #include <openssl/err.h>
2468 #include <openssl/x509v3.h>
2469 #include <openssl/x509.h>
2470 #include <openssl/rand.h>
2471 #ifdef OPENSSL_NO_TLS1 /* TODO only deduced from OPENSSL_NO_SSL[23]! */
2472 # error We need TLSv1.
2475 SSL_CTX *ctx = SSL_CTX_new(TLS_client_method());
2478 PEM_read_PrivateKey(0, 0, 0, 0);
2484 elif link_check xtls 'TLS old style SSLv23_client_method(3ssl)' \
2485 '#define n_XTLS_CLIENT_METHOD SSLv23_client_method' \
2486 '-lssl -lcrypto' << \!
2487 #include <openssl/ssl.h>
2488 #include <openssl/err.h>
2489 #include <openssl/x509v3.h>
2490 #include <openssl/x509.h>
2491 #include <openssl/rand.h>
2492 #if defined OPENSSL_NO_SSL3 &&\
2493 defined OPENSSL_NO_TLS1 /* TODO only deduced from OPENSSL_NO_SSL[23]! */
2494 # error We need one of SSLv3 and TLSv1.
2497 SSL_CTX *ctx = SSL_CTX_new(SSLv23_client_method());
2500 PEM_read_PrivateKey(0, 0, 0, 0);
2507 feat_bail_required TLS
2511 if feat_yes TLS; then # {{{
2512 if [ -n "${ossl_v1_1}" ]; then
2513 without_check yes xtls_stack_of 'TLS STACK_OF()' \
2514 '#define HAVE_XTLS_STACK_OF'
2515 elif compile_check xtls_stack_of 'TLS STACK_OF()' \
2516 '#define HAVE_XTLS_STACK_OF' << \!
2517 #include <stdio.h> /* For C89 NULL */
2518 #include <openssl/ssl.h>
2519 #include <openssl/err.h>
2520 #include <openssl/x509v3.h>
2521 #include <openssl/x509.h>
2522 #include <openssl/rand.h>
2524 STACK_OF(GENERAL_NAME) *gens = NULL;
2526 printf("%p", gens); /* to use it */
2534 if [ -n "${ossl_v1_1}" ]; then
2535 without_check yes xtls_conf 'TLS OpenSSL_modules_load_file(3ssl)' \
2536 '#define HAVE_XTLS_CONFIG'
2537 VAL_TLS_FEATURES="${VAL_TLS_FEATURES},+modules-load-file"
2538 elif link_check xtls_conf \
2539 'TLS OpenSSL_modules_load_file(3ssl) support' \
2540 '#define HAVE_XTLS_CONFIG' << \!
2541 #include <stdio.h> /* For C89 NULL */
2542 #include <openssl/conf.h>
2544 CONF_modules_load_file(NULL, NULL, CONF_MFLAGS_IGNORE_MISSING_FILE);
2545 CONF_modules_free();
2550 VAL_TLS_FEATURES="${VAL_TLS_FEATURES},+modules-load-file"
2552 VAL_TLS_FEATURES="${VAL_TLS_FEATURES},-modules-load-file"
2555 if [ -n "${ossl_v1_1}" ]; then
2556 without_check yes xtls_conf_ctx 'TLS SSL_CONF_CTX support' \
2557 '#define HAVE_XTLS_CONF_CTX'
2558 VAL_TLS_FEATURES="${VAL_TLS_FEATURES},+conf-ctx"
2559 elif link_check xtls_conf_ctx 'TLS SSL_CONF_CTX support' \
2560 '#define HAVE_XTLS_CONF_CTX' << \!
2561 #include <openssl/ssl.h>
2562 #include <openssl/err.h>
2564 SSL_CTX *ctx = SSL_CTX_new(n_XSSL_CLIENT_METHOD());
2565 SSL_CONF_CTX *cctx = SSL_CONF_CTX_new();
2567 SSL_CONF_CTX_set_flags(cctx,
2568 SSL_CONF_FLAG_FILE | SSL_CONF_FLAG_CLIENT |
2569 SSL_CONF_FLAG_CERTIFICATE | SSL_CONF_FLAG_SHOW_ERRORS);
2570 SSL_CONF_CTX_set_ssl_ctx(cctx, ctx);
2571 SSL_CONF_cmd(cctx, "Protocol", "ALL");
2572 SSL_CONF_CTX_finish(cctx);
2573 SSL_CONF_CTX_free(cctx);
2579 VAL_TLS_FEATURES="${VAL_TLS_FEATURES},+conf-ctx"
2581 VAL_TLS_FEATURES="${VAL_TLS_FEATURES},-conf-ctx"
2584 if [ -n "${ossl_v1_1}" ]; then
2585 without_check yes xtls_ctx_config 'TLS SSL_CTX_config(3ssl)' \
2586 '#define HAVE_XTLS_CTX_CONFIG'
2587 VAL_TLS_FEATURES="${VAL_TLS_FEATURES},+ctx-config"
2588 elif [ -n "${have_xtls_conf}" ] && [ -n "${have_xtls_conf_ctx}" ] &&
2589 link_check xtls_ctx_config 'TLS SSL_CTX_config(3ssl)' \
2590 '#define HAVE_XTLS_CTX_CONFIG' << \!
2591 #include <stdio.h> /* For C89 NULL */
2592 #include <openssl/ssl.h>
2594 SSL_CTX_config(NULL, "SOMEVAL");
2599 VAL_TLS_FEATURES="${VAL_TLS_FEATURES},+ctx-config"
2601 VAL_TLS_FEATURES="${VAL_TLS_FEATURES},-ctx-config"
2604 if [ -n "${ossl_v1_1}" ] && [ -n "${have_xtls_conf_ctx}" ]; then
2605 without_check yes xtls_set_maxmin_proto \
2606 'TLS SSL_CTX_set_min_proto_version(3ssl)' \
2607 '#define HAVE_XTLS_SET_MIN_PROTO_VERSION'
2608 VAL_TLS_FEATURES="${VAL_TLS_FEATURES},+ctx-set-maxmin-proto"
2609 elif link_check xtls_set_maxmin_proto \
2610 'TLS SSL_CTX_set_min_proto_version(3ssl)' \
2611 '#define HAVE_XTLS_SET_MIN_PROTO_VERSION' << \!
2612 #include <stdio.h> /* For C89 NULL */
2613 #include <openssl/ssl.h>
2615 SSL_CTX_set_min_proto_version(NULL, 0);
2616 SSL_CTX_set_max_proto_version(NULL, 10);
2621 VAL_TLS_FEATURES="${VAL_TLS_FEATURES},+ctx-set-maxmin-proto"
2623 VAL_TLS_FEATURES="${VAL_TLS_FEATURES},-ctx-set-maxmin-proto"
2626 if [ -n "${ossl_v1_1}" ] && [ -n "${have_xtls_conf_ctx}" ]; then
2627 without_check yes xtls_set_ciphersuites \
2628 'TLSv1.3 SSL_CTX_set_ciphersuites(3ssl)' \
2629 '#define HAVE_XTLS_SET_CIPHERSUITES'
2630 VAL_TLS_FEATURES="${VAL_TLS_FEATURES},+ctx-set-ciphersuites"
2631 elif link_check xtls_set_ciphersuites \
2632 'TLSv1.3 SSL_CTX_set_ciphersuites(3ssl)' \
2633 '#define HAVE_XTLS_SET_CIPHERSUITES' << \!
2634 #include <stdio.h> /* For C89 NULL */
2635 #include <openssl/ssl.h>
2637 SSL_CTX_set_ciphersuites(NULL, NULL);
2642 VAL_TLS_FEATURES="${VAL_TLS_FEATURES},+ctx-set-ciphersuites"
2644 VAL_TLS_FEATURES="${VAL_TLS_FEATURES},-ctx-set-ciphersuites"
2646 fi # feat_yes SSL }}}
2648 if feat_yes TLS; then # digest etc algorithms {{{
2649 if feat_yes TLS_ALL_ALGORITHMS; then
2650 if [ -n "${ossl_v1_1}" ]; then
2651 without_check yes tls_all_algo 'TLS all-algorithms support' \
2652 '#define HAVE_TLS_ALL_ALGORITHMS'
2653 elif link_check tls_all_algo 'TLS all-algorithms support' \
2654 '#define HAVE_TLS_ALL_ALGORITHMS' << \!
2655 #include <openssl/evp.h>
2657 OpenSSL_add_all_algorithms();
2658 EVP_get_cipherbyname("two cents i never exist");
2666 feat_bail_required TLS_ALL_ALGORITHMS
2668 elif [ -n "${ossl_v1_1}" ]; then
2669 without_check yes tls_all_algo \
2670 'TLS all-algorithms (always available in v1.1.0+)' \
2671 '#define HAVE_TLS_ALL_ALGORITHMS'
2675 link_check tls_blake2 'TLS: BLAKE2 digests' \
2676 '#define HAVE_XTLS_BLAKE2' << \!
2677 #include <openssl/evp.h>
2686 link_check tls_sha3 'TLS: SHA-3 digests' '#define HAVE_XTLS_SHA3' << \!
2687 #include <openssl/evp.h>
2697 if feat_yes MD5 && feat_no NOEXTMD5; then
2698 run_check tls_md5 'TLS: MD5 digest' '#define HAVE_XTLS_MD5' << \!
2701 #include <openssl/md5.h>
2703 char const dat[] = "abrakadabrafidibus";
2704 char dig[16], hex[16 * 2];
2708 memset(dig, 0, sizeof(dig));
2709 memset(hex, 0, sizeof(hex));
2711 MD5_Update(&ctx, dat, sizeof(dat) - 1);
2712 MD5_Final(dig, &ctx);
2714 #define hexchar(n) ((n) > 9 ? (n) - 10 + 'a' : (n) + '0')
2715 for(i = 0; i < sizeof(hex) / 2; i++){
2717 hex[j] = hexchar((dig[i] & 0xf0) >> 4);
2718 hex[++j] = hexchar(dig[i] & 0x0f);
2720 return !!memcmp("6d7d0a3d949da2e96f2aa010f65d8326", hex, sizeof(hex));
2726 if feat_yes TLS; then
2727 feat_def TLS_ALL_ALGORITHMS
2729 feat_bail_required TLS_ALL_ALGORITHMS
2732 feat_is_disabled TLS
2733 feat_is_disabled TLS_ALL_ALGORITHMS
2734 fi # }}} feat_yes TLS
2735 printf '#define VAL_TLS_FEATURES "#'"${VAL_TLS_FEATURES}"'"\n' >> ${h}
2737 if [ "${have_xtls}" = yes ]; then
2745 if val_allof VAL_RANDOM \
2746 "arc4,tls,libgetrandom,sysgetrandom,urandom,builtin,error"; then
2749 msg 'ERROR: VAL_RANDOM with invalid entries: %s' "${VAL_RANDOM}"
2754 link_check arc4random 'VAL_RANDOM: arc4random(3)' \
2755 '#define HAVE_RANDOM n_RANDOM_IMPL_ARC4' << \!
2765 if feat_yes TLS; then
2766 msg ' . VAL_RANDOM: tls ... yes'
2767 echo '#define HAVE_RANDOM n_RANDOM_IMPL_TLS' >> ${h}
2770 msg ' . VAL_RANDOM: tls ... no'
2775 val_random_libgetrandom() {
2776 link_check getrandom 'VAL_RANDOM: getrandom(3) (in sys/random.h)' \
2777 '#define HAVE_RANDOM n_RANDOM_IMPL_GETRANDOM
2778 #define n_RANDOM_GETRANDOM_FUN(B,S) getrandom(B, S, 0)
2779 #define n_RANDOM_GETRANDOM_H <sys/random.h>' <<\!
2780 #include <sys/random.h>
2783 getrandom(buf, sizeof buf, 0);
2789 val_random_sysgetrandom() {
2790 link_check getrandom 'VAL_RANDOM: getrandom(2) (via syscall(2))' \
2791 '#define HAVE_RANDOM n_RANDOM_IMPL_GETRANDOM
2792 #define n_RANDOM_GETRANDOM_FUN(B,S) syscall(SYS_getrandom, B, S, 0)
2793 #define n_RANDOM_GETRANDOM_H <sys/syscall.h>' <<\!
2794 #include <sys/syscall.h>
2797 syscall(SYS_getrandom, buf, sizeof buf, 0);
2803 val_random_urandom() {
2804 msg_nonl ' . VAL_RANDOM: /dev/urandom ... '
2805 if feat_yes CROSS_BUILD; then
2806 msg 'yes (unchecked)'
2807 echo '#define HAVE_RANDOM n_RANDOM_IMPL_URANDOM' >> ${h}
2808 elif [ -f /dev/urandom ]; then
2810 echo '#define HAVE_RANDOM n_RANDOM_IMPL_URANDOM' >> ${h}
2818 val_random_builtin() {
2819 msg_nonl ' . VAL_RANDOM: builtin ... '
2820 if [ -n "${have_no_subsecond_time}" ]; then
2821 msg 'no\nERROR: %s %s' 'without a specialized PRG ' \
2822 'one of clock_gettime(2) and gettimeofday(2) is required.'
2826 echo '#define HAVE_RANDOM n_RANDOM_IMPL_BUILTIN' >> ${h}
2830 val_random_error() {
2831 msg 'ERROR: VAL_RANDOM search reached "error" entry'
2837 VAL_RANDOM="${VAL_RANDOM},error"
2838 set -- ${VAL_RANDOM}
2842 eval val_random_$randfun && break
2850 if feat_yes GSSAPI; then
2851 ${cat} > ${tmp2}.c << \!
2852 #include <gssapi/gssapi.h>
2854 gss_import_name(0, 0, GSS_C_NT_HOSTBASED_SERVICE, 0);
2855 gss_init_sec_context(0,0,0,0,0,0,0,0,0,0,0,0,0);
2859 ${sed} -e '1s/gssapi\///' < ${tmp2}.c > ${tmp3}.c
2861 if acmd_set i krb5-config; then
2862 GSS_LIBS="`CFLAGS
= ${i} --libs gssapi
`"
2863 GSS_INCS="`CFLAGS
= ${i} --cflags`"
2864 i='GSS-API via krb5-config(1)'
2868 i='GSS-API in gssapi/gssapi.h, libgssapi'
2870 if < ${tmp2}.c link_check gss \
2871 "${i}" '#define HAVE_GSSAPI' "${GSS_LIBS}" "${GSS_INCS}" ||\
2872 < ${tmp3}.c link_check gss \
2873 'GSS-API in gssapi.h, libgssapi' \
2874 '#define HAVE_GSSAPI
2875 #define GSSAPI_REG_INCLUDE' \
2877 < ${tmp2}.c link_check gss 'GSS-API in libgssapi_krb5' \
2878 '#define HAVE_GSSAPI' \
2880 < ${tmp3}.c link_check gss \
2881 'GSS-API in libgssapi, OpenBSD-style (pre 5.3)' \
2882 '#define HAVE_GSSAPI
2883 #define GSS_REG_INCLUDE' \
2884 '-lgssapi -lkrb5 -lcrypto' \
2885 '-I/usr/include/kerberosV' ||\
2886 < ${tmp2}.c link_check gss 'GSS-API in libgss' \
2887 '#define HAVE_GSSAPI' \
2889 link_check gss 'GSS-API in libgssapi_krb5, old-style' \
2890 '#define HAVE_GSSAPI
2891 #define GSSAPI_OLD_STYLE' \
2892 '-lgssapi_krb5' << \!
2893 #include <gssapi/gssapi.h>
2894 #include <gssapi/gssapi_generic.h>
2896 gss_import_name(0, 0, gss_nt_service_name, 0);
2897 gss_init_sec_context(0,0,0,0,0,0,0,0,0,0,0,0,0);
2904 feat_bail_required GSSAPI
2907 feat_is_disabled GSSAPI
2908 fi # feat_yes GSSAPI
2913 if feat_yes IDNA; then # {{{
2914 if val_allof VAL_IDNA "idnkit,idn2,idn"; then
2917 msg 'ERROR: VAL_IDNA with invalid entries: %s' "${VAL_IDNA}"
2922 link_check idna 'OPT_IDNA: GNU Libidn2' \
2923 '#define HAVE_IDNA n_IDNA_IMPL_LIBIDN2' '-lidn2' << \!
2926 char *idna_utf8, *idna_lc;
2928 if(idn2_to_ascii_8z("does.this.work", &idna_utf8,
2929 IDN2_NONTRANSITIONAL | IDN2_TRANSITIONAL) != IDN2_OK)
2931 if(idn2_to_unicode_8zlz(idna_utf8, &idna_lc, 0) != IDN2_OK)
2934 idn2_free(idna_utf8);
2941 link_check idna 'OPT_IDNA: GNU Libidn' \
2942 '#define HAVE_IDNA n_IDNA_IMPL_LIBIDN' '-lidn' << \!
2944 #include <idn-free.h>
2945 #include <stringprep.h> /* XXX we actually use our own iconv instead */
2947 char *utf8, *idna_ascii, *idna_utf8;
2949 utf8 = stringprep_locale_to_utf8("does.this.work");
2950 if (idna_to_ascii_8z(utf8, &idna_ascii, IDNA_USE_STD3_ASCII_RULES)
2953 idn_free(idna_ascii);
2954 /* (Rather link check only here) */
2955 idna_utf8 = stringprep_convert(idna_ascii, "UTF-8", "de_DE");
2962 link_check idna 'OPT_IDNA: idnkit' \
2963 '#define HAVE_IDNA n_IDNA_IMPL_IDNKIT' '-lidnkit' << \!
2965 #include <idn/api.h>
2966 #include <idn/result.h>
2970 char local_name[256];
2972 r = idn_encodename(IDN_ENCODE_APP, "does.this.work", ace_name,
2974 if (r != idn_success) {
2975 fprintf(stderr, "idn_encodename failed: %s\n", idn_result_tostring(r));
2978 r = idn_decodename(IDN_DECODE_APP, ace_name, local_name, sizeof(local_name));
2979 if (r != idn_success) {
2980 fprintf(stderr, "idn_decodename failed: %s\n", idn_result_tostring(r));
2989 feat_bail_required IDNA
2994 VAL_IDNA="${VAL_IDNA},bye"
2999 eval val_idna_$randfun && break
3002 feat_is_disabled IDNA
3005 feat_def IMAP_SEARCH
3007 if feat_yes REGEX; then
3008 if link_check regex 'regular expressions' '#define HAVE_REGEX' << \!
3016 status = regcomp(&re, ".*bsd", REG_EXTENDED | REG_ICASE | REG_NOSUB);
3017 xret = regerror(status, &re, NULL, 0);
3018 status = regexec(&re, "plan9", 0,NULL, 0);
3020 return !(status == REG_NOMATCH);
3026 feat_bail_required REGEX
3029 feat_is_disabled REGEX
3032 if feat_yes MLE; then
3033 if [ -n "${have_c90amend1}" ]; then
3035 echo '#define HAVE_MLE' >> ${h}
3037 feat_bail_required MLE
3040 feat_is_disabled MLE
3043 # Generic have-a-line-editor switch for those who need it below
3044 if [ -n "${have_mle}" ]; then
3048 if feat_yes HISTORY; then
3049 if [ -n "${have_cle}" ]; then
3050 echo '#define HAVE_HISTORY' >> ${h}
3052 feat_is_unsupported HISTORY
3055 feat_is_disabled HISTORY
3058 if feat_yes KEY_BINDINGS; then
3059 if [ -n "${have_mle}" ]; then
3060 echo '#define HAVE_KEY_BINDINGS' >> ${h}
3062 feat_is_unsupported KEY_BINDINGS
3065 feat_is_disabled KEY_BINDINGS
3068 if feat_yes TERMCAP; then # {{{
3071 link_check termcap "termcap(5) (via ${4}${ADDINC})" \
3072 "#define HAVE_TERMCAP${3}" "${1}" "${ADDINC}" << _EOT
3077 #define UNCONST(P) ((void*)(unsigned long)(void const*)(P))
3078 static int my_putc(int c){return putchar(c);}
3080 char buf[1024+512], cmdbuf[2048], *cpb, *r1;
3081 int r2 = OK, r3 = ERR;
3083 tgetent(buf, getenv("TERM"));
3085 r1 = tgetstr(UNCONST("cm"), &cpb);
3087 r2 = tgetnum(UNCONST("Co"));
3088 r3 = tgetflag(UNCONST("ut"));
3089 tputs("cr", 1, &my_putc);
3090 return (r1 == NULL || r2 == -1 || r3 == 0);
3096 link_check terminfo "terminfo(5) (via ${2}${ADDINC})" \
3097 '#define HAVE_TERMCAP
3098 #define HAVE_TERMCAP_CURSES
3099 #define HAVE_TERMINFO' "${1}" "${ADDINC}" << _EOT
3103 #define UNCONST(P) ((void*)(unsigned long)(void const*)(P))
3104 static int my_putc(int c){return putchar(c);}
3110 r0 = setupterm(NULL, 1, &er);
3111 r1 = tigetflag(UNCONST("bce"));
3112 r2 = tigetnum(UNCONST("colors"));
3113 r3 = tigetstr(UNCONST("cr"));
3114 tp = tparm(r3, NULL, NULL, 0,0,0,0,0,0,0);
3115 tputs(tp, 1, &my_putc);
3116 return (r0 == ERR || r1 == -1 || r2 == -2 || r2 == -1 ||
3117 r3 == (char*)-1 || r3 == NULL);
3122 if feat_yes TERMCAP_VIA_TERMINFO; then
3126 __terminfolib -ltinfo -ltinfo ||
3127 __terminfolib -lcurses -lcurses ||
3128 __terminfolib -lcursesw -lcursesw ||
3132 if [ -n "${xbail}" ] && [ -d /usr/local/include/ncurses ]; then
3133 ADDINC=' -I/usr/local/include/ncurses'
3136 if [ -n "${xbail}" ] && [ -d /usr/include/ncurses ]; then
3137 ADDINC=' -I/usr/include/ncurses'
3140 [ -n "${xbail}" ] && feat_bail_required TERMCAP_VIA_TERMINFO
3143 if [ -z "${have_terminfo}" ]; then
3147 __termcaplib -ltermcap '' '' '-ltermcap' ||
3148 __termcaplib -ltermcap '#include <curses.h>' '
3149 #define HAVE_TERMCAP_CURSES' \
3150 'curses.h / -ltermcap' ||
3151 __termcaplib -lcurses '#include <curses.h>' '
3152 #define HAVE_TERMCAP_CURSES' \
3153 'curses.h / -lcurses' ||
3154 __termcaplib -lcursesw '#include <curses.h>' '
3155 #define HAVE_TERMCAP_CURSES' \
3156 'curses.h / -lcursesw' ||
3160 if [ -n "${xbail}" ] && [ -d /usr/local/include/ncurses ]; then
3161 ADDINC=' -I/usr/local/include/ncurses'
3164 if [ -n "${xbail}" ] && [ -d /usr/include/ncurses ]; then
3165 ADDINC=' -I/usr/include/ncurses'
3168 [ -n "${xbail}" ] && feat_bail_required TERMCAP
3170 if [ -n "${have_termcap}" ]; then
3171 run_check tgetent_null \
3172 "tgetent(3) of termcap(5) takes NULL buffer" \
3173 "#define HAVE_TGETENT_NULL_BUF" << _EOT
3174 #include <stdio.h> /* For C89 NULL */
3176 #ifdef HAVE_TERMCAP_CURSES
3177 # include <curses.h>
3181 tgetent(NULL, getenv("TERM"));
3189 feat_is_disabled TERMCAP
3190 feat_is_disabled TERMCAP_VIA_TERMINFO
3193 if feat_def SPAM_SPAMC; then
3194 if acmd_set i spamc; then
3195 echo "#define SPAM_SPAMC_PATH \"${i}\"" >> ${h}
3199 if feat_yes SPAM_SPAMD; then
3200 if [ -n "${have_af_unix}" ]; then
3201 echo '#define HAVE_SPAM_SPAMD' >> ${h}
3203 feat_bail_required SPAM_SPAMD
3206 feat_is_disabled SPAM_SPAMD
3209 feat_def SPAM_FILTER
3211 if feat_yes SPAM_SPAMC || feat_yes SPAM_SPAMD || feat_yes SPAM_FILTER; then
3212 echo '#define HAVE_SPAM' >> ${h}
3214 echo '/* HAVE_SPAM */' >> ${h}
3217 if feat_yes QUOTE_FOLD; then
3218 if [ -n "${have_c90amend1}" ] && [ -n "${have_wcwidth}" ]; then
3219 echo '#define HAVE_QUOTE_FOLD' >> ${h}
3221 feat_bail_required QUOTE_FOLD
3224 feat_is_disabled QUOTE_FOLD
3227 feat_def FILTER_HTML_TAGSOUP
3235 squeeze_em ${inc} ${tmp}
3237 squeeze_em ${lib} ${tmp}
3240 echo "LIBS = `${cat} ${lib}`" >> ${mk}
3241 echo "INCS = `${cat} ${inc}`" >> ${mk}
3246 printf '#ifndef n_MK_CONFIG_H\n# define n_MK_CONFIG_H 1\n' > ${h}
3247 ${cat} ${tmp} >> ${h}
3249 # Also need these for correct "second stage configuration changed
" detection */
3251 if (${CC} --version) >/dev/null 2>&1; then
3252 i=`${CC} --version 2>&1 | ${awk} '
3254 {if(length($0)) {if(l) l = l "\\\\n
"; l = l "@
" $0}}
3255 END{gsub(/"/, "", l
); print
"\\\\n" l
}
3257 elif (${CC} -v) >/dev/null 2>&1; then
3258 i=`${CC} -v 2>&1 | ${awk} '
3260 {if(length
($0)) {if(l
) l
= l
"\\\\n"; l
= l
"@" $0}}
3261 END
{gsub
(/"/, "", l); print "\\\\n
" l}
3264 printf '#define VAL_BUILD_CC "%s
%s
%s
%s
"\n' \
3265 "${CC}" "${CFLAGS}" "" "${i}" >> ${h}
3266 printf '#define VAL_BUILD_LD "%s %s %s"\n' \
3267 "${CC}" "${LDFLAGS}" "`${cat} ${lib}`" >> ${h}
3268 printf '#define VAL_BUILD_REST "%s
"\n' "${COMMLINE}" >> ${h}
3271 # Throw away all temporaries
3272 ${rm} -rf ${tmp0}.* ${tmp0}*
3274 # Create the string that is used by *features* and `version'.
3275 # Take this nice opportunity and generate a visual listing of included and
3276 # non-included features for the person who runs the configuration
3277 echo 'The following features are included (+) or not (-):' > ${tmp}
3278 set -- ${OPTIONS_DETECT} ${OPTIONS} ${OPTIONS_XTRA}
3279 printf '/* The "feature string
" */\n' >> ${h}
3280 # Because + is expanded by *folder* if first in "echo $features", put something
3281 printf '#define VAL_FEATURES_CNT '${#}'\n#define VAL_FEATURES "#' >> ${h}
3285 sdoc
=`option_doc_of ${opt}`
3286 [ -z "${sdoc}" ] && continue
3287 sopt
="`echo ${opt} | ${tr} '[A-Z]_' '[a-z]-'`"
3288 feat_yes
${opt} && sign
=+ || sign
=-
3289 printf -- "${sep}${sign}${sopt}" >> ${h}
3291 printf ' %s %s: %s\n' ${sign} ${sopt} "${sdoc}" >> ${tmp}
3293 # TODO instead of using sh+tr+awk+printf, use awk, drop option_doc_of, inc here
3295 #${awk} -v opts="${OPTIONS_DETECT} ${OPTIONS} ${OPTIONS_XTRA}" \
3296 # -v xopts="${XOPTIONS_DETECT} ${XOPTIONS} ${XOPTIONS_XTRA}" \
3297 printf '"\n' >> ${h}
3299 # Create the real mk-config.mk
3300 # Note we cannout use explicit ./ filename prefix for source and object
3301 # pathnames because of a bug in bmake(1)
3303 if feat_no AMALGAMATION
; then
3304 for i
in `printf '%s\n' "${SRCDIR}"*.c | ${sort}`; do
3305 i
=`basename "${i}" .c`
3306 if [ "${i}" = privsep
]; then
3309 objlist
="${objlist} ${i}.o"
3310 srclist
="${srclist} \$(SRCDIR)${i}.c"
3311 printf '%s: %s\n\t$(ECHO_CC)$(CC) $(CFLAGS) $(INCS) -c %s\n' \
3312 "${i}.o" "\$(SRCDIR)${i}.c" "\$(SRCDIR)${i}.c" >> ${mk}
3314 printf '\nAMALGAM_TARGET =\nAMALGAM_DEP =\n' >> ${mk}
3316 printf '%s:\n\t$(ECHO_CC)$(CC) $(CFLAGS) $(INCS) -c $(SRCDIR)%s\n' \
3317 "main.o
" "main.c
" >> ${mk}
3318 srclist=main.c objlist=main.o
3319 printf '\nAMALGAM_TARGET = main.o\nAMALGAM_DEP = ' >> ${mk}
3321 printf '\n/* HAVE_AMALGAMATION: include sources */\n' >> ${h}
3322 printf '#elif n_MK_CONFIG_H + 0 == 1\n' >> ${h}
3323 printf '# undef n_MK_CONFIG_H\n' >> ${h}
3324 printf '# define n_MK_CONFIG_H 2\n' >> ${h}
3325 for i in `printf '%s\n' "${SRCDIR}"*.c | ${sort}`; do
3327 if [ "${i}" = main.c ] ||
3328 [ "${i}" = privsep.c ]; then
3331 printf '$(SRCDIR)%s ' "${i}" >> ${mk}
3332 printf '# include "%s
%s
"\n' "${SRCDIR}" "${i}" >> ${h}
3336 printf 'OBJ_SRC = %s\nOBJ = %s\n' "${srclist}" "${objlist}" >> "${mk}"
3338 printf '#endif /* n_MK_CONFIG_H */\n' >> ${h}
3341 ${cat} "${SRCDIR}"make-config.in >> ${mk}
3345 # We have completed the new configuration header. Check whether *really*
3346 # Do the "second stage configuration changed" detection, exit if nothing to do
3347 if [ -f ${oldh} ]; then
3348 if ${cmp} ${h} ${oldh} >/dev
/null
2>&1; then
3349 ${mv} -f ${oldh} ${h}
3350 msg
'Effective configuration is up-to-date'
3355 msg
'Effective configuration has been updated..'
3358 if [ -n "${config_updated}" ]; then
3359 msg
'Wiping away old objects and such..'
3360 ( cd .obj
; oldmk
=`${basename} ${oldmk}`; ${MAKE} -f ${oldmk} clean )
3364 while read l; do msg "${l}"; done < ${tmp}
3367 msg ' . System-wide resource file: %s/%s' "${VAL_SYSCONFDIR}" "${VAL_SYSCONFRC}"
3368 msg ' . bindir: %s' "${VAL_BINDIR}"
3369 if feat_yes DOTLOCK; then
3370 msg ' . libexecdir: %s' "${VAL_LIBEXECDIR}"
3372 msg ' . mandir: %s' "${VAL_MANDIR}"
3373 msg ' . M(ail)T(ransfer)A(gent): %s (argv0: %s)' "${VAL_MTA}" "${VAL_MTA_ARGV0}"
3374 msg ' . $MAIL spool directory: %s' "${VAL_MAIL}"
3377 if [ -n "${have_fnmatch}" ] && [ -n "${have_fchdir}" ]; then
3381 if [ -z "${have_fnmatch}" ]; then
3382 msg ' . The function fnmatch(3) could not be found.'
3383 msg ' Filename patterns like wildcard are not supported on your system'
3385 if [ -z "${have_fchdir}" ]; then
3386 msg ' . The function fchdir(2) could not be found.'
3387 msg ' We will use chdir(2) instead.'
3388 msg ' This is a problem only if the current working directory is changed'
3389 msg ' while this program is inside of it'