2 #@ Please see INSTALL and make.rc instead.
7 # The feature set, to be kept in sync with make.rc
8 # If no documentation given, the option is used as such; if doc is a hyphen,
9 # entry is suppressed when configuration overview is printed, and also in the
10 # *features* string: most likely for obsolete features etc.
12 ICONV='Character set conversion using iconv(3)' \
13 SOCKETS='Network support' \
14 SSL='SSL/TLS (OpenSSL / LibreSSL)' \
15 SSL_ALL_ALGORITHMS='Support of all digest and cipher algorithms' \
16 SMTP='Simple Mail Transfer Protocol client' \
17 POP3='Post Office Protocol Version 3 client' \
18 IMAP='IMAP v4r1 client' \
19 GSSAPI='Generic Security Service authentication' \
20 NETRC='.netrc file support' \
22 MD5='MD5 message digest (APOP, CRAM-MD5)' \
23 IDNA='Internationalized Domain Names for Applications (encode only)' \
24 IMAP_SEARCH='IMAP-style search expressions' \
25 REGEX='Regular expressions' \
26 MLE='Mailx Line Editor' \
27 HISTORY='Line editor history management' \
28 KEY_BINDINGS='Configurable key bindings' \
29 TERMCAP='Terminal capability queries (termcap(5))' \
30 TERMCAP_VIA_TERMINFO='Terminal capability queries use terminfo(5)' \
31 ERRORS='Error log message ring' \
32 SPAM_SPAMC='Spam management via spamc(1) of spamassassin(1)' \
34 SPAM_FILTER='Freely configurable *spam-filter-..*s' \
35 DOCSTRINGS='Command documentation help strings' \
36 QUOTE_FOLD='Extended *quote-fold*ing' \
37 FILTER_HTML_TAGSOUP='Simple built-in HTML-to-text display filter' \
38 COLOUR='Coloured message display' \
39 DOTLOCK='Dotlock files and privilege-separated dotlock program' \
42 # Options which are automatically deduced from host environment, i.e., these
43 # need special treatment all around here to warp from/to OPT_ stuff
44 # setlocale, C90AMEND1, NL_LANGINFO, wcwidth
46 LOCALES='Locale support - printable characters etc. depend on environment' \
47 MULTIBYTE_CHARSETS='Multibyte character sets' \
48 TERMINAL_CHARSET='Automatic detection of terminal character set' \
49 WIDE_GLYPHS='Wide glyph support' \
52 # Rather special options, for custom building, or which always exist.
53 # Mostly for generating the visual overview and the *features* string
55 MIME='Multipurpose Internet Mail Extensions' \
56 SMIME='S/MIME message signing, verification, en- and decryption' \
57 CROSS_BUILD='Cross-compilation: trust any detected environment' \
58 DEBUG='Debug enabled binary, not for end-users: THANKS!' \
59 DEVEL='Computers do not blunder' \
62 # The problem is that we don't have any tools we can use right now, so
63 # encapsulate stuff in functions which get called in right order later on
85 option_parse OPTIONS_DETECT
"${XOPTIONS_DETECT}"
86 option_parse OPTIONS
"${XOPTIONS}"
87 option_parse OPTIONS_XTRA
"${XOPTIONS_XTRA}"
90 # Predefined CONFIG= urations take precedence over anything else
91 if [ -n "${CONFIG}" ]; then
100 [mM
][iI
][nN
][iI
][mM
][aA
][lL
])
106 [mM
][eE
][dD
][iI
][uU
][mM
])
112 OPT_HISTORY
=1 OPT_KEY_BINDINGS
=1
119 [nN
][eE
][tT
][sS
][eE
][nN
][dD
])
125 OPT_GSSAPI
=1 OPT_NETRC
=1 OPT_AGENT
=1
129 OPT_HISTORY
=1 OPT_KEY_BINDINGS
=1
134 [mM
][aA
][xX
][iI
][mM
][aA
][lL
])
138 [dD
][eE
][vV
][eE
][lL
])
139 OPT_DEVEL
=1 OPT_DEBUG
=1 OPT_NYD2
=1
142 [oO
][dD
][eE
][vV
][eE
][lL
])
147 echo >&2 "Unknown CONFIG= setting: ${CONFIG}"
148 echo >&2 ' NULL, NULLI, MINIMAL, MEDIUM, NETSEND, MAXIMAL'
152 msg_nonl
"CONFIG=${CONFIG} ... "
156 # Inter-relationships
158 if feat_no SMTP
&& feat_no POP3
&& feat_no IMAP
; then
161 if feat_no SOCKETS
; then
162 if feat_require SMTP
; then
163 msg
'ERROR: need SOCKETS for required feature SMTP'
166 if feat_require POP3
; then
167 msg
'ERROR: need SOCKETS for required feature POP3'
170 if feat_require IMAP
; then
171 msg
'ERROR: need SOCKETS for required feature IMAP'
174 OPT_SSL
=0 OPT_SSL_ALL_ALGORITHMS
=0
175 OPT_SMTP
=0 OPT_POP3
=0 OPT_IMAP
=0
176 OPT_GSSAPI
=0 OPT_NETRC
=0 OPT_AGENT
=0
178 if feat_no SMTP
&& feat_no IMAP
; then
182 if feat_no ICONV
; then
183 if feat_yes IMAP
; then
184 if feat_require IMAP
; then
185 msg
'ERROR: need ICONV for required feature IMAP'
188 msg
'ERROR: disabling IMAP due to missing ICONV'
192 if feat_yes IDNA
; then
193 if feat_require IDNA
; then
194 msg
'ERROR: need ICONV for required feature IDNA'
197 msg
'ERROR: disabling IDNA due to missing ICONV'
203 OPT_HISTORY
=0 OPT_KEY_BINDINGS
=0
206 # If we don't need MD5 leave it alone
207 if feat_no SOCKETS
; then
211 if feat_no TERMCAP
; then
212 OPT_TERMCAP_VIA_TERMINFO
=0
215 if feat_yes DEVEL
; then
223 h
=.
/mk-config.h h_name
=mk-config.h
226 newlst
=.
/mk-nconfig.lst
227 newmk
=.
/mk-nconfig.mk
228 newev
=.
/mk-nconfig.ev
234 ## -- >8 - << OPTIONS | OS/CC >> - 8< -- ##
236 # Note that potential duplicates in PATH, C_INCLUDE_PATH etc. will be cleaned
237 # via path_check() later on once possible
239 # TODO cc_maxopt is brute simple, we should compile test program and dig real
240 # compiler versions for known compilers, then be more specific
245 # We don't "have any utility": only path adjustments and such in here!
246 i
="${OS:-`uname -s`}"
248 if [ ${i} = SunOS
]; then
249 msg
'SunOS / Solaris? Applying some "early setup" rules ...'
250 _os_early_setup_sunos
254 _os_early_setup_sunos
() {
255 # According to standards(5), this is what we need to do
256 if [ -d /usr
/xpg4
]; then :; else
257 msg
'ERROR: On SunOS / Solaris we need /usr/xpg4 environment! Sorry.'
260 PATH
="/usr/xpg4/bin:/usr/ccs/bin:/usr/bin:${PATH}"
261 [ -d /usr
/xpg6
] && PATH
="/usr/xpg6/bin:${PATH}"
266 # OSENV ends up in *build-osenv*
267 # OSFULLSPEC is used to recognize changes (i.e., machine type, updates etc.)
268 : ${OS:=`uname -s | ${tr} '[A-Z]' '[a-z]'`}
269 : ${OSENV:=`uname -srm`}
270 : ${OSFULLSPEC:=`uname -a`}
271 msg
'Operating system is %s' ${OS}
273 if [ ${OS} = sunos
]; then
274 msg
' . have special SunOS / Solaris "setup" rules ...'
276 elif [ ${OS} = unixware
]; then
277 msg
' . have special UnixWare environmental rules ...'
278 if feat_yes AUTOCC
&& command -v cc
>/dev
/null
2>&1; then
280 feat_yes DEBUG
&& _CFLAGS
='-v -Xa -g' || _CFLAGS
='-Xa -O'
282 CFLAGS
="${_CFLAGS} ${EXTRA_CFLAGS}"
283 LDFLAGS
="${_LDFLAGS} ${EXTRA_LDFLAGS}"
284 export CC CFLAGS LDFLAGS
285 OPT_AUTOCC
=0 had_want_autocc
=1 need_R_ldflags
=-R
287 elif [ -n "${VERBOSE}" ]; then
288 msg
' . no special treatment for this system necessary or known'
291 # Sledgehammer: better set _GNU_SOURCE
292 # And in general: oh, boy!
293 OS_DEFINES
="${OS_DEFINES}#define _GNU_SOURCE\n"
294 #OS_DEFINES="${OS_DEFINES}#define _POSIX_C_SOURCE 200809L\n"
295 #OS_DEFINES="${OS_DEFINES}#define _XOPEN_SOURCE 700\n"
296 #[ ${OS} = darwin ] && OS_DEFINES="${OS_DEFINES}#define _DARWIN_C_SOURCE\n"
298 # On pkgsrc(7) systems automatically add /usr/pkg/*
299 if [ -d /usr
/pkg
]; then
300 C_INCLUDE_PATH
="${C_INCLUDE_PATH}:/usr/pkg/include"
301 LD_LIBRARY_PATH
="${LD_LIBRARY_PATH}:/usr/pkg/lib"
306 C_INCLUDE_PATH
="/usr/xpg4/include:${C_INCLUDE_PATH}"
307 LD_LIBRARY_PATH
="/usr/xpg4/lib:${LD_LIBRARY_PATH}"
310 if [ -d /opt
/csw
]; then
311 C_INCLUDE_PATH
="${C_INCLUDE_PATH}:/opt/csw/include"
312 LD_LIBRARY_PATH
="${LD_LIBRARY_PATH}:/opt/csw/lib"
315 OS_DEFINES
="${OS_DEFINES}#define __EXTENSIONS__\n"
316 #OS_DEFINES="${OS_DEFINES}#define _POSIX_C_SOURCE 200112L\n"
318 [ -n "${cksum}" ] ||
cksum=/opt
/csw
/gnu
/cksum
319 if [ -x "${cksum}" ]; then :; else
320 msg
'ERROR: Not an executable program: %s' "${cksum}"
321 msg
'ERROR: We need a CRC-32 cksum(1), as specified in POSIX.'
322 msg
'ERROR: However, we do so only for tests.'
323 msg
'ERROR: If that is ok, set "cksum=/usr/bin/true", then rerun'
327 if feat_yes AUTOCC
; then
328 if command -v cc
>/dev
/null
2>&1; then
330 feat_yes DEBUG
&& _CFLAGS
="-v -Xa -g" || _CFLAGS
="-Xa -O"
332 CFLAGS
="${_CFLAGS} ${EXTRA_CFLAGS}"
333 LDFLAGS
="${_LDFLAGS} ${EXTRA_LDFLAGS}"
334 export CC CFLAGS LDFLAGS
335 OPT_AUTOCC
=0 had_want_autocc
=1 need_R_ldflags
=-R
337 # Assume gcc(1), which supports -R for compat
338 cc_maxopt
=2 force_no_stackprot
=1 need_R_ldflags
=-Wl,-R
343 # Check out compiler ($CC) and -flags ($CFLAGS)
345 # Even though it belongs into cc_flags we will try to compile and link
346 # something, so ensure we have a clean state regarding CFLAGS/LDFLAGS or
347 # EXTRA_CFLAGS/EXTRA_LDFLAGS
348 if feat_no AUTOCC
; then
350 # Ensure those don't do any harm
351 EXTRA_CFLAGS
= EXTRA_LDFLAGS
=
352 export EXTRA_CFLAGS EXTRA_LDFLAGS
356 export CFLAGS LDFLAGS
359 [ -n "${CC}" ] && [ "${CC}" != cc ] && { _cc_default; return; }
361 msg_nonl 'Searching for a usable C compiler .. $CC='
362 if { i="`command -v clang`"; }; then
364 elif { i="`command -v gcc`"; }; then
366 elif { i="`command -v c99`"; }; then
368 elif { i="`command -v tcc`"; }; then
370 elif { i="`command -v pcc`"; }; then
373 if [ "${CC}" = cc ]; then
375 elif { i="`command -v c89`"; }; then
378 msg 'boing booom tschak'
379 msg 'ERROR: I cannot find a compiler!'
380 msg ' Neither of clang(1), gcc(1), tcc(1), pcc(1), c89(1) and c99(1).'
381 msg ' Please set ${CC} environment variable, maybe ${CFLAGS}, rerun.'
390 if [ -z "${CC}" ]; then
391 msg 'To go on like you have chosen, please set $CC, rerun.'
395 if [ -z "${VERBOSE}" ] && [ -f ${lst} ] && feat_no DEBUG; then
398 msg 'Using C compiler ${CC}=%s' "${CC}"
403 if feat_yes AUTOCC; then
404 if [ -f ${lst} ] && feat_no DEBUG && [ -z "${VERBOSE}" ]; then
406 msg 'Detecting ${CFLAGS}/${LDFLAGS} for ${CC}=%s, just a second..' \
410 msg 'Testing usable ${CFLAGS}/${LDFLAGS} for ${CC}=%s' "${CC}"
413 i
=`echo "${CC}" | ${awk} 'BEGIN{FS="/"}{print $NF}'`
414 if { echo "${i}" | ${grep} tcc; } >/dev/null 2>&1; then
415 msg ' . have special tcc(1) environmental rules ...'
418 # As of pcc CVS 2016-04-02, stack protection support is announced but
419 # will break if used on Linux
420 if { echo "${i}" | ${grep} pcc; } >/dev
/null
2>&1; then
426 feat_no DEBUG
&& _CFLAGS
="-DNDEBUG ${_CFLAGS}"
427 CFLAGS
="${_CFLAGS} ${EXTRA_CFLAGS}"
428 LDFLAGS
="${_LDFLAGS} ${EXTRA_LDFLAGS}"
430 if feat_no DEBUG
; then
431 CFLAGS
="-DNDEBUG ${CFLAGS}"
435 export CFLAGS LDFLAGS
439 __cflags
=${_CFLAGS} __ldflags
=${_LDFLAGS}
446 if feat_yes DEBUG
; then
447 # May have problems to find libtcc cc_check -b
451 if ld_check
-Wl,-rpath =.
/ no
; then
452 need_R_ldflags
=-Wl,-rpath=
453 ld_check
-Wl,--enable-new-dtags
454 ld_runtime_flags
# update!
457 _CFLAGS
="${_CFLAGS} ${__cflags}" _LDFLAGS="${_LDFLAGS} ${__ldflags}"
458 unset __cflags __ldflags
461 _cc_flags_generic
() {
462 __cflags
=${_CFLAGS} __ldflags
=${_LDFLAGS}
464 feat_yes DEVEL
&& cc_check
-std=c89 || cc_check
-std=c99
466 # Check -g first since some others may rely upon -g / optim. level
467 if feat_yes DEBUG
; then
470 elif [ ${cc_maxopt} -gt 2 ] && cc_check
-O3; then
472 elif [ ${cc_maxopt} -gt 1 ] && cc_check
-O2; then
474 elif [ ${cc_maxopt} -gt 0 ] && cc_check
-O1; then
480 if feat_yes AMALGAMATION
; then
484 #if feat_yes DEVEL && cc_check -Weverything; then
489 cc_check
-Wbad-function-cast
490 cc_check
-Wcast-align
493 cc_check
-Wmissing-prototypes
496 cc_check
-Wwrite-strings
497 cc_check
-Wno-long-long
501 if feat_yes AMALGAMATION
&& feat_no DEVEL
; then
502 cc_check
-Wno-unused-function
504 feat_no DEVEL
&& cc_check
-Wno-unused-result # XXX do right way (pragma too)
506 cc_check
-fno-unwind-tables
507 cc_check
-fno-asynchronous-unwind-tables
508 cc_check
-fstrict-aliasing
509 if cc_check
-fstrict-overflow && feat_yes DEVEL
; then
510 cc_check
-Wstrict-overflow=5
513 if feat_yes DEBUG || feat_yes FORCED_STACKPROT
; then
514 if [ -z "${force_no_stackprot}" ]; then
515 if cc_check
-fstack-protector-strong ||
516 cc_check
-fstack-protector-all; then
517 cc_check
-D_FORTIFY_SOURCE=2
520 msg
'Not checking for -fstack-protector compiler option,'
521 msg
'since that caused errors in a "similar" configuration.'
522 msg
'You may turn off OPT_AUTOCC and use your own settings, rerun'
526 # LD (+ dependend CC)
528 if feat_yes ASAN_ADDRESS
; then
530 if cc_check
-fsanitize=address
&&
531 ld_check
-fsanitize=address
; then
534 feat_bail_required ASAN_ADDRESS
539 if feat_yes ASAN_MEMORY
; then
541 if cc_check
-fsanitize=memory
&&
542 ld_check
-fsanitize=memory
&&
543 cc_check
-fsanitize-memory-track-origins=2 &&
544 ld_check
-fsanitize-memory-track-origins=2; then
547 feat_bail_required ASAN_MEMORY
552 ld_check
-Wl,-z,relro
554 ld_check
-Wl,-z,noexecstack
555 if ld_check
-Wl,-rpath =.
/ no
; then
556 need_R_ldflags
=-Wl,-rpath=
557 # Choose DT_RUNPATH (after $LD_LIBRARY_PATH) over DT_RPATH (before)
558 ld_check
-Wl,--enable-new-dtags
559 ld_runtime_flags
# update!
560 elif ld_check
-Wl,-R .
/ no
; then
561 need_R_ldflags
=-Wl,-R
562 ld_check
-Wl,--enable-new-dtags
563 ld_runtime_flags
# update!
566 # Address randomization
568 if cc_check
-fPIE || cc_check
-fpie; then
569 ld_check
-pie || _CFLAGS
=${_ccfg}
573 _CFLAGS
="${_CFLAGS} ${__cflags}" _LDFLAGS="${_LDFLAGS} ${__ldflags}"
574 unset __cflags __ldflags
577 ## -- >8 - <<OS/CC | SUPPORT FUNS>> - 8< -- ##
580 ## - Heirloom sh(1) (and same origin) have _sometimes_ problems with ': >'
581 ## redirection, so use "printf '' >" instead
583 ## Very first: we undergo several states regarding I/O redirection etc.,
584 ## but need to deal with option updates from within all. Since all the
585 ## option stuff should be above the scissor line, define utility functions
586 ## and redefine them as necessary.
587 ## And, since we have those functions, simply use them for whatever
596 printf >&2 -- "${fmt}\\n" "${@}"
602 printf >&2 -- "${fmt}" "${@}"
605 t1
=ten10one1ten10one1
606 if ( [ ${t1##*ten10} = one1
] && [ ${t1#*ten10} = one1ten10one1
] &&
607 [ ${t1%%one1*} = ten10
] && [ ${t1%one1*} = ten10one1ten10
]
608 ) > /dev
/null
2>&1; then
615 # We need some standard utilities
618 n
=${1} i=${2} opt=${3:-0}
619 # Evaluate, just in case user comes in with shell snippets (..well..)
621 if type "${i}" >/dev
/null
2>&1; then # XXX why have i type not command -v?
622 [ -n "${VERBOSE}" ] && msg ' . ${%s} ... %s' "${n}" "${i}"
626 if [ ${opt} -eq 0 ]; then
627 msg
'ERROR: no trace of utility %s' "${n}"
633 # Our feature check environment
635 [ "x${1}" = x0
] ||
[ "x${1}" = xn
] ||
636 [ "x${1}" = xfalse ] || [ "x${1}" = xno ] || [ "x${1}" = xoff
]
640 [ "x${1}" = x1
] ||
[ "x${1}" = xy
] ||
641 [ "x${1}" = xtrue ] || [ "x${1}" = xyes ] || [ "x${1}" = xon
] ||
642 [ "x${1}" = xrequire
]
646 [ "x${1}" = xrequire
]
651 i
="`echo ${i} | ${tr} '[A-Z]' '[a-z]'`"
652 if feat_val_no
"${i}"; then
654 elif feat_val_yes
"${i}"; then
657 msg
"ERROR: %s: 0/n/false/no/off or 1/y/true/yes/on/require, got: %s" \
668 _feat_check
${1} && return 1
674 i
="`echo ${i} | ${tr} '[A-Z]' '[a-z]'`"
675 [ "x${i}" = xrequire
] ||
[ "x${i}" = xrequired
]
678 feat_bail_required
() {
679 if feat_require
${1}; then
680 msg
'ERROR: feature OPT_%s is required but not available' "${1}"
684 option_update
# XXX this is rather useless here (dependency chain..)
688 # Parse one of our XOPTIONS* in $2 and assign the sh(1) compatible list of
689 # options, without documentation, to $1
691 i
="`${awk} -v input=\"${2}\" '
694 voff = match(input, /[[:alnum:]_]+(='${j}'[^'${j}']+)?/)
697 v = substr(input, voff, RLENGTH)
698 input = substr(input, voff + RLENGTH)
701 d = substr(v, doff + 2, length(v) - doff - 1)
702 v = substr(v, 1, doff - 1)
712 # Return the "documentation string" for option $1, itself if none such
714 ${awk} -v want
="${1}" \
715 -v input
="${XOPTIONS_DETECT}${XOPTIONS}${XOPTIONS_XTRA}" '
718 voff = match(input, /[[:alnum:]_]+(='${j}'[^'${j}']+)?/)
721 v = substr(input, voff, RLENGTH)
722 input = substr(input, voff + RLENGTH)
725 d = substr(v, doff + 2, length(v) - doff - 1)
726 v = substr(v, 1, doff - 1)
740 # Join the values from make.rc into what currently is defined, not
741 # overwriting yet existing settings
743 # We want read(1) to perform reverse solidus escaping in order to be able to
744 # use multiline values in make.rc; the resulting sh(1)/sed(1) code was very
745 # slow in VMs (see [fa2e248]), Aharon Robbins suggested the following
746 < ${rc} ${awk} 'BEGIN{line = ""}{
747 gsub
(/^
[[:space
:]]+/, "", $0)
748 gsub
(/[[:space
:]]+$
/, "", $0)
749 if(gsub
(/\\$
/, "", $0)){
754 if(index
(line
, "#") == 1){
756 }else if(length
(line
)){
762 if [ -n "${good_shell}" ]; then
765 i=`${awk} -v LINE="${line}" 'BEGIN
{
766 gsub
(/=.
*$
/, "", LINE
)
770 if [ "${i}" = "${line}" ]; then
771 msg 'ERROR
: invalid syntax
in: %s
' "${line}"
775 eval j="\$${i}" jx="\${${i}+x}"
776 if [ -n "${j}" ] || [ "${jx}" = x ]; then
779 j=`${awk} -v LINE="${line}" 'BEGIN
{
780 gsub
(/^
[^
=]*=/, "", LINE
)
781 gsub
(/^
\"*/, "", LINE
)
782 gsub
(/\"*$
/, "", LINE
)
786 [ "${i}" = "DESTDIR" ] && continue
789 # Reread the mixed version right now
794 # Expand the option values, which may contain shell snippets
795 ${rm} -f ${newlst} ${newmk} ${newh}
796 exec 5<&0 6>&1 <${tmp} >${newlst}
799 if [ -n "${good_shell}" ]; then
801 [ "${i}" != "${i#OPT_}" ] && z=1
803 i=`${awk} -v LINE="${line}" 'BEGIN
{
804 gsub
(/=.
*$
/, "", LINE
);\
807 if echo "${i}" | ${grep} '^OPT_
' >/dev/null 2>&1; then
813 if [ -n "${z}" ]; then
814 j="`echo ${j} | ${tr} '[A-Z
]' '[a-z
]'`"
815 if [ -z "${j}" ] || feat_val_no "${j}"; then
817 printf " /* #undef ${i} */\n" >> ${newh}
818 elif feat_val_yes "${j}"; then
819 if feat_val_require "${j}"; then
824 printf " /* #define ${i} */\n" >> ${newh}
826 msg 'ERROR
: cannot parse
<%s
>' "${line}"
830 printf "#define ${i} \"${j}\"\n" >> ${newh}
832 printf "${i} = ${j}\n" >> ${newmk}
836 exec 0<&5 1>&6 5<&- 6<&-
840 # "path_check VARNAME" or "path_check VARNAME FLAG VARNAME"
841 varname=${1} addflag=${2} flagvarname=${3}
849 [ -z "${i}" ] && continue
850 [ -d "${i}" ] || continue
851 # Skip any fakeroot packager environment
852 case "${i}" in *fakeroot*) continue;; esac
853 if [ -n "${j}" ]; then
854 if { z=${y}; echo "${z}"; } | ${grep} ":${i}:" >/dev/null 2>&1; then
859 [ -n "${addflag}" ] && k="${k} ${addflag}${i}"
864 [ -n "${addflag}" ] && k="${addflag}${i}"
867 eval "${varname}=\"${j}\""
868 [ -n "${addflag}" ] && eval "${flagvarname}=\"${k}\""
873 if [ -n "${need_R_ldflags}" ]; then
876 set -- ${LD_LIBRARY_PATH}
880 LDFLAGS="${LDFLAGS} ${need_R_ldflags}${i}"
881 _LDFLAGS="${_LDFLAGS} ${need_R_ldflags}${i}"
885 # Disable it for a possible second run.
890 [ -n "${cc_check_silent}" ] || msg_nonl ' . CC
%s ..
' "${1}"
892 ${_CFLAGS} ${1} ${EXTRA_CFLAGS} ${_LDFLAGS} ${EXTRA_LDFLAGS} \
893 -o ${tmp2} ${tmp}.c ${LIBS} >/dev/null 2>&1; then
894 _CFLAGS="${_CFLAGS} ${1}"
895 [ -n "${cc_check_silent}" ] || msg 'yes'
898 [ -n "${cc_check_silent}" ] || msg 'no
'
903 # $1=option [$2=option argument] [$3=if set, shall NOT be added to _LDFLAGS]
904 [ -n "${cc_check_silent}" ] || msg_nonl ' . LD
%s ..
' "${1}"
905 if "${CC}" ${INCS} ${_CFLAGS} ${_LDFLAGS} ${1}${2} ${EXTRA_LDFLAGS} \
906 -o ${tmp2} ${tmp}.c ${LIBS} >/dev/null 2>&1; then
907 [ -n "${3}" ] || _LDFLAGS="${_LDFLAGS} ${1}"
908 [ -n "${cc_check_silent}" ] || msg 'yes'
911 [ -n "${cc_check_silent}" ] || msg 'no
'
916 variable=$1 topic=$2 define=$3
919 msg_nonl ' .
%s ...
' "${topic}"
920 echo "/* checked ${topic} */" >> ${h}
921 ${rm} -f ${tmp} ${tmp}.o
922 echo '*** test program is
'
923 { echo '#include <'"${h_name}"'>'; cat; } | ${tee} ${tmp}.c
924 #echo '*** the preprocessor generates'
925 #${make} -f ${makefile} ${tmp}.x
927 echo '*** results are'
931 yesno
=$1 variable
=$2 topic
=$3 define
=$4 libs
=$5 incs
=$6
934 msg_nonl
' . %s ... ' "${topic}"
936 echo '*** enforced unchecked results are'
937 if feat_val_yes
${yesno}; then
938 if [ -n "${incs}" ] ||
[ -n "${libs}" ]; then
939 echo "*** adding INCS<${incs}> LIBS<${libs}>"
940 LIBS
="${LIBS} ${libs}"
941 echo "${libs}" >> ${lib}
942 INCS
="${INCS} ${incs}"
943 echo "${incs}" >> ${inc}
946 echo "${define}" >> ${h}
947 eval have_
${variable}=yes
950 echo "/* ${define} */" >> ${h}
952 eval unset have_
${variable}
958 variable
=$1 topic
=$2 define
=$3
960 _check_preface
"${variable}" "${topic}" "${define}"
962 if ${make} -f ${makefile} XINCS="${INCS}" \
963 CFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}" \
965 [ -f ./${tmp}.o ]; then
967 echo "${define}" >> ${h}
968 eval have_${variable}=yes
971 echo "/* ${define} */" >> ${h}
973 eval unset have_${variable}
979 run=$1 variable=$2 topic=$3 define=$4 libs=$5 incs=$6
981 _check_preface "${variable}" "${topic}" "${define}"
983 if feat_yes CROSS_BUILD; then
984 if [ ${run} = 1 ]; then
989 if ${make} -f ${makefile} XINCS="${INCS} ${incs}" \
990 CFLAGS
="${CFLAGS}" LDFLAGS
="${LDFLAGS}" \
991 XLIBS
="${LIBS} ${libs}" \
994 { [ ${run} -eq 0 ] || ./${tmp}; }; then
995 echo "*** adding INCS<${incs}> LIBS<${libs}>; executed: ${run}"
997 echo "${define}" >> ${h}
998 LIBS
="${LIBS} ${libs}"
999 echo "${libs}" >> ${lib}
1000 INCS
="${INCS} ${incs}"
1001 echo "${incs}" >> ${inc}
1002 eval have_
${variable}=yes
1006 echo "/* ${define} */" >> ${h}
1007 eval unset have_
${variable}
1013 _link_mayrun
0 "${1}" "${2}" "${3}" "${4}" "${5}"
1017 _link_mayrun
1 "${1}" "${2}" "${3}" "${4}" "${5}"
1021 _link_mayrun
2 "${1}" "${2}" "${3}" "${4}" "${5}"
1025 if feat_yes
${1}; then
1026 echo '#define HAVE_'${1}'' >> ${h}
1029 echo '/* OPT_'${1}'=0 */' >> ${h}
1035 < "${1}" > "${2}" ${awk} \
1036 'BEGIN {ORS = " "} /^[^#]/ {print} {next} END {ORS = ""; print "\n"}'
1039 ## -- >8 - <<SUPPORT FUNS | RUNNING>> - 8< -- ##
1041 # First of all, create new configuration and check whether it changed
1043 # Very easy checks for the operating system in order to be able to adjust paths
1044 # or similar very basic things which we need to be able to go at all
1047 # Check those tools right now that we need before including $rc
1048 msg 'Checking for basic utility set'
1049 check_tool awk "${awk:-`command -v awk`}"
1050 check_tool rm "${rm:-`command -v rm`}"
1051 check_tool tr "${tr:-`command -v tr`}"
1053 # Initialize the option set
1054 msg_nonl 'Setting up configuration options ... '
1058 # Include $rc, but only take from it what wasn't overwritten by the user from
1059 # within the command line or from a chosen fixed CONFIG=
1060 # Note we leave alone the values
1061 trap "exit 1" HUP INT TERM
1062 trap "${rm} -f ${tmp}" EXIT
1064 msg_nonl 'Joining in %s ... ' ${rc}
1068 # We need to know about that now, in order to provide utility overwrites etc.
1071 msg 'Checking for remaining set of utilities'
1072 check_tool grep "${grep:-`command -v grep`}"
1074 # Before we step ahead with the other utilities perform a path cleanup first.
1078 check_tool cat "${cat:-`command -v cat`}"
1079 check_tool chmod "${chmod:-`command -v chmod`}"
1080 check_tool cp "${cp:-`command -v cp`}"
1081 check_tool cmp "${cmp:-`command -v cmp`}"
1083 check_tool mkdir "${mkdir:-`command -v mkdir`}"
1084 check_tool mv "${mv:-`command -v mv`}"
1086 check_tool sed "${sed:-`command -v sed`}"
1087 check_tool sort "${sort:-`command -v sort`}"
1088 check_tool tee "${tee:-`command -v tee`}"
1090 check_tool chown "${chown:-`command -v chown`}" 1 ||
1091 check_tool chown "/sbin
/chown
" 1 ||
1092 check_tool chown "/usr
/sbin
/chown
"
1094 check_tool make "${MAKE:-`command -v make`}"
1096 check_tool strip "${STRIP:-`command -v strip`}" 1 &&
1097 HAVE_STRIP=1 || HAVE_STRIP=0
1099 # For ./cc-test.sh only
1100 check_tool cksum "${cksum:-`command -v cksum`}"
1102 # Update OPT_ options now, in order to get possible inter-dependencies right
1105 # (No functions since some shells loose non-exported variables in traps)
1106 trap "trap \"\" HUP INT TERM
; exit 1" HUP INT TERM
1107 trap "trap \"\" HUP INT TERM EXIT
;\
1108 ${rm} -rf ${newlst} ${tmp0}.* ${tmp0}* ${newmk} ${newev} ${newh}" EXIT
1110 # Our configuration options may at this point still contain shell snippets,
1111 # we need to evaluate them in order to get them expanded, and we need those
1112 # evaluated values not only in our new configuration file, but also at hand..
1113 msg_nonl 'Evaluating all configuration items ... '
1117 # Add the known utility and some other variables
1118 printf "#define VAL_UAGENT \"${VAL_SID}${VAL_MAILX}\"\n" >> ${newh}
1119 printf "VAL_UAGENT = ${VAL_SID}${VAL_MAILX}\n" >> ${newmk}
1121 printf "#define VAL_PRIVSEP \"${VAL_SID}${VAL_MAILX}-privsep\"\n" >> ${newh}
1122 printf "VAL_PRIVSEP = \$(VAL_UAGENT)-privsep\n" >> ${newmk}
1123 if feat_yes DOTLOCK
; then
1124 printf "OPTIONAL_PRIVSEP = \$(VAL_PRIVSEP)\n" >> ${newmk}
1126 printf "OPTIONAL_PRIVSEP =\n" >> ${newmk}
1130 awk cat chmod chown
cp cmp grep mkdir
mv rm sed sort tee tr \
1131 MAKE MAKEFLAGS
make SHELL strip \
1134 printf "${i} = ${j}\n" >> ${newmk}
1135 printf "${i}=${j}\n" >> ${newlst}
1136 printf "${i}=\"${j}\";export ${i}; " >> ${newev}
1138 printf "\n" >> ${newev}
1140 # Build a basic set of INCS and LIBS according to user environment.
1141 path_check C_INCLUDE_PATH -I _INCS
1142 INCS="${INCS} ${_INCS}"
1143 path_check LD_LIBRARY_PATH -L _LIBS
1144 LIBS="${LIBS} ${_LIBS}"
1146 export C_INCLUDE_PATH LD_LIBRARY_PATH
1148 # Some environments need runtime path flags to be able to go at all
1151 ## Detect CC, whether we can use it, and possibly which CFLAGS we can use
1155 ${cat} > ${tmp}.c << \!
1158 static void doit(char const *s);
1160 main(int argc, char **argv){
1163 doit("Hello world
");
1167 doit(char const *s){
1169 memcpy(buf, s, strlen(s) +1);
1174 if "${CC}" ${INCS} ${CFLAGS} ${EXTRA_CFLAGS} ${LDFLAGS} ${EXTRA_LDFLAGS} \
1175 -o ${tmp2} ${tmp}.c ${LIBS}; then
1178 msg
'ERROR: i cannot compile a "Hello world" via'
1180 "${CC} ${INCS} ${CFLAGS} ${EXTRA_CFLAGS} ${LDFLAGS} ${EXTRA_LDFLAGS} ${LIBS}"
1181 msg
'ERROR: Please read INSTALL, rerun'
1185 # This may also update ld_runtime_flags() (again)
1192 printf -- "${i}=${j}\n" >> ${newlst}
1198 PATH C_INCLUDE_PATH LD_LIBRARY_PATH \
1202 printf -- "${i} = ${j}\n" >> ${newmk}
1203 printf -- "${i}=${j}\n" >> ${newlst}
1206 # Now finally check whether we already have a configuration and if so, whether
1207 # all those parameters are still the same.. or something has actually changed
1208 if [ -f ${lst} ] && ${cmp} ${newlst} ${lst} >/dev/null 2>&1; then
1209 echo 'Configuration is up-to-date'
1211 elif [ -f ${lst} ]; then
1212 echo 'Configuration has been updated..'
1213 ( eval "${MAKE} -f .
/mk-config.mk clean
" )
1216 echo 'Shiny configuration..'
1219 # Time to redefine helper 1
1221 ${rm} -f ${lst} ${h} ${mk}
1225 ${mv} -f ${newlst} ${lst}
1226 ${mv} -f ${newev} ${ev}
1227 ${mv} -f ${newh} ${h}
1228 ${mv} -f ${newmk} ${mk}
1230 if [ -z "${VERBOSE}" ]; then
1231 printf -- "ECHO_CC
= @
echo ' 'CC \$
(@
);\n" >> ${mk}
1232 printf -- "ECHO_LINK
= @
echo ' 'LINK \$
(@
);\n" >> ${mk}
1233 printf -- "ECHO_GEN
= @
echo ' 'GEN \$
(@
);\n" >> ${mk}
1234 printf -- "ECHO_TEST
= @
\n" >> ${mk}
1235 printf -- "ECHO_CMD
= @
echo ' CMD';\n" >> ${mk}
1236 printf -- "ECHO_BLOCK_BEGIN
= @
( \n" >> ${mk}
1237 printf -- "ECHO_BLOCK_END
= ) >/dev
/null
\n" >> ${mk}
1240 ## Compile and link checking
1246 makefile=./${tmp0}.mk
1248 # (No function since some shells loose non-exported variables in traps)
1249 trap "trap \"\" HUP INT TERM
;\
1250 ${rm} -f ${lst} ${h} ${mk} ${lib} ${inc}; exit 1" HUP INT TERM
1251 trap "trap \"\" HUP INT TERM EXIT
;\
1252 ${rm} -rf ${tmp0}.* ${tmp0}*" EXIT
1254 # Time to redefine helper 2
1258 printf "*** ${fmt}\\n
" "${@}"
1259 printf -- "${fmt}\\n
" "${@}" >&5
1264 printf "*** ${fmt}\\n
" "${@}"
1265 printf -- "${fmt}" "${@}" >&5
1269 exec 5>&2 > ${log} 2>&1
1271 echo "${LIBS}" > ${lib}
1272 echo "${INCS}" > ${inc}
1273 ${cat} > ${makefile} << \!
1274 .SUFFIXES: .o .c .x .y
1276 $(CC) -I./ $(XINCS) $(CFLAGS) -c $(<)
1278 $(CC) -I./ $(XINCS) -E $(<) > $(@)
1280 $(CC) -I./ $(XINCS) $(CFLAGS) $(LDFLAGS) -o $(@) $(<) $(XLIBS)
1285 # May be multiline..
1287 [ -n "${OS_DEFINES}" ] && printf -- "${OS_DEFINES}" >> ${h}
1288 echo '#define VAL_BUILD_OS "'"${OS}"'"' >> ${h}
1289 echo '#define VAL_BUILD_OSENV "'"${OSENV}"'"' >> ${h}
1291 # Generate n_err_number OS mappings
1293 feat_yes DEVEL
&& NV
= || NV
=noverbose
1294 TARGET
="${h}" awk="${awk}" ./make-errors.sh ${NV} config
1296 xrun_check oserrno 'OS error mapping table generated' || config_exit 1
1298 feat_def ALWAYS_UNICODE_LOCALE
1299 feat_def AMALGAMATION
1300 feat_def CROSS_BUILD
1304 feat_def ASAN_ADDRESS
1305 feat_def ASAN_MEMORY
1311 if xrun_check inline 'inline functions' \
1312 '#define HAVE_INLINE
1313 #define n_INLINE static inline' << \!
1314 static inline int ilf(int i){return ++i;}
1315 int main(void){return ilf(-1);}
1319 elif xrun_check inline 'inline functions (via __inline)' \
1320 '#define HAVE_INLINE
1321 #define n_INLINE static __inline' << \!
1322 static __inline int ilf(int i){return ++i;}
1323 int main(void){return ilf(-1);}
1329 ## Test for "basic
" system-calls / functionality that is used by all parts
1330 ## of our program. Once this is done fork away BASE_LIBS and other BASE_*
1331 ## macros to be used by only the subprograms (potentially).
1333 if run_check clock_gettime 'clock_gettime(2)' \
1334 '#define HAVE_CLOCK_GETTIME' << \!
1340 if(!clock_gettime(CLOCK_REALTIME, &ts) || errno != ENOSYS)
1347 elif run_check clock_gettime 'clock_gettime(2) (via -lrt)' \
1348 '#define HAVE_CLOCK_GETTIME' '-lrt' << \!
1354 if(!clock_gettime(CLOCK_REALTIME, &ts) || errno != ENOSYS)
1361 elif run_check gettimeofday 'gettimeofday(2)' \
1362 '#define HAVE_GETTIMEOFDAY' << \!
1363 #include <stdio.h> /* For C89 NULL */
1364 #include <sys/time.h>
1369 if(!gettimeofday(&tv, NULL) || errno != ENOSYS)
1377 have_no_subsecond_time=1
1380 if run_check nanosleep 'nanosleep(2)' \
1381 '#define HAVE_NANOSLEEP' << \!
1388 ts.tv_nsec = 100000;
1389 if(!nanosleep(&ts, NULL) || errno != ENOSYS)
1396 elif run_check nanosleep 'nanosleep(2) (via -lrt)' \
1397 '#define HAVE_NANOSLEEP' '-lrt' << \!
1404 ts.tv_nsec = 100000;
1405 if(!nanosleep(&ts, NULL) || errno != ENOSYS)
1412 # link_check is enough for this, that function is so old, trust the proto
1413 elif link_check sleep 'sleep(3)' \
1414 '#define HAVE_SLEEP' << \!
1418 if(!sleep(1) || errno != ENOSYS)
1426 msg 'ERROR: we require one of nanosleep(2) and sleep(3).'
1430 if run_check userdb 'gete?[gu]id(2), getpwuid(3), getpwnam(3)' << \!
1439 if((gid = getgid()) != 0)
1441 if((uid = getuid()) != 0)
1443 if((pw = getpwuid(uid)) == NULL && errno == ENOSYS)
1445 if((pw = getpwnam("root
")) == NULL && errno == ENOSYS)
1453 msg 'ERROR: we require user and group info / database searches.'
1454 msg 'That much Unix we indulge ourselfs.'
1458 if link_check ftruncate 'ftruncate(2)' \
1459 '#define HAVE_FTRUNCATE' << \!
1461 #include <sys/types.h>
1463 return (ftruncate(0, 0) != 0);
1469 msg 'ERROR: we require the ftruncate(2) system call.'
1473 if run_check sa_restart 'SA_RESTART (for sigaction(2))' << \!
1477 struct sigaction nact, oact;
1479 nact.sa_handler = SIG_DFL;
1480 sigemptyset(&nact.sa_mask);
1481 nact.sa_flags = SA_RESTART;
1482 return !(!sigaction(SIGCHLD, &nact, &oact) || errno != ENOSYS);
1488 msg 'ERROR: we (yet) require the SA_RESTART flag for sigaction(2).'
1492 if link_check snprintf 'snprintf(3)' << \!
1497 snprintf(b, sizeof b, "%s
", "string
");
1504 msg 'ERROR: we require the snprintf(3) function.'
1508 if link_check environ 'environ(3)' << \!
1509 #include <stdio.h> /* For C89 NULL */
1511 extern char **environ;
1513 return environ[0] == NULL;
1519 msg 'ERROR: we require the environ(3) array for subprocess control.'
1523 if link_check setenv '(un)?setenv(3)' '#define HAVE_SETENV' << \!
1526 setenv("s-mailx
", "i want to see it cute
!", 1);
1527 unsetenv("s-mailx
");
1533 elif link_check setenv 'putenv(3)' '#define HAVE_PUTENV' << \!
1536 putenv("s-mailx
=i want to see it cute
!");
1543 msg 'ERROR: we require either the setenv(3) or putenv(3) functions.'
1547 if link_check termios 'termios.h and tc*(3) family' << \!
1548 #include <termios.h>
1550 struct termios tios;
1552 tcgetattr(0, &tios);
1553 tcsetattr(0, TCSANOW | TCSADRAIN | TCSAFLUSH, &tios);
1560 msg 'ERROR: we require termios.h and the tc*() family of functions.'
1561 msg 'That much Unix we indulge ourselfs.'
1567 if link_check vsnprintf 'vsnprintf(3)' << \!
1570 static void dome(char *buf, size_t blen, ...){
1574 vsnprintf(buf, blen, "%s
", ap);
1580 dome(b, sizeof b, "string
");
1587 feat_bail_required ERRORS
1590 if [ "${have_vsnprintf}" = yes ]; then
1592 link_check va_copy "va_copy
(3) (as
${2})" \
1593 "#define HAVE_N_VA_COPY
1594 #define n_va_copy ${2}" <<_EOT
1598 # if defined __va_copy && !defined va_copy
1599 # define va_copy __va_copy
1602 static void dome2
(char
*buf
, size_t blen
, va_list src
){
1606 vsnprintf
(buf
, blen
, "%s", ap
);
1609 static void dome
(char
*buf
, size_t blen
, ...
){
1613 dome2
(buf
, blen
, ap
);
1619 dome
(b
, sizeof b
, "string");
1624 __va_copy
0 va_copy || __va_copy
1 __va_copy
1627 run_check pathconf
'f?pathconf(2)' '#define HAVE_PATHCONF' << \
!
1634 rv |
= !(pathconf
(".", _PC_NAME_MAX
) >= 0 || errno
== 0 || errno
!= ENOSYS
);
1636 rv |
= !(pathconf
(".", _PC_PATH_MAX
) >= 0 || errno
== 0 || errno
!= ENOSYS
);
1638 /* Only link check
*/
1639 fpathconf
(0, _PC_NAME_MAX
);
1645 run_check pipe2
'pipe2(2)' '#define HAVE_PIPE2' << \
!
1652 if(!pipe2
(fds
, O_CLOEXEC
) || errno
!= ENOSYS
)
1658 # We use this only then for now (need NOW+1)
1659 run_check utimensat
'utimensat(2)' '#define HAVE_UTIMENSAT' << \
!
1660 #include <fcntl.h> /* For AT_* */
1661 #include <sys/stat.h>
1664 struct timespec ts
[2];
1666 ts
[0].tv_nsec
= UTIME_NOW
;
1667 ts
[1].tv_nsec
= UTIME_OMIT
;
1668 if(!utimensat
(AT_FDCWD
, "", ts
, 0) || errno
!= ENOSYS
)
1676 # XXX Add POSIX check once standardized
1677 if link_check posix_random
'arc4random(3)' '#define HAVE_POSIX_RANDOM 0' << \
!
1686 elif link_check getrandom
'getrandom(2) (in sys/random.h)' \
1687 '#define HAVE_GETRANDOM(B,S) getrandom(B, S, 0)
1688 #define HAVE_GETRANDOM_HEADER <sys/random.h>' <<\
!
1689 #include <sys/random.h>
1692 getrandom
(buf
, sizeof buf
, 0);
1698 elif link_check getrandom
'getrandom(2) (via syscall(2))' \
1699 '#define HAVE_GETRANDOM(B,S) syscall(SYS_getrandom, B, S, 0)
1700 #define HAVE_GETRANDOM_HEADER <sys/syscall.h>' <<\
!
1701 #include <sys/syscall.h>
1704 syscall
(SYS_getrandom
, buf
, sizeof buf
, 0);
1710 elif [ -n "${have_no_subsecond_time}" ]; then
1711 msg
'ERROR: %s %s' 'without a native random' \
1712 'one of clock_gettime(2) and gettimeofday(2) is required.'
1717 link_check putc_unlocked
'putc_unlocked(3)' '#define HAVE_PUTC_UNLOCKED' <<\
!
1720 putc_unlocked
('@', stdout
);
1725 link_check fchdir
'fchdir(3)' '#define HAVE_FCHDIR' << \
!
1733 if run_check realpath
'realpath(3)' '#define HAVE_REALPATH' << \
!
1736 char x_buf
[4096], *x
= realpath
(".", x_buf
);
1738 return (x
!= NULL
) ?
0 : 1;
1742 if run_check realpath_malloc
'realpath(3) takes NULL' \
1743 '#define HAVE_REALPATH_NULL' << \
!
1746 char
*x
= realpath
(".", NULL
);
1750 return (x
!= NULL
) ?
0 : 1;
1758 ## optional and selectable
1760 if feat_yes DOTLOCK
; then
1761 if run_check readlink
'readlink(2)' << \
!
1767 if(!readlink
("here", buf
, sizeof buf
) || errno
!= ENOSYS
)
1775 feat_bail_required DOTLOCK
1779 if feat_yes DOTLOCK
; then
1780 if run_check fchown
'fchown(2)' << \
!
1784 if(!fchown
(0, 0, 0) || errno
!= ENOSYS
)
1792 feat_bail_required DOTLOCK
1796 ## Now it is the time to fork away the BASE_ series
1799 squeeze_em
${inc} ${tmp}
1801 squeeze_em
${lib} ${tmp}
1804 echo "BASE_LIBS = `${cat} ${lib}`" >> ${mk}
1805 echo "BASE_INCS
= `${cat} ${inc}`" >> ${mk}
1807 ## The remains are expected to be used only by the main MUA binary!
1810 link_check setlocale 'setlocale(3)' '#define HAVE_SETLOCALE' << \!
1813 setlocale(LC_ALL, "");
1817 [ -n "${have_setlocale}" ] && OPT_LOCALES=1
1819 OPT_MULTIBYTE_CHARSETS=0
1821 OPT_TERMINAL_CHARSET=0
1822 if [ -n "${have_setlocale}" ]; then
1823 link_check c90amend1 'ISO/IEC 9899:1990/Amendment 1:1995' \
1824 '#define HAVE_C90AMEND1' << \!
1830 char mbb[MB_LEN_MAX + 1];
1835 mbtowc(&wc, "x", 1);
1836 mbrtowc(&wc, "x", 1, NULL);
1838 return (mblen("\0", 1) == 0);
1841 [ -n "${have_c90amend1}" ] && OPT_MULTIBYTE_CHARSETS=1
1843 if [ -n "${have_c90amend1}" ]; then
1844 link_check wcwidth 'wcwidth(3)' '#define HAVE_WCWIDTH' << \!
1851 [ -n "${have_wcwidth}" ] && OPT_WIDE_GLYPHS=1
1854 link_check nl_langinfo 'nl_langinfo(3)' '#define HAVE_NL_LANGINFO' << \!
1855 #include <langinfo.h>
1859 return (nl_langinfo(CODESET) == NULL);
1862 [ -n "${have_nl_langinfo}" ] && OPT_TERMINAL_CHARSET=1
1865 link_check fnmatch 'fnmatch(3)' '#define HAVE_FNMATCH' << \!
1866 #include <fnmatch.h>
1868 return (fnmatch("*", ".", FNM_PATHNAME | FNM_PERIOD) == FNM_NOMATCH);
1872 link_check dirent_d_type 'struct dirent.d_type' '#define HAVE_DIRENT_TYPE' << \!
1876 return !(de.d_type == DT_UNKNOWN ||
1877 de.d_type == DT_DIR || de.d_type == DT_LNK);
1881 ## optional and selectable
1883 if feat_yes ICONV; then
1884 ${cat} > ${tmp2}.c << \!
1885 #include <stdio.h> /* For C89 NULL */
1890 id = iconv_open("foo", "bar");
1891 iconv(id, NULL, NULL, NULL, NULL);
1896 < ${tmp2}.c link_check iconv 'iconv(3) functionality' \
1897 '#define HAVE_ICONV' ||
1898 < ${tmp2}.c link_check iconv 'iconv(3) functionality (via -liconv)' \
1899 '#define HAVE_ICONV' '-liconv' ||
1900 feat_bail_required ICONV
1902 echo '/* OPT_ICONV=0 */' >> ${h}
1905 if feat_yes SOCKETS || feat_yes SPAM_SPAMD; then
1906 ${cat} > ${tmp2}.c << \!
1907 #include <sys/types.h>
1908 #include <sys/socket.h>
1912 struct sockaddr_un soun;
1914 if(socket(AF_UNIX, SOCK_STREAM, 0) == -1 && errno == ENOSYS)
1916 if(connect(0, (struct sockaddr*)&soun, 0) == -1 && errno == ENOSYS)
1918 if(shutdown(0, SHUT_RD | SHUT_WR | SHUT_RDWR) == -1 && errno == ENOSYS)
1924 < ${tmp2}.c run_check af_unix 'AF_UNIX sockets' \
1925 '#define HAVE_UNIX_SOCKETS' ||
1926 < ${tmp2}.c run_check af_unix 'AF_UNIX sockets (via -lnsl)' \
1927 '#define HAVE_UNIX_SOCKETS' '-lnsl' ||
1928 < ${tmp2}.c run_check af_unix 'AF_UNIX sockets (via -lsocket -lnsl)' \
1929 '#define HAVE_UNIX_SOCKETS' '-lsocket -lnsl'
1932 if feat_yes SOCKETS; then
1933 ${cat} > ${tmp2}.c << \!
1934 #include <sys/types.h>
1935 #include <sys/socket.h>
1936 #include <netinet/in.h>
1941 if(socket(AF_INET, SOCK_STREAM, 0) == -1 && errno == ENOSYS)
1943 if(connect(0, &s, 0) == -1 && errno == ENOSYS)
1949 < ${tmp2}.c run_check sockets 'sockets' \
1950 '#define HAVE_SOCKETS' ||
1951 < ${tmp2}.c run_check sockets 'sockets (via -lnsl)' \
1952 '#define HAVE_SOCKETS' '-lnsl' ||
1953 < ${tmp2}.c run_check sockets 'sockets (via -lsocket -lnsl)' \
1954 '#define HAVE_SOCKETS' '-lsocket -lnsl' ||
1955 feat_bail_required SOCKETS
1957 echo '/* OPT_SOCKETS=0 */' >> ${h}
1958 fi # feat_yes SOCKETS
1960 if feat_yes SOCKETS; then
1961 link_check getaddrinfo 'getaddrinfo(3)' \
1962 '#define HAVE_GETADDRINFO' << \!
1963 #include <sys/types.h>
1964 #include <sys/socket.h>
1968 struct addrinfo a, *ap;
1971 switch((lrv = getaddrinfo("foo", "0", &a, &ap))){
1975 fprintf(stderr, "%s\n", gai_strerror(lrv));
1984 if feat_yes SOCKETS && [ -z "${have_getaddrinfo}" ]; then
1985 compile_check arpa_inet_h '<arpa/inet.h>' \
1986 '#define HAVE_ARPA_INET_H' << \!
1987 #include <sys/types.h>
1988 #include <sys/socket.h>
1990 #include <netinet/in.h>
1991 #include <arpa/inet.h>
1994 ${cat} > ${tmp2}.c << \!
1995 #include <sys/types.h>
1996 #include <sys/socket.h>
2000 #include <netinet/in.h>
2001 #ifdef HAVE_ARPA_INET_H
2002 #include <arpa/inet.h>
2005 struct sockaddr_in servaddr;
2006 unsigned short portno;
2009 struct in_addr **pptr;
2012 if((ep = getservbyname("POPPY-PORT", "tcp")) != NULL)
2013 portno = (unsigned short)ep->s_port;
2015 if((hp = gethostbyname("POPPY-HOST")) != NULL){
2016 pptr = (struct in_addr**)hp->h_addr_list;
2017 if(hp->h_addrtype != AF_INET)
2018 fprintf(stderr, "au\n");
2021 case HOST_NOT_FOUND:
2027 fprintf(stderr, "au\n");
2032 memset(&servaddr, 0, sizeof servaddr);
2033 servaddr.sin_family = AF_INET;
2034 servaddr.sin_port = htons(portno);
2035 memcpy(&servaddr.sin_addr, *pptr, sizeof(struct in_addr));
2036 fprintf(stderr, "Would connect to %s:%d ...\n",
2037 inet_ntoa(**pptr), (int)portno);
2042 < ${tmp2}.c link_check gethostbyname 'get(serv|host)byname(3)' ||
2043 < ${tmp2}.c link_check gethostbyname \
2044 'get(serv|host)byname(3) (via -nsl)' '' '-lnsl' ||
2045 < ${tmp2}.c link_check gethostbyname \
2046 'get(serv|host)byname(3) (via -lsocket -nsl)' \
2047 '' '-lsocket -lnsl' ||
2048 feat_bail_required SOCKETS
2052 run_check setsockopt 'setsockopt(2)' '#define HAVE_SETSOCKOPT' << \!
2053 #include <sys/socket.h>
2059 if(setsockopt(sockfd, SOL_SOCKET, SO_KEEPALIVE, NULL, 0) == -1 &&
2066 feat_yes SOCKETS && [ -n "${have_setsockopt}" ] &&
2067 link_check so_sndtimeo 'SO_SNDTIMEO' '#define HAVE_SO_SNDTIMEO' << \!
2068 #include <sys/socket.h>
2076 setsockopt(sockfd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof tv);
2077 setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof tv);
2082 feat_yes SOCKETS && [ -n "${have_setsockopt}" ] &&
2083 link_check so_linger 'SO_LINGER' '#define HAVE_SO_LINGER' << \!
2084 #include <sys/socket.h>
2092 setsockopt(sockfd, SOL_SOCKET, SO_LINGER, &li, sizeof li);
2097 if feat_yes SSL; then # {{{
2098 # {{{ LibreSSL decided to define OPENSSL_VERSION_NUMBER with a useless value
2099 # instead of keeping it at the one that corresponds to the OpenSSL at fork
2100 # time: we need to test it first in order to get things right
2101 if compile_check _xssl 'TLS/SSL (LibreSSL)' \
2104 #define HAVE_XSSL_RESSL
2105 #define HAVE_XSSL_OPENSSL 0' << \!
2106 #include <openssl/opensslv.h>
2107 #ifdef LIBRESSL_VERSION_NUMBER
2114 # TODO OPENSSL_IS_BORINGSSL, but never tried that one!
2115 elif compile_check _xssl 'TLS/SSL (OpenSSL >= v1.1.0)' \
2118 #define HAVE_XSSL_OPENSSL 0x10100' << \!
2119 #include <openssl/opensslv.h>
2120 #if OPENSSL_VERSION_NUMBER + 0 >= 0x10100000L
2127 elif compile_check _xssl 'TLS/SSL (OpenSSL)' \
2130 #define HAVE_XSSL_OPENSSL 0x10000' << \!
2131 #include <openssl/opensslv.h>
2132 #ifdef OPENSSL_VERSION_NUMBER
2140 feat_bail_required SSL
2143 if feat_yes SSL; then # {{{
2144 if [ -n "${ossl_v1_1}" ]; then
2145 without_check yes xssl 'TLS/SSL (new style *_client_method(3ssl))' \
2146 '#define n_XSSL_CLIENT_METHOD TLS_client_method' \
2148 elif link_check xssl 'TLS/SSL (new style *_client_method(3ssl))' \
2149 '#define n_XSSL_CLIENT_METHOD TLS_client_method' \
2150 '-lssl -lcrypto' << \!
2151 #include <openssl/ssl.h>
2152 #include <openssl/err.h>
2153 #include <openssl/x509v3.h>
2154 #include <openssl/x509.h>
2155 #include <openssl/rand.h>
2156 #ifdef OPENSSL_NO_TLS1 /* TODO only deduced from OPENSSL_NO_SSL[23]! */
2157 # error We need TLSv1.
2160 SSL_CTX *ctx = SSL_CTX_new(TLS_client_method());
2163 PEM_read_PrivateKey(0, 0, 0, 0);
2169 elif link_check xssl 'TLS/SSL (old style *_client_method(3ssl))' \
2170 '#define n_XSSL_CLIENT_METHOD SSLv23_client_method' \
2171 '-lssl -lcrypto' << \!
2172 #include <openssl/ssl.h>
2173 #include <openssl/err.h>
2174 #include <openssl/x509v3.h>
2175 #include <openssl/x509.h>
2176 #include <openssl/rand.h>
2177 #if defined OPENSSL_NO_SSL3 &&\
2178 defined OPENSSL_NO_TLS1 /* TODO only deduced from OPENSSL_NO_SSL[23]! */
2179 # error We need one of SSLv3 and TLSv1.
2182 SSL_CTX *ctx = SSL_CTX_new(SSLv23_client_method());
2185 PEM_read_PrivateKey(0, 0, 0, 0);
2192 feat_bail_required SSL
2196 if feat_yes SSL; then # {{{
2197 if [ -n "${ossl_v1_1}" ]; then
2198 without_check yes xssl_stack_of 'TLS/SSL STACK_OF()' \
2199 '#define HAVE_XSSL_STACK_OF'
2200 elif compile_check xssl_stack_of 'TLS/SSL STACK_OF()' \
2201 '#define HAVE_XSSL_STACK_OF' << \!
2202 #include <stdio.h> /* For C89 NULL */
2203 #include <openssl/ssl.h>
2204 #include <openssl/err.h>
2205 #include <openssl/x509v3.h>
2206 #include <openssl/x509.h>
2207 #include <openssl/rand.h>
2209 STACK_OF(GENERAL_NAME) *gens = NULL;
2211 printf("%p", gens); /* to use it */
2219 if [ -n "${ossl_v1_1}" ]; then
2220 without_check yes xssl_conf 'TLS/SSL OpenSSL_modules_load_file()' \
2221 '#define HAVE_XSSL_CONFIG'
2222 elif link_check xssl_conf 'TLS/SSL OpenSSL_modules_load_file() support' \
2223 '#define HAVE_XSSL_CONFIG' << \!
2224 #include <stdio.h> /* For C89 NULL */
2225 #include <openssl/conf.h>
2227 CONF_modules_load_file(NULL, NULL, CONF_MFLAGS_IGNORE_MISSING_FILE);
2228 CONF_modules_free();
2236 if [ -n "${ossl_v1_1}" ]; then
2237 without_check yes xssl_conf_ctx 'TLS/SSL SSL_CONF_CTX support' \
2238 '#define HAVE_XSSL_CONF_CTX'
2239 elif link_check xssl_conf_ctx 'TLS/SSL SSL_CONF_CTX support' \
2240 '#define HAVE_XSSL_CONF_CTX' << \!
2241 #include <openssl/ssl.h>
2242 #include <openssl/err.h>
2244 SSL_CTX *ctx = SSL_CTX_new(n_XSSL_CLIENT_METHOD());
2245 SSL_CONF_CTX *cctx = SSL_CONF_CTX_new();
2247 SSL_CONF_CTX_set_flags(cctx,
2248 SSL_CONF_FLAG_FILE | SSL_CONF_FLAG_CLIENT |
2249 SSL_CONF_FLAG_CERTIFICATE | SSL_CONF_FLAG_SHOW_ERRORS);
2250 SSL_CONF_CTX_set_ssl_ctx(cctx, ctx);
2251 SSL_CONF_cmd(cctx, "Protocol", "ALL");
2252 SSL_CONF_CTX_finish(cctx);
2253 SSL_CONF_CTX_free(cctx);
2262 if [ -n "${ossl_v1_1}" ]; then
2263 without_check no xssl_rand_egd 'TLS/SSL RAND_egd(3ssl)' \
2264 '#define HAVE_XSSL_RAND_EGD'
2265 elif link_check xssl_rand_egd 'TLS/SSL RAND_egd(3ssl)' \
2266 '#define HAVE_XSSL_RAND_EGD' << \!
2267 #include <openssl/rand.h>
2269 return RAND_egd("some.where") > 0;
2276 if feat_yes SSL_ALL_ALGORITHMS; then
2277 if [ -n "${ossl_v1_1}" ]; then
2278 without_check yes ssl_all_algo 'TLS/SSL all-algorithms support' \
2279 '#define HAVE_SSL_ALL_ALGORITHMS'
2280 elif link_check ssl_all_algo 'TLS/SSL all-algorithms support' \
2281 '#define HAVE_SSL_ALL_ALGORITHMS' << \!
2282 #include <openssl/evp.h>
2284 OpenSSL_add_all_algorithms();
2285 EVP_get_cipherbyname("two cents i never exist");
2293 feat_bail_required SSL_ALL_ALGORITHMS
2296 fi # feat_yes SSL }}}
2298 if feat_yes SSL && feat_yes MD5 && feat_no NOEXTMD5; then # {{{
2299 run_check ssl_md5 'MD5 digest in the used crypto library' \
2300 '#define HAVE_XSSL_MD5' << \!
2303 #include <openssl/md5.h>
2305 char const dat[] = "abrakadabrafidibus";
2306 char dig[16], hex[16 * 2];
2310 memset(dig, 0, sizeof(dig));
2311 memset(hex, 0, sizeof(hex));
2313 MD5_Update(&ctx, dat, sizeof(dat) - 1);
2314 MD5_Final(dig, &ctx);
2316 #define hexchar(n) ((n) > 9 ? (n) - 10 + 'a' : (n) + '0')
2317 for(i = 0; i < sizeof(hex) / 2; i++){
2319 hex[j] = hexchar((dig[i] & 0xf0) >> 4);
2320 hex[++j] = hexchar(dig[i] & 0x0f);
2322 return !!memcmp("6d7d0a3d949da2e96f2aa010f65d8326", hex, sizeof(hex));
2327 echo '/* OPT_SSL=0 */' >> ${h}
2328 fi # }}} feat_yes SSL
2330 if [ "${have_xssl}" = yes ]; then
2341 if feat_yes GSSAPI; then
2342 ${cat} > ${tmp2}.c << \!
2343 #include <gssapi/gssapi.h>
2345 gss_import_name(0, 0, GSS_C_NT_HOSTBASED_SERVICE, 0);
2346 gss_init_sec_context(0,0,0,0,0,0,0,0,0,0,0,0,0);
2350 ${sed} -e '1s/gssapi\///' < ${tmp2}.c > ${tmp3}.c
2352 if command -v krb5-config >/dev/null 2>&1; then
2353 i=`command -v krb5-config
`
2354 GSS_LIBS="`CFLAGS
= ${i} --libs gssapi
`"
2355 GSS_INCS="`CFLAGS
= ${i} --cflags`"
2356 i='GSS-API via krb5-config(1)'
2360 i='GSS-API in gssapi/gssapi.h, libgssapi'
2362 if < ${tmp2}.c link_check gss \
2363 "${i}" '#define HAVE_GSSAPI' "${GSS_LIBS}" "${GSS_INCS}" ||\
2364 < ${tmp3}.c link_check gss \
2365 'GSS-API in gssapi.h, libgssapi' \
2366 '#define HAVE_GSSAPI
2367 #define GSSAPI_REG_INCLUDE' \
2369 < ${tmp2}.c link_check gss 'GSS-API in libgssapi_krb5' \
2370 '#define HAVE_GSSAPI' \
2372 < ${tmp3}.c link_check gss \
2373 'GSS-API in libgssapi, OpenBSD-style (pre 5.3)' \
2374 '#define HAVE_GSSAPI
2375 #define GSS_REG_INCLUDE' \
2376 '-lgssapi -lkrb5 -lcrypto' \
2377 '-I/usr/include/kerberosV' ||\
2378 < ${tmp2}.c link_check gss 'GSS-API in libgss' \
2379 '#define HAVE_GSSAPI' \
2381 link_check gss 'GSS-API in libgssapi_krb5, old-style' \
2382 '#define HAVE_GSSAPI
2383 #define GSSAPI_OLD_STYLE' \
2384 '-lgssapi_krb5' << \!
2385 #include <gssapi/gssapi.h>
2386 #include <gssapi/gssapi_generic.h>
2388 gss_import_name(0, 0, gss_nt_service_name, 0);
2389 gss_init_sec_context(0,0,0,0,0,0,0,0,0,0,0,0,0);
2396 feat_bail_required GSSAPI
2399 echo '/* OPT_GSSAPI=0 */' >> ${h}
2400 fi # feat_yes GSSAPI
2405 if feat_yes IDNA; then
2406 if link_check idna 'GNU Libidn' '#define HAVE_IDNA HAVE_IDNA_LIBIDNA' \
2409 #include <idn-free.h>
2410 #include <stringprep.h>
2412 char *utf8, *idna_ascii, *idna_utf8;
2414 utf8 = stringprep_locale_to_utf8("does.this.work");
2415 if (idna_to_ascii_8z(utf8, &idna_ascii, IDNA_USE_STD3_ASCII_RULES)
2418 idn_free(idna_ascii);
2419 /* (Rather link check only here) */
2420 idna_utf8 = stringprep_convert(idna_ascii, "UTF-8", "de_DE");
2426 elif link_check idna 'idnkit' '#define HAVE_IDNA HAVE_IDNA_IDNKIT' \
2429 #include <idn/api.h>
2430 #include <idn/result.h>
2434 char local_name[256];
2436 r = idn_encodename(IDN_ENCODE_APP, "does.this.work", ace_name,
2438 if (r != idn_success) {
2439 fprintf(stderr, "idn_encodename failed: %s\n", idn_result_tostring(r));
2442 r = idn_decodename(IDN_DECODE_APP, ace_name, local_name, sizeof(local_name));
2443 if (r != idn_success) {
2444 fprintf(stderr, "idn_decodename failed: %s\n", idn_result_tostring(r));
2453 feat_bail_required IDNA
2456 if [ -n "${have_idna}" ]; then
2457 echo '#define HAVE_IDNA_LIBIDNA 0' >> ${h}
2458 echo '#define HAVE_IDNA_IDNKIT 1' >> ${h}
2461 echo '/* OPT_IDNA=0 */' >> ${h}
2464 feat_def IMAP_SEARCH
2466 if feat_yes REGEX; then
2467 if link_check regex 'regular expressions' '#define HAVE_REGEX' << \!
2475 status = regcomp(&re, ".*bsd", REG_EXTENDED | REG_ICASE | REG_NOSUB);
2476 xret = regerror(status, &re, NULL, 0);
2477 status = regexec(&re, "plan9", 0,NULL, 0);
2479 return !(status == REG_NOMATCH);
2485 feat_bail_required REGEX
2488 echo '/* OPT_REGEX=0 */' >> ${h}
2491 if feat_yes MLE && [ -n "${have_c90amend1}" ]; then
2493 echo '#define HAVE_MLE' >> ${h}
2495 feat_bail_required MLE
2496 echo '/* OPT_MLE=0 */' >> ${h}
2499 # Generic have-a-line-editor switch for those who need it below
2500 if [ -n "${have_mle}" ]; then
2504 if [ -n "${have_cle}" ] && feat_yes HISTORY; then
2505 echo '#define HAVE_HISTORY' >> ${h}
2507 echo '/* OPT_HISTORY=0 */' >> ${h}
2510 if [ -n "${have_mle}" ] && feat_yes KEY_BINDINGS; then
2511 echo '#define HAVE_KEY_BINDINGS' >> ${h}
2513 echo '/* OPT_KEY_BINDINGS=0 */' >> ${h}
2516 if feat_yes TERMCAP; then
2518 link_check termcap "termcap(5) (via ${4})" \
2519 "#define HAVE_TERMCAP${3}" "${1}" << _EOT
2524 #define UNCONST(P) ((void*)(unsigned long)(void const*)(P))
2525 static int my_putc(int c){return putchar(c);}
2527 char buf[1024+512], cmdbuf[2048], *cpb, *r1;
2528 int r2 = OK, r3 = ERR;
2530 tgetent(buf, getenv("TERM"));
2532 r1 = tgetstr(UNCONST("cm"), &cpb);
2534 r2 = tgetnum(UNCONST("Co"));
2535 r3 = tgetflag(UNCONST("ut"));
2536 tputs("cr", 1, &my_putc);
2537 return (r1 == NULL || r2 == -1 || r3 == 0);
2543 link_check terminfo "terminfo(5) (via ${2})" \
2544 '#define HAVE_TERMCAP
2545 #define HAVE_TERMCAP_CURSES
2546 #define HAVE_TERMINFO' "${1}" << _EOT
2550 #define UNCONST(P) ((void*)(unsigned long)(void const*)(P))
2551 static int my_putc(int c){return putchar(c);}
2557 r0 = setupterm(NULL, 1, &er);
2558 r1 = tigetflag(UNCONST("bce"));
2559 r2 = tigetnum(UNCONST("colors"));
2560 r3 = tigetstr(UNCONST("cr"));
2561 tp = tparm(r3, NULL, NULL, 0,0,0,0,0,0,0);
2562 tputs(tp, 1, &my_putc);
2563 return (r0 == ERR || r1 == -1 || r2 == -2 || r2 == -1 ||
2564 r3 == (char*)-1 || r3 == NULL);
2569 if feat_yes TERMCAP_VIA_TERMINFO; then
2570 __terminfolib -ltinfo -ltinfo ||
2571 __terminfolib -lcurses -lcurses ||
2572 __terminfolib -lcursesw -lcursesw ||
2573 feat_bail_required TERMCAP_VIA_TERMINFO
2576 if [ -z "${have_terminfo}" ]; then
2577 __termcaplib -ltermcap '' '' '-ltermcap' ||
2578 __termcaplib -ltermcap '#include <curses.h>' '
2579 #define HAVE_TERMCAP_CURSES' \
2580 'curses.h / -ltermcap' ||
2581 __termcaplib -lcurses '#include <curses.h>' '
2582 #define HAVE_TERMCAP_CURSES' \
2583 'curses.h / -lcurses' ||
2584 __termcaplib -lcursesw '#include <curses.h>' '
2585 #define HAVE_TERMCAP_CURSES' \
2586 'curses.h / -lcursesw' ||
2587 feat_bail_required TERMCAP
2589 if [ -n "${have_termcap}" ]; then
2590 run_check tgetent_null \
2591 "tgetent(3) of termcap(5) takes NULL buffer" \
2592 "#define HAVE_TGETENT_NULL_BUF" << _EOT
2593 #include <stdio.h> /* For C89 NULL */
2595 #ifdef HAVE_TERMCAP_CURSES
2596 # include <curses.h>
2600 tgetent(NULL, getenv("TERM"));
2607 echo '/* OPT_TERMCAP=0 */' >> ${h}
2608 echo '/* OPT_TERMCAP_VIA_TERMINFO=0 */' >> ${h}
2611 if feat_def SPAM_SPAMC; then
2612 if command -v spamc >/dev/null 2>&1; then
2613 echo "#define SPAM_SPAMC_PATH \"`command -v spamc
`\"" >> ${h}
2617 if feat_yes SPAM_SPAMD && [ -n "${have_af_unix}" ]; then
2618 echo '#define HAVE_SPAM_SPAMD' >> ${h}
2620 feat_bail_required SPAM_SPAMD
2621 echo '/* OPT_SPAM_SPAMD=0 */' >> ${h}
2624 feat_def SPAM_FILTER
2626 if feat_yes SPAM_SPAMC || feat_yes SPAM_SPAMD || feat_yes SPAM_FILTER; then
2627 echo '#define HAVE_SPAM' >> ${h}
2629 echo '/* HAVE_SPAM */' >> ${h}
2632 if feat_yes QUOTE_FOLD &&\
2633 [ -n "${have_c90amend1}" ] && [ -n "${have_wcwidth}" ]; then
2634 echo '#define HAVE_QUOTE_FOLD' >> ${h}
2636 feat_bail_required QUOTE_FOLD
2637 echo '/* OPT_QUOTE_FOLD=0 */' >> ${h}
2640 feat_def FILTER_HTML_TAGSOUP
2649 squeeze_em ${inc} ${tmp}
2651 squeeze_em ${lib} ${tmp}
2656 printf '#ifndef n_MK_CONFIG_H\n# define n_MK_CONFIG_H 1\n' > ${h}
2657 ${cat} ${tmp} >> ${h}
2661 # Create the string that is used by *features* and `version
'.
2662 # Take this nice opportunity and generate a visual listing of included and
2663 # non-included features for the person who runs the configuration
2664 msg '\nThe following features are included
(+) or not
(-):'
2665 set -- ${OPTIONS_DETECT} ${OPTIONS} ${OPTIONS_XTRA}
2666 printf '/* The
"feature string" */\n' >> ${h}
2667 # Because + is expanded by *folder* if first in "echo $features", put something
2668 printf '#define VAL_FEATURES_CNT '${#}'\n#define VAL_FEATURES "#' >> ${h}
2672 sdoc
=`option_doc_of ${opt}`
2673 [ -z "${sdoc}" ] && continue
2674 sopt
="`echo ${opt} | ${tr} '[A-Z]_' '[a-z]-'`"
2675 feat_yes
${opt} && sign
=+ || sign
=-
2676 printf -- "${sep}${sign}${sopt}" >> ${h}
2678 msg " %s
%s
: %s
" ${sign} ${sopt} "${sdoc}"
2680 # TODO instead of using sh+tr+awk+printf, use awk, drop option_doc_of, inc here
2682 #${awk} -v opts="${OPTIONS_DETECT} ${OPTIONS} ${OPTIONS_XTRA}" \
2683 # -v xopts="${XOPTIONS_DETECT} ${XOPTIONS} ${XOPTIONS_XTRA}" \
2684 printf '"\n' >> ${h}
2686 # Create the real mk-config.mk
2687 # Note we cannout use explicit ./ filename prefix for source and object
2688 # pathnames because of a bug in bmake(1)
2689 ${rm} -rf ${tmp0}.* ${tmp0}*
2690 printf 'OBJ_SRC = ' >> ${mk}
2691 if feat_no AMALGAMATION
; then
2692 for i
in `printf '%s\n' *.c | ${sort}`; do
2693 if [ "${i}" = privsep.c
]; then
2696 printf "${i} " >> ${mk}
2698 printf '\nAMALGAM_TARGET =\nAMALGAM_DEP =\n' >> ${mk}
2700 printf 'main.c\nAMALGAM_TARGET = main.o\nAMALGAM_DEP = ' >> ${mk}
2702 printf '\n/* HAVE_AMALGAMATION: include sources */\n' >> ${h}
2703 printf '#elif n_MK_CONFIG_H + 0 == 1\n' >> ${h}
2704 printf '# undef n_MK_CONFIG_H\n' >> ${h}
2705 printf '# define n_MK_CONFIG_H 2\n' >> ${h}
2706 for i
in `printf '%s\n' *.c | ${sort}`; do
2707 if [ "${i}" = "${j}" ] || [ "${i}" = main.c
] || \
2708 [ "${i}" = privsep.c
]; then
2711 printf "${i} " >> ${mk}
2712 printf "# include \"${i}\"\n" >> ${h}
2717 printf '#endif /* n_MK_CONFIG_H */\n' >> ${h}
2719 echo "LIBS = `${cat} ${lib}`" >> ${mk}
2720 echo "INCS
= `${cat} ${inc}`" >> ${mk}
2722 ${cat} ./make-config.in >> ${mk}
2727 msg ' . System-wide resource file: %s/%s' "${VAL_SYSCONFDIR}" "${VAL_SYSCONFRC}"
2728 msg ' . bindir: %s' "${VAL_BINDIR}"
2729 if feat_yes DOTLOCK; then
2730 msg ' . libexecdir: %s' "${VAL_LIBEXECDIR}"
2732 msg ' . mandir: %s' "${VAL_MANDIR}"
2733 msg ' . M(ail)T(ransfer)A(gent): %s (argv0 %s)' "${VAL_MTA}" "${VAL_MTA_ARGV0}"
2734 msg ' . $MAIL spool directory: %s' "${VAL_MAIL}"
2737 if [ -n "${have_fnmatch}" ] && [ -n "${have_fchdir}" ]; then
2741 if [ -z "${have_fnmatch}" ]; then
2742 msg ' . The function fnmatch(3) could not be found.'
2743 msg ' Filename patterns like wildcard are not supported on your system'
2745 if [ -z "${have_fchdir}" ]; then
2746 msg ' . The function fchdir(2) could not be found.'
2747 msg ' We will use chdir(2) instead.'
2748 msg ' This is a problem only if the current working directory is changed'
2749 msg ' while this program is inside of it'