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: most likely for
10 # 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 GSSAPI='Generic Security Service authentication' \
19 NETRC='.netrc file support' \
21 MD5='MD5 message digest (APOP, CRAM-MD5)' \
22 IDNA='Internationalized Domain Names for Applications (encode only)' \
23 IMAP_SEARCH='IMAP-style search expressions' \
24 REGEX='Regular expressions' \
25 MLE='Mailx Line Editor' \
26 HISTORY='Line editor history management' \
27 KEY_BINDINGS='Configurable key bindings' \
28 TERMCAP='Terminal capability queries (termcap(5))' \
29 TERMCAP_VIA_TERMINFO='Terminal capability queries use terminfo(5)' \
30 ERRORS='Error log message ring' \
31 SPAM_SPAMC='Spam management via spamc(1) of spamassassin(1)' \
33 SPAM_FILTER='Freely configurable *spam-filter-..*s' \
34 DOCSTRINGS='Command documentation help strings' \
35 QUOTE_FOLD='Extended *quote-fold*ing' \
36 FILTER_HTML_TAGSOUP='Simple builtin HTML-to-text display filter' \
37 COLOUR='Coloured message display' \
38 DOTLOCK='Dotlock files and privilege-separated dotlock program' \
41 # Options which are automatically deduced from host environment, i.e., these
42 # need special treatment all around here to warp from/to OPT_ stuff
43 # setlocale, C90AMEND1, NL_LANGINFO, wcwidth
45 LOCALES='Locale support - printable characters etc. depend on environment' \
46 MULTIBYTE_CHARSETS='Multibyte character sets' \
47 TERMINAL_CHARSET='Automatic detection of terminal character set' \
48 WIDE_GLYPHS='Wide glyph support' \
51 # Rather special options, for custom building, or which always exist.
52 # Mostly for generating the visual overview and the *features* string
54 MIME='Multipurpose Internet Mail Extensions' \
55 SMIME='S/MIME message signing, verification, en- and decryption' \
56 CROSS_BUILD='Cross-compilation: trust any detected environment' \
57 DEBUG='Debug enabled binary, not for end-users: THANKS!' \
58 DEVEL='Computers do not blunder' \
61 # The problem is that we don't have any tools we can use right now, so
62 # encapsulate stuff in functions which get called in right order later on
84 option_parse OPTIONS_DETECT
"${XOPTIONS_DETECT}"
85 option_parse OPTIONS
"${XOPTIONS}"
86 option_parse OPTIONS_XTRA
"${XOPTIONS_XTRA}"
89 # Predefined CONFIG= urations take precedence over anything else
90 if [ -n "${CONFIG}" ]; then
99 [mM
][iI
][nN
][iI
][mM
][aA
][lL
])
105 [mM
][eE
][dD
][iI
][uU
][mM
])
111 OPT_HISTORY
=1 OPT_KEY_BINDINGS
=1
118 [nN
][eE
][tT
][sS
][eE
][nN
][dD
])
124 OPT_GSSAPI
=1 OPT_NETRC
=1 OPT_AGENT
=1
128 OPT_HISTORY
=1 OPT_KEY_BINDINGS
=1
133 [mM
][aA
][xX
][iI
][mM
][aA
][lL
])
137 [dD
][eE
][vV
][eE
][lL
])
138 OPT_DEVEL
=1 OPT_DEBUG
=1 OPT_NYD2
=1
141 [oO
][dD
][eE
][vV
][eE
][lL
])
146 echo >&2 "Unknown CONFIG= setting: ${CONFIG}"
147 echo >&2 ' NULL, NULLI, MINIMAL, MEDIUM, NETSEND, MAXIMAL'
154 # Inter-relationships
156 if feat_no SMTP
&& feat_no POP3
; then
159 if feat_no SOCKETS
; then
160 if feat_require SMTP
; then
161 msg
'ERROR: need SOCKETS for required feature SMTP'
164 if feat_require POP3
; then
165 msg
'ERROR: need SOCKETS for required feature POP3'
168 OPT_SSL
=0 OPT_SSL_ALL_ALGORITHMS
=0
169 OPT_SMTP
=0 OPT_POP3
=0
170 OPT_GSSAPI
=0 OPT_NETRC
=0 OPT_AGENT
=0
172 if feat_no SMTP
; then
177 OPT_HISTORY
=0 OPT_KEY_BINDINGS
=0
180 # If we don't need MD5 leave it alone
181 if feat_no SOCKETS
; then
185 if feat_yes DEVEL
; then
193 h
=.
/config.h h_name
=config.h
196 newlst
=.
/config.lst-new
197 newmk
=.
/config.mk-new
198 newev
=.
/config.ev-new
204 ## -- >8 - << OPTIONS | OS/CC >> - 8< -- ##
206 # Note that potential duplicates in PATH, C_INCLUDE_PATH etc. will be cleaned
207 # via path_check() later on once possible
209 # TODO cc_maxopt is brute simple, we should compile test program and dig real
210 # compiler versions for known compilers, then be more specific
215 # We don't "have any utility": only path adjustments and such in here!
216 i
="${OS:-`uname -s`}"
218 if [ ${i} = SunOS
]; then
219 msg
'SunOS / Solaris? Applying some "early setup" rules ...'
220 _os_early_setup_sunos
224 _os_early_setup_sunos
() {
225 # According to standards(5), this is what we need to do
226 if [ -d /usr
/xpg4
]; then :; else
227 msg
'ERROR: On SunOS / Solaris we need /usr/xpg4 environment! Sorry.'
230 PATH
="/usr/xpg4/bin:/usr/ccs/bin:/usr/bin:${PATH}"
231 [ -d /usr
/xpg6
] && PATH
="/usr/xpg6/bin:${PATH}"
236 # OSFULLSPEC is used to recognize changes (i.e., machine type, updates etc.)
237 OSFULLSPEC
="${OS:-`uname -a | ${tr} '[A-Z]' '[a-z]'`}"
238 OS
="${OS:-`uname -s | ${tr} '[A-Z]' '[a-z]'`}"
239 msg
'Operating system is %s' ${OS}
241 if [ ${OS} = sunos
]; then
242 msg
' . have special SunOS / Solaris "setup" rules ...'
244 elif [ ${OS} = unixware
]; then
245 msg
' . have special UnixWare environmental rules ...'
246 if feat_yes AUTOCC
&& command -v cc
>/dev
/null
2>&1; then
248 feat_yes DEBUG
&& _CFLAGS
='-v -Xa -g' || _CFLAGS
='-Xa -O'
250 CFLAGS
="${_CFLAGS} ${EXTRA_CFLAGS}"
251 LDFLAGS
="${_LDFLAGS} ${EXTRA_LDFLAGS}"
252 export CC CFLAGS LDFLAGS
253 OPT_AUTOCC
=0 had_want_autocc
=1 need_R_ldflags
=-R
255 elif [ -n "${VERBOSE}" ]; then
256 msg
' . no special treatment for this system necessary or known'
259 # Sledgehammer: better set _GNU_SOURCE
260 # And in general: oh, boy!
261 OS_DEFINES
="${OS_DEFINES}#define _GNU_SOURCE\n"
262 #OS_DEFINES="${OS_DEFINES}#define _POSIX_C_SOURCE 200809L\n"
263 #OS_DEFINES="${OS_DEFINES}#define _XOPEN_SOURCE 700\n"
264 #[ ${OS} = darwin ] && OS_DEFINES="${OS_DEFINES}#define _DARWIN_C_SOURCE\n"
266 # On pkgsrc(7) systems automatically add /usr/pkg/*
267 if [ -d /usr
/pkg
]; then
268 C_INCLUDE_PATH
="${C_INCLUDE_PATH}:/usr/pkg/include"
269 LD_LIBRARY_PATH
="${LD_LIBRARY_PATH}:/usr/pkg/lib"
274 C_INCLUDE_PATH
="/usr/xpg4/include:${C_INCLUDE_PATH}"
275 LD_LIBRARY_PATH
="/usr/xpg4/lib:${LD_LIBRARY_PATH}"
278 if [ -d /opt
/csw
]; then
279 C_INCLUDE_PATH
="${C_INCLUDE_PATH}:/opt/csw/include"
280 LD_LIBRARY_PATH
="${LD_LIBRARY_PATH}:/opt/csw/lib"
283 OS_DEFINES
="${OS_DEFINES}#define __EXTENSIONS__\n"
284 #OS_DEFINES="${OS_DEFINES}#define _POSIX_C_SOURCE 200112L\n"
286 [ -n "${cksum}" ] ||
cksum=/opt
/csw
/gnu
/cksum
287 if [ -x "${cksum}" ]; then :; else
288 msg
'ERROR: Not an executable program: %s' "${cksum}"
289 msg
'ERROR: We need a CRC-32 cksum(1), as specified in POSIX.'
290 msg
'ERROR: However, we do so only for tests.'
291 msg
'ERROR: If that is ok, set "cksum=/usr/bin/true", then rerun'
295 if feat_yes AUTOCC
; then
296 if command -v cc
>/dev
/null
2>&1; then
298 feat_yes DEBUG
&& _CFLAGS
="-v -Xa -g" || _CFLAGS
="-Xa -O"
300 CFLAGS
="${_CFLAGS} ${EXTRA_CFLAGS}"
301 LDFLAGS
="${_LDFLAGS} ${EXTRA_LDFLAGS}"
302 export CC CFLAGS LDFLAGS
303 OPT_AUTOCC
=0 had_want_autocc
=1 need_R_ldflags
=-R
305 # Assume gcc(1), which supports -R for compat
306 cc_maxopt
=2 force_no_stackprot
=1 need_R_ldflags
=-Wl,-R
311 # Check out compiler ($CC) and -flags ($CFLAGS)
313 # Even though it belongs into cc_flags we will try to compile and link
314 # something, so ensure we have a clean state regarding CFLAGS/LDFLAGS or
315 # EXTRA_CFLAGS/EXTRA_LDFLAGS
316 if feat_no AUTOCC
; then
318 # Ensure those don't do any harm
319 EXTRA_CFLAGS
= EXTRA_LDFLAGS
=
320 export EXTRA_CFLAGS EXTRA_LDFLAGS
324 export CFLAGS LDFLAGS
327 [ -n "${CC}" ] && [ "${CC}" != cc ] && { _cc_default; return; }
329 msg_nonl 'Searching for a usable C compiler .. $CC='
330 if { i="`command -v clang`"; }; then
332 elif { i="`command -v gcc`"; }; then
334 elif { i="`command -v c99`"; }; then
336 elif { i="`command -v tcc`"; }; then
338 elif { i="`command -v pcc`"; }; then
341 if [ "${CC}" = cc ]; then
343 elif { i="`command -v c89`"; }; then
346 msg 'boing booom tschak'
347 msg 'ERROR: I cannot find a compiler!'
348 msg ' Neither of clang(1), gcc(1), tcc(1), pcc(1), c89(1) and c99(1).'
349 msg ' Please set ${CC} environment variable, maybe ${CFLAGS}, rerun.'
358 if [ -z "${CC}" ]; then
359 msg 'To go on like you have chosen, please set $CC, rerun.'
363 if [ -z "${VERBOSE}" ] && [ -f ${lst} ] && feat_no DEBUG; then
366 msg 'Using C compiler ${CC}=%s' "${CC}"
371 if feat_yes AUTOCC; then
372 if [ -f ${lst} ] && feat_no DEBUG && [ -z "${VERBOSE}" ]; then
374 msg 'Detecting ${CFLAGS}/${LDFLAGS} for ${CC}=%s, just a second..' \
378 msg 'Testing usable ${CFLAGS}/${LDFLAGS} for ${CC}=%s' "${CC}"
381 i
=`echo "${CC}" | ${awk} 'BEGIN{FS="/"}{print $NF}'`
382 if { echo "${i}" | ${grep} tcc; } >/dev/null 2>&1; then
383 msg ' . have special tcc(1) environmental rules ...'
386 # As of pcc CVS 2016-04-02, stack protection support is announced but
387 # will break if used on Linux
388 if { echo "${i}" | ${grep} pcc; } >/dev
/null
2>&1; then
394 feat_no DEBUG
&& _CFLAGS
="-DNDEBUG ${_CFLAGS}"
395 CFLAGS
="${_CFLAGS} ${EXTRA_CFLAGS}"
396 LDFLAGS
="${_LDFLAGS} ${EXTRA_LDFLAGS}"
398 if feat_no DEBUG
; then
399 CFLAGS
="-DNDEBUG ${CFLAGS}"
403 export CFLAGS LDFLAGS
407 __cflags
=${_CFLAGS} __ldflags
=${_LDFLAGS}
414 if feat_yes DEBUG
; then
415 # May have problems to find libtcc cc_check -b
419 if ld_check
-Wl,-rpath =.
/ no
; then
420 need_R_ldflags
=-Wl,-rpath=
421 ld_runtime_flags
# update!
424 _CFLAGS
="${_CFLAGS} ${__cflags}" _LDFLAGS="${_LDFLAGS} ${__ldflags}"
425 unset __cflags __ldflags
428 _cc_flags_generic
() {
429 __cflags
=${_CFLAGS} __ldflags
=${_LDFLAGS}
431 feat_yes DEVEL
&& cc_check
-std=c89 || cc_check
-std=c99
433 # Check -g first since some others may rely upon -g / optim. level
434 if feat_yes DEBUG
; then
437 elif [ ${cc_maxopt} -gt 2 ] && cc_check
-O3; then
439 elif [ ${cc_maxopt} -gt 1 ] && cc_check
-O2; then
441 elif [ ${cc_maxopt} -gt 0 ] && cc_check
-O1; then
447 if feat_yes DEVEL
&& cc_check
-Weverything; then
452 cc_check
-Wbad-function-cast
453 cc_check
-Wcast-align
456 cc_check
-Wmissing-prototypes
459 cc_check
-Wwrite-strings
460 cc_check
-Wno-long-long
464 if feat_yes AMALGAMATION
&& feat_no DEVEL
; then
465 cc_check
-Wno-unused-function
467 feat_no DEVEL
&& cc_check
-Wno-unused-result # XXX do right way (pragma too)
469 cc_check
-fno-unwind-tables
470 cc_check
-fno-asynchronous-unwind-tables
471 cc_check
-fstrict-aliasing
472 if cc_check
-fstrict-overflow && feat_yes DEVEL
; then
473 cc_check
-Wstrict-overflow=5
476 if feat_yes DEBUG || feat_yes FORCED_STACKPROT
; then
477 if [ -z "${force_no_stackprot}" ]; then
478 if cc_check
-fstack-protector-strong ||
479 cc_check
-fstack-protector-all; then
480 cc_check
-D_FORTIFY_SOURCE=2
483 msg
'Not checking for -fstack-protector compiler option,'
484 msg
'since that caused errors in a "similar" configuration.'
485 msg
'You may turn off OPT_AUTOCC and use your own settings, rerun'
489 if feat_yes AMALGAMATION
; then
493 # LD (+ dependend CC)
495 if feat_yes DEVEL
; then
498 #if cc_check -fsanitize=memory &&
499 # ld_check -fsanitize=memory &&
500 # cc_check -fsanitize-memory-track-origins=2 &&
501 # ld_check -fsanitize-memory-track-origins=2; then
508 ld_check
-Wl,-z,relro
510 ld_check
-Wl,-z,noexecstack
511 if ld_check
-Wl,-rpath =.
/ no
; then
512 need_R_ldflags
=-Wl,-rpath=
513 ld_runtime_flags
# update!
514 elif ld_check
-Wl,-R .
/ no
; then
515 need_R_ldflags
=-Wl,-R
516 ld_runtime_flags
# update!
519 # Address randomization
521 if cc_check
-fPIE || cc_check
-fpie; then
522 ld_check
-pie || _CFLAGS
=${_ccfg}
526 _CFLAGS
="${_CFLAGS} ${__cflags}" _LDFLAGS="${_LDFLAGS} ${__ldflags}"
527 unset __cflags __ldflags
530 ## -- >8 - <<OS/CC | SUPPORT FUNS>> - 8< -- ##
533 ## - Heirloom sh(1) (and same origin) have _sometimes_ problems with ': >'
534 ## redirection, so use "printf '' >" instead
536 ## Very first: we undergo several states regarding I/O redirection etc.,
537 ## but need to deal with option updates from within all. Since all the
538 ## option stuff should be above the scissor line, define utility functions
539 ## and redefine them as necessary.
540 ## And, since we have those functions, simply use them for whatever
549 printf >&2 -- "${fmt}\\n" "${@}"
555 printf >&2 -- "${fmt}" "${@}"
558 t1
=ten10one1ten10one1
559 if ( [ ${t1##*ten10} = one1
] && [ ${t1#*ten10} = one1ten10one1
] &&
560 [ ${t1%%one1*} = ten10
] && [ ${t1%one1*} = ten10one1ten10
]
561 ) > /dev
/null
2>&1; then
568 # We need some standard utilities
571 n
=${1} i=${2} opt=${3:-0}
572 # Evaluate, just in case user comes in with shell snippets (..well..)
574 if type "${i}" >/dev
/null
2>&1; then # XXX why have i type not command -v?
575 [ -n "${VERBOSE}" ] && msg ' . ${%s} ... %s' "${n}" "${i}"
579 if [ ${opt} -eq 0 ]; then
580 msg
'ERROR: no trace of utility %s' "${n}"
586 # Our feature check environment
588 [ "x${1}" = x0
] ||
[ "x${1}" = xn
] ||
589 [ "x${1}" = xfalse ] || [ "x${1}" = xno ] || [ "x${1}" = xoff
]
593 [ "x${1}" = x1
] ||
[ "x${1}" = xy
] ||
594 [ "x${1}" = xtrue ] || [ "x${1}" = xyes ] || [ "x${1}" = xon
] ||
595 [ "x${1}" = xrequire
]
599 [ "x${1}" = xrequire
]
604 i
="`echo ${i} | ${tr} '[A-Z]' '[a-z]'`"
605 if feat_val_no
"${i}"; then
607 elif feat_val_yes
"${i}"; then
610 msg
"ERROR: %s: 0/n/false/no/off or 1/y/true/yes/on/require, got: %s" \
621 _feat_check
${1} && return 1
627 i
="`echo ${i} | ${tr} '[A-Z]' '[a-z]'`"
628 [ "x${i}" = xrequire
] ||
[ "x${i}" = xrequired
]
631 feat_bail_required
() {
632 if feat_require
${1}; then
633 msg
'ERROR: feature OPT_%s is required but not available' "${1}"
637 option_update
# XXX this is rather useless here (dependency chain..)
641 # Parse one of our XOPTIONS* in $2 and assign the sh(1) compatible list of
642 # options, without documentation, to $1
644 i
="`${awk} -v input=\"${2}\" '
647 voff = match(input, /[[:alnum:]_]+(='${j}'[^'${j}']+)?/)
650 v = substr(input, voff, RLENGTH)
651 input = substr(input, voff + RLENGTH)
654 d = substr(v, doff + 2, length(v) - doff - 1)
655 v = substr(v, 1, doff - 1)
665 # Return the "documentation string" for option $1, itself if none such
667 ${awk} -v want
="${1}" \
668 -v input
="${XOPTIONS_DETECT}${XOPTIONS}${XOPTIONS_XTRA}" '
671 voff = match(input, /[[:alnum:]_]+(='${j}'[^'${j}']+)?/)
674 v = substr(input, voff, RLENGTH)
675 input = substr(input, voff + RLENGTH)
678 d = substr(v, doff + 2, length(v) - doff - 1)
679 v = substr(v, 1, doff - 1)
693 # Join the values from make.rc into what currently is defined, not
694 # overwriting yet existing settings
696 # We want read(1) to perform backslash escaping in order to be able to use
697 # multiline values in make.rc; the resulting sh(1)/sed(1) code was very slow
698 # in VMs (see [fa2e248]), Aharon Robbins suggested the following
699 < ${rc} ${awk} 'BEGIN{line = ""}{
700 gsub
(/^
[[:space
:]]+/, "", $0)
701 gsub
(/[[:space
:]]+$
/, "", $0)
702 if(gsub
(/\\$
/, "", $0)){
707 if(index
(line
, "#") == 1){
709 }else if(length
(line
)){
715 if [ -n "${good_shell}" ]; then
718 i=`${awk} -v LINE="${line}" 'BEGIN
{
719 gsub
(/=.
*$
/, "", LINE
)
723 if [ "${i}" = "${line}" ]; then
724 msg 'ERROR
: invalid syntax
in: %s
' "${line}"
728 eval j="\$${i}" jx="\${${i}+x}"
729 if [ -n "${j}" ] || [ "${jx}" = x ]; then
732 j=`${awk} -v LINE="${line}" 'BEGIN
{
733 gsub
(/^
[^
=]*=/, "", LINE
)
734 gsub
(/^
\"*/, "", LINE
)
735 gsub
(/\"*$
/, "", LINE
)
739 [ "${i}" = "DESTDIR" ] && continue
742 # Reread the mixed version right now
747 # Expand the option values, which may contain shell snippets
748 ${rm} -f ${newlst} ${newmk} ${newh}
749 exec 5<&0 6>&1 <${tmp} >${newlst}
752 if [ -n "${good_shell}" ]; then
754 [ "${i}" != "${i#OPT_}" ] && z=1
756 i=`${awk} -v LINE="${line}" 'BEGIN
{
757 gsub
(/=.
*$
/, "", LINE
);\
760 if echo "${i}" | ${grep} '^OPT_
' >/dev/null 2>&1; then
766 if [ -n "${z}" ]; then
767 j="`echo ${j} | ${tr} '[A-Z
]' '[a-z
]'`"
768 if [ -z "${j}" ] || feat_val_no "${j}"; then
770 printf " /* #undef ${i} */\n" >> ${newh}
771 elif feat_val_yes "${j}"; then
772 if feat_val_require "${j}"; then
777 printf " /* #define ${i} */\n" >> ${newh}
779 msg 'ERROR
: cannot parse
<%s
>' "${line}"
783 printf "#define ${i} \"${j}\"\n" >> ${newh}
785 printf "${i} = ${j}\n" >> ${newmk}
789 exec 0<&5 1>&6 5<&- 6<&-
793 # "path_check VARNAME" or "path_check VARNAME FLAG VARNAME"
794 varname=${1} addflag=${2} flagvarname=${3}
802 [ -z "${i}" ] && continue
803 [ -d "${i}" ] || continue
804 # Skip any fakeroot packager environment
805 case "${i}" in *fakeroot*) continue;; esac
806 if [ -n "${j}" ]; then
807 if { z=${y}; echo "${z}"; } | ${grep} ":${i}:" >/dev/null 2>&1; then
812 [ -n "${addflag}" ] && k="${k} ${addflag}${i}"
817 [ -n "${addflag}" ] && k="${addflag}${i}"
820 eval "${varname}=\"${j}\""
821 [ -n "${addflag}" ] && eval "${flagvarname}=\"${k}\""
826 if [ -n "${need_R_ldflags}" ]; then
829 set -- ${LD_LIBRARY_PATH}
833 LDFLAGS="${LDFLAGS} ${need_R_ldflags}${i}"
834 _LDFLAGS="${_LDFLAGS} ${need_R_ldflags}${i}"
838 # Disable it for a possible second run.
843 [ -n "${cc_check_silent}" ] || msg_nonl ' . CC
%s ..
' "${1}"
845 ${_CFLAGS} ${1} ${EXTRA_CFLAGS} ${_LDFLAGS} ${EXTRA_LDFLAGS} \
846 -o ${tmp2} ${tmp}.c ${LIBS} >/dev/null 2>&1; then
847 _CFLAGS="${_CFLAGS} ${1}"
848 [ -n "${cc_check_silent}" ] || msg 'yes'
851 [ -n "${cc_check_silent}" ] || msg 'no
'
856 # $1=option [$2=option argument] [$3=if set, shall NOT be added to _LDFLAGS]
857 [ -n "${cc_check_silent}" ] || msg_nonl ' . LD
%s ..
' "${1}"
858 if "${CC}" ${INCS} ${_CFLAGS} ${_LDFLAGS} ${1}${2} ${EXTRA_LDFLAGS} \
859 -o ${tmp2} ${tmp}.c ${LIBS} >/dev/null 2>&1; then
860 [ -n "${3}" ] || _LDFLAGS="${_LDFLAGS} ${1}"
861 [ -n "${cc_check_silent}" ] || msg 'yes'
864 [ -n "${cc_check_silent}" ] || msg 'no
'
869 variable=$1 topic=$2 define=$3
872 msg_nonl ' .
%s ...
' "${topic}"
873 echo "/* checked ${topic} */" >> ${h}
874 ${rm} -f ${tmp} ${tmp}.o
875 echo '*** test program is
'
876 { echo '#include <'"${h_name}"'>'; cat; } | ${tee} ${tmp}.c
877 #echo '*** the preprocessor generates'
878 #${make} -f ${makefile} ${tmp}.x
880 echo '*** results are'
884 yesno
=$1 variable
=$2 topic
=$3 define
=$4 libs
=$5 incs
=$6
887 msg_nonl
' . %s ... ' "${topic}"
889 echo '*** enforced unchecked results are'
890 if feat_val_yes
${yesno}; then
891 if [ -n "${incs}" ] ||
[ -n "${libs}" ]; then
892 echo "*** adding INCS<${incs}> LIBS<${libs}>"
893 LIBS
="${LIBS} ${libs}"
894 echo "${libs}" >> ${lib}
895 INCS
="${INCS} ${incs}"
896 echo "${incs}" >> ${inc}
899 echo "${define}" >> ${h}
900 eval have_
${variable}=yes
903 echo "/* ${define} */" >> ${h}
905 eval unset have_
${variable}
911 variable
=$1 topic
=$2 define
=$3
913 _check_preface
"${variable}" "${topic}" "${define}"
915 if ${make} -f ${makefile} XINCS="${INCS}" \
916 CFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}" \
918 [ -f ./${tmp}.o ]; then
920 echo "${define}" >> ${h}
921 eval have_${variable}=yes
924 echo "/* ${define} */" >> ${h}
926 eval unset have_${variable}
932 run=$1 variable=$2 topic=$3 define=$4 libs=$5 incs=$6
934 _check_preface "${variable}" "${topic}" "${define}"
936 feat_yes CROSS_BUILD && run=0
938 if ${make} -f ${makefile} XINCS="${INCS} ${incs}" \
939 CFLAGS
="${CFLAGS}" LDFLAGS
="${LDFLAGS}" \
940 XLIBS
="${LIBS} ${libs}" \
943 { [ ${run} -eq 0 ] || ./${tmp}; }; then
944 echo "*** adding INCS<${incs}> LIBS<${libs}>; executed: ${run}"
946 echo "${define}" >> ${h}
947 LIBS
="${LIBS} ${libs}"
948 echo "${libs}" >> ${lib}
949 INCS
="${INCS} ${incs}"
950 echo "${incs}" >> ${inc}
951 eval have_
${variable}=yes
955 echo "/* ${define} */" >> ${h}
956 eval unset have_
${variable}
962 _link_mayrun
0 "${1}" "${2}" "${3}" "${4}" "${5}"
966 _link_mayrun
1 "${1}" "${2}" "${3}" "${4}" "${5}"
970 if feat_yes
${1}; then
971 echo '#define HAVE_'${1}'' >> ${h}
973 echo '/* OPT_'${1}'=0 */' >> ${h}
978 < "${1}" > "${2}" ${awk} \
979 'BEGIN {ORS = " "} /^[^#]/ {print} {next} END {ORS = ""; print "\n"}'
982 ## -- >8 - <<SUPPORT FUNS | RUNNING>> - 8< -- ##
984 # First of all, create new configuration and check whether it changed
986 # Very easy checks for the operating system in order to be able to adjust paths
987 # or similar very basic things which we need to be able to go at all
990 # Check those tools right now that we need before including $rc
991 msg 'Checking for basic utility set'
992 check_tool awk "${awk:-`command -v awk`}"
993 check_tool rm "${rm:-`command -v rm`}"
994 check_tool tr "${tr:-`command -v tr`}"
996 # Initialize the option set
997 msg_nonl 'Setting up configuration options ... '
1001 # Include $rc, but only take from it what wasn't overwritten by the user from
1002 # within the command line or from a chosen fixed CONFIG=
1003 # Note we leave alone the values
1004 trap "exit 1" HUP INT TERM
1005 trap "${rm} -f ${tmp}" EXIT
1007 msg_nonl 'Joining in %s ... ' ${rc}
1011 # We need to know about that now, in order to provide utility overwrites etc.
1014 msg 'Checking for remaining set of utilities'
1015 check_tool grep "${grep:-`command -v grep`}"
1017 # Before we step ahead with the other utilities perform a path cleanup first.
1021 check_tool cat "${cat:-`command -v cat`}"
1022 check_tool chmod "${chmod:-`command -v chmod`}"
1023 check_tool cp "${cp:-`command -v cp`}"
1024 check_tool cmp "${cmp:-`command -v cmp`}"
1026 check_tool mkdir "${mkdir:-`command -v mkdir`}"
1027 check_tool mv "${mv:-`command -v mv`}"
1029 check_tool sed "${sed:-`command -v sed`}"
1030 check_tool sort "${sort:-`command -v sort`}"
1031 check_tool tee "${tee:-`command -v tee`}"
1033 check_tool chown "${chown:-`command -v chown`}" 1 ||
1034 check_tool chown "/sbin
/chown
" 1 ||
1035 check_tool chown "/usr
/sbin
/chown
"
1037 check_tool make "${MAKE:-`command -v make`}"
1039 check_tool strip "${STRIP:-`command -v strip`}" 1 &&
1040 HAVE_STRIP=1 || HAVE_STRIP=0
1042 # For ./cc-test.sh only
1043 check_tool cksum "${cksum:-`command -v cksum`}"
1045 # Update OPT_ options now, in order to get possible inter-dependencies right
1048 # (No functions since some shells loose non-exported variables in traps)
1049 trap "trap \"\" HUP INT TERM
; exit 1" HUP INT TERM
1050 trap "trap \"\" HUP INT TERM EXIT
;\
1051 ${rm} -rf ${newlst} ${tmp0}.* ${tmp0}* ${newmk} ${newev} ${newh}" EXIT
1053 # Our configuration options may at this point still contain shell snippets,
1054 # we need to evaluate them in order to get them expanded, and we need those
1055 # evaluated values not only in our new configuration file, but also at hand..
1056 msg_nonl 'Evaluating all configuration items ... '
1060 # Add the known utility and some other variables
1061 printf "#define VAL_UAGENT \"${VAL_SID}${VAL_NAIL}\"\n" >> ${newh}
1062 printf "VAL_UAGENT = ${VAL_SID}${VAL_NAIL}\n" >> ${newmk}
1064 printf "#define VAL_PRIVSEP \"${VAL_SID}${VAL_NAIL}-privsep\"\n" >> ${newh}
1065 printf "VAL_PRIVSEP = \$(VAL_UAGENT)-privsep\n" >> ${newmk}
1066 if feat_yes DOTLOCK
; then
1067 printf "OPTIONAL_PRIVSEP = \$(VAL_PRIVSEP)\n" >> ${newmk}
1069 printf "OPTIONAL_PRIVSEP =\n" >> ${newmk}
1073 awk cat chmod chown
cp cmp grep mkdir
mv rm sed sort tee tr \
1074 MAKE MAKEFLAGS
make SHELL strip \
1077 printf "${i} = ${j}\n" >> ${newmk}
1078 printf "${i}=${j}\n" >> ${newlst}
1079 printf "${i}=\"${j}\";export ${i}; " >> ${newev}
1081 printf "\n" >> ${newev}
1083 # Build a basic set of INCS and LIBS according to user environment.
1084 path_check C_INCLUDE_PATH -I _INCS
1085 INCS="${INCS} ${_INCS}"
1086 path_check LD_LIBRARY_PATH -L _LIBS
1087 LIBS="${LIBS} ${_LIBS}"
1089 export C_INCLUDE_PATH LD_LIBRARY_PATH
1091 # Some environments need runtime path flags to be able to go at all
1094 ## Detect CC, whether we can use it, and possibly which CFLAGS we can use
1098 ${cat} > ${tmp}.c << \!
1101 static void doit(char const *s);
1103 main(int argc, char **argv){
1106 doit("Hello world
");
1110 doit(char const *s){
1112 memcpy(buf, s, strlen(s) +1);
1117 if "${CC}" ${INCS} ${CFLAGS} ${EXTRA_CFLAGS} ${LDFLAGS} ${EXTRA_LDFLAGS} \
1118 -o ${tmp2} ${tmp}.c ${LIBS}; then
1121 msg
'ERROR: i cannot compile a "Hello world" via'
1123 "${CC} ${INCS} ${CFLAGS} ${EXTRA_CFLAGS} ${LDFLAGS} ${EXTRA_LDFLAGS} ${LIBS}"
1124 msg
'ERROR: Please read INSTALL, rerun'
1128 # This may also update ld_runtime_flags() (again)
1135 printf -- "${i}=${j}\n" >> ${newlst}
1141 PATH C_INCLUDE_PATH LD_LIBRARY_PATH \
1145 printf -- "${i} = ${j}\n" >> ${newmk}
1146 printf -- "${i}=${j}\n" >> ${newlst}
1149 # Now finally check whether we already have a configuration and if so, whether
1150 # all those parameters are still the same.. or something has actually changed
1151 if [ -f ${lst} ] && ${cmp} ${newlst} ${lst} >/dev/null 2>&1; then
1152 echo 'Configuration is up-to-date'
1154 elif [ -f ${lst} ]; then
1155 echo 'Configuration has been updated..'
1156 ( eval "${MAKE} -f .
/mk.mk clean
" )
1159 echo 'Shiny configuration..'
1162 # Time to redefine helper 1
1164 ${rm} -f ${lst} ${h} ${mk}
1168 ${mv} -f ${newlst} ${lst}
1169 ${mv} -f ${newev} ${ev}
1170 ${mv} -f ${newh} ${h}
1171 ${mv} -f ${newmk} ${mk}
1173 if [ -z "${VERBOSE}" ]; then
1174 printf -- "ECHO_CC
= @
echo ' 'CC \$
(@
);\n" >> ${mk}
1175 printf -- "ECHO_LINK
= @
echo ' 'LINK \$
(@
);\n" >> ${mk}
1176 printf -- "ECHO_GEN
= @
echo ' 'GEN \$
(@
);\n" >> ${mk}
1177 printf -- "ECHO_TEST
= @
\n" >> ${mk}
1178 printf -- "ECHO_CMD
= @
echo ' CMD';\n" >> ${mk}
1179 printf -- "ECHO_BLOCK_BEGIN
= @
( \n" >> ${mk}
1180 printf -- "ECHO_BLOCK_END
= ) >/dev
/null
\n" >> ${mk}
1183 ## Compile and link checking
1189 makefile=./config.mk
1191 # (No function since some shells loose non-exported variables in traps)
1192 trap "trap \"\" HUP INT TERM
;\
1193 ${rm} -f ${lst} ${h} ${mk} ${lib} ${inc}; exit 1" HUP INT TERM
1194 trap "trap \"\" HUP INT TERM EXIT
;\
1195 ${rm} -rf ${tmp0}.* ${tmp0}* ${makefile}" EXIT
1197 # Time to redefine helper 2
1201 printf "*** ${fmt}\\n
" "${@}"
1202 printf -- "${fmt}\\n
" "${@}" >&5
1207 printf "*** ${fmt}\\n
" "${@}"
1208 printf -- "${fmt}" "${@}" >&5
1212 exec 5>&2 > ${log} 2>&1
1214 echo "${LIBS}" > ${lib}
1215 echo "${INCS}" > ${inc}
1216 ${cat} > ${makefile} << \!
1217 .SUFFIXES: .o .c .x .y
1219 $(CC) -I./ $(XINCS) $(CFLAGS) -c $(<)
1221 $(CC) -I./ $(XINCS) -E $(<) > $(@)
1223 $(CC) -I./ $(XINCS) $(CFLAGS) $(LDFLAGS) -o $(@) $(<) $(XLIBS)
1228 # May be multiline..
1229 [ -n "${OS_DEFINES}" ] && printf -- "${OS_DEFINES}" >> ${h}
1231 feat_def ALWAYS_UNICODE_LOCALE
1232 feat_def AMALGAMATION
1233 feat_def CROSS_BUILD
1241 if run_check inline
'inline functions' \
1242 '#define HAVE_INLINE
1243 #define n_INLINE static inline' << \
!
1244 static inline int ilf
(int i
){return ++i
;}
1245 int main
(void
){return ilf
(-1);}
1249 elif run_check inline
'inline functions (via __inline)' \
1250 '#define HAVE_INLINE
1251 #define n_INLINE static __inline' << \
!
1252 static __inline int ilf
(int i
){return ++i
;}
1253 int main
(void
){return ilf
(-1);}
1259 if run_check endian
'Little endian byteorder' \
1260 '#define HAVE_BYTE_ORDER_LITTLE' << \
!
1262 enum
{vBig
= 1, vLittle
= 0};
1263 union
{unsigned short bom
; unsigned char buf
[2];} u
;
1265 return((u.buf
[1] == 0xFE) ? vLittle
: vBig
);
1272 ## Test for "basic" system-calls / functionality that is used by all parts
1273 ## of our program. Once this is done fork away BASE_LIBS and other BASE_*
1274 ## macros to be used by only the subprograms (potentially).
1276 if run_check clock_gettime
'clock_gettime(2)' \
1277 '#define HAVE_CLOCK_GETTIME' << \
!
1283 if(!clock_gettime
(CLOCK_REALTIME
, &ts
) || errno
!= ENOSYS
)
1290 elif run_check clock_gettime
'clock_gettime(2) (via -lrt)' \
1291 '#define HAVE_CLOCK_GETTIME' '-lrt' << \
!
1297 if(!clock_gettime
(CLOCK_REALTIME
, &ts
) || errno
!= ENOSYS
)
1304 elif run_check gettimeofday
'gettimeofday(2)' \
1305 '#define HAVE_GETTIMEOFDAY' << \
!
1306 #include <stdio.h> /* For C89 NULL */
1307 #include <sys/time.h>
1312 if(!gettimeofday
(&tv
, NULL
) || errno
!= ENOSYS
)
1320 have_no_subsecond_time
=1
1323 if run_check nanosleep
'nanosleep(2)' \
1324 '#define HAVE_NANOSLEEP' << \
!
1331 ts.tv_nsec
= 100000;
1332 if(!nanosleep
(&ts
, NULL
) || errno
!= ENOSYS
)
1339 elif run_check nanosleep
'nanosleep(2) (via -lrt)' \
1340 '#define HAVE_NANOSLEEP' '-lrt' << \
!
1347 ts.tv_nsec
= 100000;
1348 if(!nanosleep
(&ts
, NULL
) || errno
!= ENOSYS
)
1355 # link_check is enough for this, that function is so old, trust the proto
1356 elif link_check
sleep 'sleep(3)' \
1357 '#define HAVE_SLEEP' << \
!
1361 if(!sleep(1) || errno
!= ENOSYS
)
1369 msg
'ERROR: we require one of nanosleep(2) and sleep(3).'
1373 if run_check userdb
'gete?[gu]id(2), getpwuid(3), getpwnam(3)' << \
!
1382 if((gid
= getgid
()) != 0)
1384 if((uid
= getuid
()) != 0)
1386 if((pw
= getpwuid
(uid
)) == NULL
&& errno
== ENOSYS
)
1388 if((pw
= getpwnam
("root")) == NULL
&& errno
== ENOSYS
)
1396 msg
'ERROR: we require user and group info / database searches.'
1397 msg
'That much Unix we indulge ourselfs.'
1401 if link_check ftruncate
'ftruncate(2)' \
1402 '#define HAVE_FTRUNCATE' << \
!
1404 #include <sys/types.h>
1406 return (ftruncate
(0, 0) != 0);
1412 msg
'ERROR: we require the ftruncate(2) system call.'
1416 if run_check sa_restart
'SA_RESTART (for sigaction(2))' << \
!
1420 struct sigaction nact
, oact
;
1422 nact.sa_handler
= SIG_DFL
;
1423 sigemptyset
(&nact.sa_mask
);
1424 nact.sa_flags
= SA_RESTART
;
1425 return !(!sigaction
(SIGCHLD
, &nact
, &oact
) || errno
!= ENOSYS
);
1431 msg
'ERROR: we (yet) require the SA_RESTART flag for sigaction(2).'
1435 if link_check snprintf
'snprintf(3)' << \
!
1440 snprintf
(b
, sizeof b
, "%s", "string");
1447 msg
'ERROR: we require the snprintf(3) function.'
1451 if link_check environ
'environ(3)' << \
!
1452 #include <stdio.h> /* For C89 NULL */
1454 extern char
**environ
;
1456 return environ
[0] == NULL
;
1462 msg
'ERROR: we require the environ(3) array for subprocess control.'
1466 if link_check setenv
'(un)?setenv(3)' '#define HAVE_SETENV' << \
!
1469 setenv
("s-mailx", "i want to see it cute!", 1);
1470 unsetenv
("s-mailx");
1476 elif link_check setenv
'putenv(3)' '#define HAVE_PUTENV' << \
!
1479 putenv
("s-mailx=i want to see it cute!");
1486 msg
'ERROR: we require either the setenv(3) or putenv(3) functions.'
1490 if link_check termios
'termios.h and tc*(3) family' << \
!
1491 #include <termios.h>
1493 struct termios tios
;
1495 tcgetattr
(0, &tios
);
1496 tcsetattr
(0, TCSANOW | TCSADRAIN | TCSAFLUSH
, &tios
);
1503 msg
'ERROR: we require termios.h and the tc*() family of functions.'
1504 msg
'That much Unix we indulge ourselfs.'
1510 if link_check vsnprintf
'vsnprintf(3)' << \
!
1513 static void dome
(char
*buf
, size_t blen
, ...
){
1517 vsnprintf
(buf
, blen
, "%s", ap
);
1523 dome
(b
, sizeof b
, "string");
1530 feat_bail_required ERRORS
1533 if [ "${have_vsnprintf}" = yes ]; then
1535 link_check va_copy
"va_copy(3) (as ${2})" \
1536 "#define HAVE_N_VA_COPY
1537 #define n_va_copy ${2}" <<_EOT
1541 # if defined __va_copy && !defined va_copy
1542 # define va_copy __va_copy
1545 static void dome2(char *buf, size_t blen, va_list src){
1549 vsnprintf(buf, blen, "%s", ap);
1552 static void dome(char *buf, size_t blen, ...){
1556 dome2(buf, blen, ap);
1562 dome(b, sizeof b, "string");
1567 __va_copy
0 va_copy || __va_copy
1 __va_copy
1570 run_check pathconf
'f?pathconf(2)' '#define HAVE_PATHCONF' << \
!
1577 rv |
= !(pathconf
(".", _PC_NAME_MAX
) >= 0 || errno
== 0 || errno
!= ENOSYS
);
1579 rv |
= !(pathconf
(".", _PC_PATH_MAX
) >= 0 || errno
== 0 || errno
!= ENOSYS
);
1581 /* Only link check
*/
1582 fpathconf
(0, _PC_NAME_MAX
);
1588 run_check pipe2
'pipe2(2)' '#define HAVE_PIPE2' << \
!
1595 if(!pipe2
(fds
, O_CLOEXEC
) || errno
!= ENOSYS
)
1601 # We use this only then for now (need NOW+1)
1602 run_check utimensat
'utimensat(2)' '#define HAVE_UTIMENSAT' << \
!
1603 #include <fcntl.h> /* For AT_* */
1604 #include <sys/stat.h>
1607 struct timespec ts
[2];
1609 ts
[0].tv_nsec
= UTIME_NOW
;
1610 ts
[1].tv_nsec
= UTIME_OMIT
;
1611 if(!utimensat
(AT_FDCWD
, "", ts
, 0) || errno
!= ENOSYS
)
1619 # XXX Add POSIX check once standardized
1620 if link_check posix_random
'arc4random(3)' '#define HAVE_POSIX_RANDOM 0' << \
!
1629 elif [ -n "${have_no_subsecond_time}" ]; then
1630 msg
'ERROR: %s %s' 'without a native random' \
1631 'one of clock_gettime(2) and gettimeofday(2) is required.'
1635 link_check putc_unlocked
'putc_unlocked(3)' '#define HAVE_PUTC_UNLOCKED' <<\
!
1638 putc_unlocked
('@', stdout
);
1643 link_check fchdir
'fchdir(3)' '#define HAVE_FCHDIR' << \
!
1651 if run_check realpath
'realpath(3)' '#define HAVE_REALPATH' << \
!
1654 char x_buf
[4096], *x
= realpath
(".", x_buf
);
1656 return (x
!= NULL
) ?
0 : 1;
1660 if run_check realpath_malloc
'realpath(3) takes NULL' \
1661 '#define HAVE_REALPATH_NULL' << \
!
1664 char
*x
= realpath
(".", NULL
);
1668 return (x
!= NULL
) ?
0 : 1;
1676 ## optional and selectable
1678 if feat_yes DOTLOCK
; then
1679 if run_check readlink
'readlink(2)' << \
!
1685 if(!readlink
("here", buf
, sizeof buf
) || errno
!= ENOSYS
)
1693 feat_bail_required DOTLOCK
1697 if feat_yes DOTLOCK
; then
1698 if run_check fchown
'fchown(2)' << \
!
1702 if(!fchown
(0, 0, 0) || errno
!= ENOSYS
)
1710 feat_bail_required DOTLOCK
1714 ## Now it is the time to fork away the BASE_ series
1717 squeeze_em
${inc} ${tmp}
1719 squeeze_em
${lib} ${tmp}
1722 echo "BASE_LIBS = `${cat} ${lib}`" >> ${mk}
1723 echo "BASE_INCS
= `${cat} ${inc}`" >> ${mk}
1725 ## The remains are expected to be used only by the main MUA binary!
1728 link_check setlocale 'setlocale(3)' '#define HAVE_SETLOCALE' << \!
1731 setlocale(LC_ALL, "");
1735 [ -n "${have_setlocale}" ] && OPT_LOCALES=1
1737 OPT_MULTIBYTE_CHARSETS=0
1739 OPT_TERMINAL_CHARSET=0
1740 if [ -n "${have_setlocale}" ]; then
1741 link_check c90amend1 'ISO/IEC 9899:1990/Amendment 1:1995' \
1742 '#define HAVE_C90AMEND1' << \!
1748 char mbb[MB_LEN_MAX + 1];
1753 mbtowc(&wc, "x", 1);
1754 mbrtowc(&wc, "x", 1, NULL);
1756 return (mblen("\0", 1) == 0);
1759 [ -n "${have_c90amend1}" ] && OPT_MULTIBYTE_CHARSETS=1
1761 if [ -n "${have_c90amend1}" ]; then
1762 link_check wcwidth 'wcwidth(3)' '#define HAVE_WCWIDTH' << \!
1769 [ -n "${have_wcwidth}" ] && OPT_WIDE_GLYPHS=1
1772 link_check nl_langinfo 'nl_langinfo(3)' '#define HAVE_NL_LANGINFO' << \!
1773 #include <langinfo.h>
1777 return (nl_langinfo(CODESET) == NULL);
1780 [ -n "${have_nl_langinfo}" ] && OPT_TERMINAL_CHARSET=1
1783 link_check fnmatch 'fnmatch(3)' '#define HAVE_FNMATCH' << \!
1784 #include <fnmatch.h>
1786 return (fnmatch("*", ".", FNM_PATHNAME | FNM_PERIOD) == FNM_NOMATCH);
1790 link_check dirent_d_type 'struct dirent.d_type' '#define HAVE_DIRENT_TYPE' << \!
1794 return !(de.d_type == DT_UNKNOWN ||
1795 de.d_type == DT_DIR || de.d_type == DT_LNK);
1799 ## optional and selectable
1801 if feat_yes ICONV; then
1802 ${cat} > ${tmp2}.c << \!
1803 #include <stdio.h> /* For C89 NULL */
1808 id = iconv_open("foo", "bar");
1809 iconv(id, NULL, NULL, NULL, NULL);
1814 < ${tmp2}.c link_check iconv 'iconv(3) functionality' \
1815 '#define HAVE_ICONV' ||
1816 < ${tmp2}.c link_check iconv 'iconv(3) functionality (via -liconv)' \
1817 '#define HAVE_ICONV' '-liconv' ||
1818 feat_bail_required ICONV
1820 echo '/* OPT_ICONV=0 */' >> ${h}
1823 if feat_yes SOCKETS || feat_yes SPAM_SPAMD; then
1824 ${cat} > ${tmp2}.c << \!
1825 #include <sys/types.h>
1826 #include <sys/socket.h>
1830 struct sockaddr_un soun;
1832 if(socket(AF_UNIX, SOCK_STREAM, 0) == -1 && errno == ENOSYS)
1834 if(connect(0, (struct sockaddr*)&soun, 0) == -1 && errno == ENOSYS)
1836 if(shutdown(0, SHUT_RD | SHUT_WR | SHUT_RDWR) == -1 && errno == ENOSYS)
1842 < ${tmp2}.c run_check af_unix 'AF_UNIX sockets' \
1843 '#define HAVE_UNIX_SOCKETS' ||
1844 < ${tmp2}.c run_check af_unix 'AF_UNIX sockets (via -lnsl)' \
1845 '#define HAVE_UNIX_SOCKETS' '-lnsl' ||
1846 < ${tmp2}.c run_check af_unix 'AF_UNIX sockets (via -lsocket -lnsl)' \
1847 '#define HAVE_UNIX_SOCKETS' '-lsocket -lnsl'
1850 if feat_yes SOCKETS; then
1851 ${cat} > ${tmp2}.c << \!
1853 #include <sys/types.h>
1854 #include <sys/socket.h>
1855 #include <netinet/in.h>
1860 if(socket(AF_INET, SOCK_STREAM, 0) == -1 && errno == ENOSYS)
1862 if(connect(0, &s, 0) == -1 && errno == ENOSYS)
1868 < ${tmp2}.c run_check sockets 'sockets' \
1869 '#define HAVE_SOCKETS' ||
1870 < ${tmp2}.c run_check sockets 'sockets (via -lnsl)' \
1871 '#define HAVE_SOCKETS' '-lnsl' ||
1872 < ${tmp2}.c run_check sockets 'sockets (via -lsocket -lnsl)' \
1873 '#define HAVE_SOCKETS' '-lsocket -lnsl' ||
1874 feat_bail_required SOCKETS
1876 echo '/* OPT_SOCKETS=0 */' >> ${h}
1877 fi # feat_yes SOCKETS
1879 if feat_yes SOCKETS; then
1880 link_check getaddrinfo 'getaddrinfo(3)' \
1881 '#define HAVE_GETADDRINFO' << \!
1883 #include <sys/types.h>
1884 #include <sys/socket.h>
1888 struct addrinfo a, *ap;
1891 switch((lrv = getaddrinfo("foo", "0", &a, &ap))){
1895 fprintf(stderr, "%s\n", gai_strerror(lrv));
1904 if feat_yes SOCKETS && [ -z "${have_getaddrinfo}" ]; then
1905 compile_check arpa_inet_h '<arpa/inet.h>' \
1906 '#define HAVE_ARPA_INET_H' << \!
1908 #include <sys/types.h>
1909 #include <sys/socket.h>
1911 #include <netinet/in.h>
1912 #include <arpa/inet.h>
1915 ${cat} > ${tmp2}.c << \!
1917 #include <sys/types.h>
1918 #include <sys/socket.h>
1922 #include <netinet/in.h>
1923 #ifdef HAVE_ARPA_INET_H
1924 #include <arpa/inet.h>
1927 struct sockaddr_in servaddr;
1928 unsigned short portno;
1931 struct in_addr **pptr;
1934 if((ep = getservbyname("POPPY-PORT", "tcp")) != NULL)
1935 portno = (unsigned short)ep->s_port;
1937 if((hp = gethostbyname("POPPY-HOST")) != NULL){
1938 pptr = (struct in_addr**)hp->h_addr_list;
1939 if(hp->h_addrtype != AF_INET)
1940 fprintf(stderr, "au\n");
1943 case HOST_NOT_FOUND:
1949 fprintf(stderr, "au\n");
1954 memset(&servaddr, 0, sizeof servaddr);
1955 servaddr.sin_family = AF_INET;
1956 servaddr.sin_port = htons(portno);
1957 memcpy(&servaddr.sin_addr, *pptr, sizeof(struct in_addr));
1958 fprintf(stderr, "Would connect to %s:%d ...\n",
1959 inet_ntoa(**pptr), (int)portno);
1964 < ${tmp2}.c link_check gethostbyname 'get(serv|host)byname(3)' ||
1965 < ${tmp2}.c link_check gethostbyname \
1966 'get(serv|host)byname(3) (via -nsl)' '' '-lnsl' ||
1967 < ${tmp2}.c link_check gethostbyname \
1968 'get(serv|host)byname(3) (via -lsocket -nsl)' \
1969 '' '-lsocket -lnsl' ||
1970 feat_bail_required SOCKETS
1974 run_check setsockopt 'setsockopt(2)' '#define HAVE_SETSOCKOPT' << \!
1975 #include <sys/socket.h>
1981 if(setsockopt(sockfd, SOL_SOCKET, SO_KEEPALIVE, NULL, 0) == -1 &&
1988 feat_yes SOCKETS && [ -n "${have_setsockopt}" ] &&
1989 link_check so_sndtimeo 'SO_SNDTIMEO' '#define HAVE_SO_SNDTIMEO' << \!
1990 #include <sys/socket.h>
1998 setsockopt(sockfd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof tv);
1999 setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof tv);
2004 feat_yes SOCKETS && [ -n "${have_setsockopt}" ] &&
2005 link_check so_linger 'SO_LINGER' '#define HAVE_SO_LINGER' << \!
2006 #include <sys/socket.h>
2014 setsockopt(sockfd, SOL_SOCKET, SO_LINGER, &li, sizeof li);
2019 if feat_yes SSL; then # {{{
2020 # {{{ LibreSSL decided to define OPENSSL_VERSION_NUMBER with a useless value
2021 # instead of keeping it at the one that corresponds to the OpenSSL at fork
2022 # time: we need to test it first in order to get things right
2023 if compile_check _xssl 'TLS/SSL (LibreSSL)' \
2026 #define HAVE_XSSL_RESSL
2027 #define HAVE_XSSL_OPENSSL 0' << \!
2028 #include <openssl/opensslv.h>
2029 #ifdef LIBRESSL_VERSION_NUMBER
2036 # TODO OPENSSL_IS_BORINGSSL, but never tried that one!
2037 elif compile_check _xssl 'TLS/SSL (OpenSSL >= v1.1.0)' \
2040 #define HAVE_XSSL_OPENSSL 0x10100' << \!
2041 #include <openssl/opensslv.h>
2042 #if OPENSSL_VERSION_NUMBER + 0 >= 0x10100000L
2049 elif compile_check _xssl 'TLS/SSL (OpenSSL)' \
2052 #define HAVE_XSSL_OPENSSL 0x10000 /* pseudo */' << \!
2053 #include <openssl/opensslv.h>
2054 #ifdef OPENSSL_VERSION_NUMBER
2062 feat_bail_required SSL
2065 if feat_yes SSL; then # {{{
2066 if [ -n "${ossl_v1_1}" ]; then
2067 without_check yes xssl 'TLS/SSL (new style *_client_method(3ssl))' \
2068 '#define n_XSSL_CLIENT_METHOD TLS_client_method' \
2070 elif link_check xssl 'TLS/SSL (new style *_client_method(3ssl))' \
2071 '#define n_XSSL_CLIENT_METHOD TLS_client_method' \
2072 '-lssl -lcrypto' << \!
2073 #include <openssl/ssl.h>
2074 #include <openssl/err.h>
2075 #include <openssl/x509v3.h>
2076 #include <openssl/x509.h>
2077 #include <openssl/rand.h>
2078 #ifdef OPENSSL_NO_TLS1 /* TODO only deduced from OPENSSL_NO_SSL[23]! */
2079 # error We need TLSv1.
2082 SSL_CTX *ctx = SSL_CTX_new(TLS_client_method());
2085 PEM_read_PrivateKey(0, 0, 0, 0);
2091 elif link_check xssl 'TLS/SSL (old style *_client_method(3ssl))' \
2092 '#define n_XSSL_CLIENT_METHOD SSLv23_client_method' \
2093 '-lssl -lcrypto' << \!
2094 #include <openssl/ssl.h>
2095 #include <openssl/err.h>
2096 #include <openssl/x509v3.h>
2097 #include <openssl/x509.h>
2098 #include <openssl/rand.h>
2099 #if defined OPENSSL_NO_SSL3 &&\
2100 defined OPENSSL_NO_TLS1 /* TODO only deduced from OPENSSL_NO_SSL[23]! */
2101 # error We need one of SSLv3 and TLSv1.
2104 SSL_CTX *ctx = SSL_CTX_new(SSLv23_client_method());
2107 PEM_read_PrivateKey(0, 0, 0, 0);
2114 feat_bail_required SSL
2118 if feat_yes SSL; then # {{{
2119 if [ -n "${ossl_v1_1}" ]; then
2120 without_check yes xssl_stack_of 'TLS/SSL STACK_OF()' \
2121 '#define HAVE_XSSL_STACK_OF'
2122 elif compile_check xssl_stack_of 'TLS/SSL STACK_OF()' \
2123 '#define HAVE_XSSL_STACK_OF' << \!
2124 #include <stdio.h> /* For C89 NULL */
2125 #include <openssl/ssl.h>
2126 #include <openssl/err.h>
2127 #include <openssl/x509v3.h>
2128 #include <openssl/x509.h>
2129 #include <openssl/rand.h>
2131 STACK_OF(GENERAL_NAME) *gens = NULL;
2133 printf("%p", gens); /* to use it */
2141 if [ -n "${ossl_v1_1}" ]; then
2142 without_check yes xssl_conf 'TLS/SSL OpenSSL_modules_load_file()' \
2143 '#define HAVE_XSSL_CONFIG'
2144 elif link_check xssl_conf 'TLS/SSL OpenSSL_modules_load_file() support' \
2145 '#define HAVE_XSSL_CONFIG' << \!
2146 #include <stdio.h> /* For C89 NULL */
2147 #include <openssl/conf.h>
2149 CONF_modules_load_file(NULL, NULL, CONF_MFLAGS_IGNORE_MISSING_FILE);
2150 CONF_modules_free();
2158 if [ -n "${ossl_v1_1}" ]; then
2159 without_check yes xssl_conf_ctx 'TLS/SSL SSL_CONF_CTX support' \
2160 '#define HAVE_XSSL_CONF_CTX'
2161 elif link_check xssl_conf_ctx 'TLS/SSL SSL_CONF_CTX support' \
2162 '#define HAVE_XSSL_CONF_CTX' << \!
2164 #include <openssl/ssl.h>
2165 #include <openssl/err.h>
2167 SSL_CTX *ctx = SSL_CTX_new(n_XSSL_CLIENT_METHOD());
2168 SSL_CONF_CTX *cctx = SSL_CONF_CTX_new();
2170 SSL_CONF_CTX_set_flags(cctx,
2171 SSL_CONF_FLAG_FILE | SSL_CONF_FLAG_CLIENT |
2172 SSL_CONF_FLAG_CERTIFICATE | SSL_CONF_FLAG_SHOW_ERRORS);
2173 SSL_CONF_CTX_set_ssl_ctx(cctx, ctx);
2174 SSL_CONF_cmd(cctx, "Protocol", "ALL");
2175 SSL_CONF_CTX_finish(cctx);
2176 SSL_CONF_CTX_free(cctx);
2185 if [ -n "${ossl_v1_1}" ]; then
2186 without_check no xssl_rand_egd 'TLS/SSL RAND_egd(3ssl)' \
2187 '#define HAVE_XSSL_RAND_EGD'
2188 elif link_check xssl_rand_egd 'TLS/SSL RAND_egd(3ssl)' \
2189 '#define HAVE_XSSL_RAND_EGD' << \!
2190 #include <openssl/rand.h>
2192 return RAND_egd("some.where") > 0;
2199 if feat_yes SSL_ALL_ALGORITHMS; then
2200 if [ -n "${ossl_v1_1}" ]; then
2201 without_check yes ssl_all_algo 'TLS/SSL all-algorithms support' \
2202 '#define HAVE_SSL_ALL_ALGORITHMS'
2203 elif link_check ssl_all_algo 'TLS/SSL all-algorithms support' \
2204 '#define HAVE_SSL_ALL_ALGORITHMS' << \!
2205 #include <openssl/evp.h>
2207 OpenSSL_add_all_algorithms();
2208 EVP_get_cipherbyname("two cents i never exist");
2216 feat_bail_required SSL_ALL_ALGORITHMS
2219 fi # feat_yes SSL }}}
2221 if feat_yes SSL && feat_yes MD5 && feat_no NOEXTMD5; then # {{{
2222 run_check ssl_md5 'MD5 digest in the used crypto library' \
2223 '#define HAVE_XSSL_MD5' << \!
2226 #include <openssl/md5.h>
2228 char const dat[] = "abrakadabrafidibus";
2229 char dig[16], hex[16 * 2];
2233 memset(dig, 0, sizeof(dig));
2234 memset(hex, 0, sizeof(hex));
2236 MD5_Update(&ctx, dat, sizeof(dat) - 1);
2237 MD5_Final(dig, &ctx);
2239 #define hexchar(n) ((n) > 9 ? (n) - 10 + 'a' : (n) + '0')
2240 for(i = 0; i < sizeof(hex) / 2; i++){
2242 hex[j] = hexchar((dig[i] & 0xf0) >> 4);
2243 hex[++j] = hexchar(dig[i] & 0x0f);
2245 return !!memcmp("6d7d0a3d949da2e96f2aa010f65d8326", hex, sizeof(hex));
2250 echo '/* OPT_SSL=0 */' >> ${h}
2251 fi # }}} feat_yes SSL
2253 if [ "${have_xssl}" = yes ]; then
2259 if feat_yes SMTP; then
2260 echo '#define HAVE_SMTP' >> ${h}
2262 echo '/* OPT_SMTP=0 */' >> ${h}
2265 if feat_yes POP3; then
2266 echo '#define HAVE_POP3' >> ${h}
2268 echo '/* OPT_POP3=0 */' >> ${h}
2271 if feat_yes GSSAPI; then
2272 ${cat} > ${tmp2}.c << \!
2273 #include <gssapi/gssapi.h>
2275 gss_import_name(0, 0, GSS_C_NT_HOSTBASED_SERVICE, 0);
2276 gss_init_sec_context(0,0,0,0,0,0,0,0,0,0,0,0,0);
2280 ${sed} -e '1s/gssapi\///' < ${tmp2}.c > ${tmp3}.c
2282 if command -v krb5-config >/dev/null 2>&1; then
2283 i=`command -v krb5-config
`
2284 GSS_LIBS="`CFLAGS
= ${i} --libs gssapi
`"
2285 GSS_INCS="`CFLAGS
= ${i} --cflags`"
2286 i='GSS-API via krb5-config(1)'
2290 i='GSS-API in gssapi/gssapi.h, libgssapi'
2292 if < ${tmp2}.c link_check gss \
2293 "${i}" '#define HAVE_GSSAPI' "${GSS_LIBS}" "${GSS_INCS}" ||\
2294 < ${tmp3}.c link_check gss \
2295 'GSS-API in gssapi.h, libgssapi' \
2296 '#define HAVE_GSSAPI
2297 #define GSSAPI_REG_INCLUDE' \
2299 < ${tmp2}.c link_check gss 'GSS-API in libgssapi_krb5' \
2300 '#define HAVE_GSSAPI' \
2302 < ${tmp3}.c link_check gss \
2303 'GSS-API in libgssapi, OpenBSD-style (pre 5.3)' \
2304 '#define HAVE_GSSAPI
2305 #define GSS_REG_INCLUDE' \
2306 '-lgssapi -lkrb5 -lcrypto' \
2307 '-I/usr/include/kerberosV' ||\
2308 < ${tmp2}.c link_check gss 'GSS-API in libgss' \
2309 '#define HAVE_GSSAPI' \
2311 link_check gss 'GSS-API in libgssapi_krb5, old-style' \
2312 '#define HAVE_GSSAPI
2313 #define GSSAPI_OLD_STYLE' \
2314 '-lgssapi_krb5' << \!
2315 #include <gssapi/gssapi.h>
2316 #include <gssapi/gssapi_generic.h>
2318 gss_import_name(0, 0, gss_nt_service_name, 0);
2319 gss_init_sec_context(0,0,0,0,0,0,0,0,0,0,0,0,0);
2326 feat_bail_required GSSAPI
2329 echo '/* OPT_GSSAPI=0 */' >> ${h}
2330 fi # feat_yes GSSAPI
2332 if feat_yes NETRC; then
2333 echo '#define HAVE_NETRC' >> ${h}
2335 echo '/* OPT_NETRC=0 */' >> ${h}
2338 if feat_yes AGENT; then
2339 echo '#define HAVE_AGENT' >> ${h}
2341 echo '/* OPT_AGENT=0 */' >> ${h}
2344 if feat_yes IDNA; then
2345 if link_check idna 'GNU Libidn' '#define HAVE_IDNA HAVE_IDNA_LIBIDNA' \
2348 #include <idn-free.h>
2349 #include <stringprep.h>
2351 char *utf8, *idna_ascii, *idna_utf8;
2353 utf8 = stringprep_locale_to_utf8("does.this.work");
2354 if (idna_to_ascii_8z(utf8, &idna_ascii, IDNA_USE_STD3_ASCII_RULES)
2357 idn_free(idna_ascii);
2358 /* (Rather link check only here) */
2359 idna_utf8 = stringprep_convert(idna_ascii, "UTF-8", "de_DE");
2365 elif link_check idna 'idnkit' '#define HAVE_IDNA HAVE_IDNA_IDNKIT' \
2368 #include <idn/api.h>
2369 #include <idn/result.h>
2373 char local_name[256];
2375 r = idn_encodename(IDN_ENCODE_APP, "does.this.work", ace_name,
2377 if (r != idn_success) {
2378 fprintf(stderr, "idn_encodename failed: %s\n", idn_result_tostring(r));
2381 r = idn_decodename(IDN_DECODE_APP, ace_name, local_name, sizeof(local_name));
2382 if (r != idn_success) {
2383 fprintf(stderr, "idn_decodename failed: %s\n", idn_result_tostring(r));
2392 feat_bail_required IDNA
2395 if [ -n "${have_idna}" ]; then
2396 echo '#define HAVE_IDNA_LIBIDNA 0' >> ${h}
2397 echo '#define HAVE_IDNA_IDNKIT 1' >> ${h}
2400 echo '/* OPT_IDNA=0 */' >> ${h}
2403 if feat_yes IMAP_SEARCH; then
2404 echo '#define HAVE_IMAP_SEARCH' >> ${h}
2406 echo '/* OPT_IMAP_SEARCH=0 */' >> ${h}
2409 if feat_yes REGEX; then
2410 if link_check regex 'regular expressions' '#define HAVE_REGEX' << \!
2417 if (regcomp(&re, ".*bsd", REG_EXTENDED | REG_ICASE | REG_NOSUB) != 0)
2419 status = regexec(&re, "plan9", 0,NULL, 0);
2421 return !(status == REG_NOMATCH);
2427 feat_bail_required REGEX
2430 echo '/* OPT_REGEX=0 */' >> ${h}
2433 if feat_yes MLE && [ -n "${have_c90amend1}" ]; then
2435 echo '#define HAVE_MLE' >> ${h}
2437 feat_bail_required MLE
2438 echo '/* OPT_MLE=0 */' >> ${h}
2441 # Generic have-a-line-editor switch for those who need it below
2442 if [ -n "${have_mle}" ]; then
2446 if [ -n "${have_cle}" ] && feat_yes HISTORY; then
2447 echo '#define HAVE_HISTORY' >> ${h}
2449 echo '/* OPT_HISTORY=0 */' >> ${h}
2452 if [ -n "${have_mle}" ] && feat_yes KEY_BINDINGS; then
2453 echo '#define HAVE_KEY_BINDINGS' >> ${h}
2455 echo '/* OPT_KEY_BINDINGS=0 */' >> ${h}
2458 if feat_yes TERMCAP; then
2460 link_check termcap "termcap(5) (via ${4})" \
2461 "#define HAVE_TERMCAP${3}" "${1}" << _EOT
2466 #define UNCONST(P) ((void*)(unsigned long)(void const*)(P))
2467 static int my_putc(int c){return putchar(c);}
2469 char buf[1024+512], cmdbuf[2048], *cpb, *r1;
2470 int r2 = OK, r3 = ERR;
2472 tgetent(buf, getenv("TERM"));
2474 r1 = tgetstr(UNCONST("cm"), &cpb);
2476 r2 = tgetnum(UNCONST("Co"));
2477 r3 = tgetflag(UNCONST("ut"));
2478 tputs("cr", 1, &my_putc);
2479 return (r1 == NULL || r2 == -1 || r3 == 0);
2485 link_check terminfo "terminfo(5) (via ${2})" \
2486 '#define HAVE_TERMCAP
2487 #define HAVE_TERMCAP_CURSES
2488 #define HAVE_TERMINFO' "${1}" << _EOT
2492 #define UNCONST(P) ((void*)(unsigned long)(void const*)(P))
2493 static int my_putc(int c){return putchar(c);}
2499 r0 = setupterm(NULL, 1, &er);
2500 r1 = tigetflag(UNCONST("bce"));
2501 r2 = tigetnum(UNCONST("colors"));
2502 r3 = tigetstr(UNCONST("cr"));
2503 tp = tparm(r3, NULL, NULL, 0,0,0,0,0,0,0);
2504 tputs(tp, 1, &my_putc);
2505 return (r0 == ERR || r1 == -1 || r2 == -2 || r2 == -1 ||
2506 r3 == (char*)-1 || r3 == NULL);
2511 if feat_yes TERMCAP_VIA_TERMINFO; then
2512 __terminfolib -ltinfo -ltinfo ||
2513 __terminfolib -lcurses -lcurses ||
2514 __terminfolib -lcursesw -lcursesw ||
2515 feat_bail_required TERMCAP_VIA_TERMINFO
2518 if [ -z "${have_terminfo}" ]; then
2519 __termcaplib -ltermcap '' '' '-ltermcap' ||
2520 __termcaplib -ltermcap '#include <curses.h>' '
2521 #define HAVE_TERMCAP_CURSES' \
2522 'curses.h / -ltermcap' ||
2523 __termcaplib -lcurses '#include <curses.h>' '
2524 #define HAVE_TERMCAP_CURSES' \
2525 'curses.h / -lcurses' ||
2526 __termcaplib -lcursesw '#include <curses.h>' '
2527 #define HAVE_TERMCAP_CURSES' \
2528 'curses.h / -lcursesw' ||
2529 feat_bail_required TERMCAP
2531 if [ -n "${have_termcap}" ]; then
2532 run_check tgetent_null \
2533 "tgetent(3) of termcap(5) takes NULL buffer" \
2534 "#define HAVE_TGETENT_NULL_BUF" << _EOT
2535 #include <stdio.h> /* For C89 NULL */
2537 #ifdef HAVE_TERMCAP_CURSES
2538 # include <curses.h>
2542 tgetent(NULL, getenv("TERM"));
2549 echo '/* OPT_TERMCAP=0 */' >> ${h}
2550 echo '/* OPT_TERMCAP_VIA_TERMINFO=0 */' >> ${h}
2553 if feat_yes SPAM_SPAMC; then
2554 echo '#define HAVE_SPAM_SPAMC' >> ${h}
2555 if command -v spamc >/dev/null 2>&1; then
2556 echo "#define SPAM_SPAMC_PATH \"`command -v spamc
`\"" >> ${h}
2559 echo '/* OPT_SPAM_SPAMC=0 */' >> ${h}
2562 if feat_yes SPAM_SPAMD && [ -n "${have_af_unix}" ]; then
2563 echo '#define HAVE_SPAM_SPAMD' >> ${h}
2565 feat_bail_required SPAM_SPAMD
2566 echo '/* OPT_SPAM_SPAMD=0 */' >> ${h}
2569 feat_def SPAM_FILTER
2571 if feat_yes SPAM_SPAMC || feat_yes SPAM_SPAMD || feat_yes SPAM_FILTER; then
2572 echo '#define HAVE_SPAM' >> ${h}
2574 echo '/* HAVE_SPAM */' >> ${h}
2577 if feat_yes QUOTE_FOLD &&\
2578 [ -n "${have_c90amend1}" ] && [ -n "${have_wcwidth}" ]; then
2579 echo '#define HAVE_QUOTE_FOLD' >> ${h}
2581 feat_bail_required QUOTE_FOLD
2582 echo '/* OPT_QUOTE_FOLD=0 */' >> ${h}
2585 feat_def FILTER_HTML_TAGSOUP
2594 squeeze_em ${inc} ${tmp}
2596 squeeze_em ${lib} ${tmp}
2601 printf '#ifndef n_CONFIG_H\n# define n_CONFIG_H 1\n' > ${h}
2602 ${cat} ${tmp} >> ${h}
2606 # Create the real mk.mk
2607 # Note we cannout use explicit ./ filename prefix for source and object
2608 # pathnames because of a bug in bmake(1)
2609 ${rm} -rf ${tmp0}.* ${tmp0}*
2610 printf 'OBJ_SRC = ' >> ${mk}
2611 if feat_no AMALGAMATION; then
2612 for i in `printf '%s\n' *.c |
${sort}`; do
2613 if [ "${i}" = privsep.c ]; then
2616 printf "${i} " >> ${mk}
2618 printf '\nAMALGAM_TARGET =\nAMALGAM_DEP =\n' >> ${mk}
2620 printf 'main.c\nAMALGAM_TARGET = main.o\nAMALGAM_DEP = ' >> ${mk}
2622 printf '\n/* HAVE_AMALGAMATION: include sources */\n' >> ${h}
2623 printf '#elif _CONFIG_H + 0 == 1\n' >> ${h}
2624 printf '# undef _CONFIG_H\n' >> ${h}
2625 printf '# define _CONFIG_H 2\n' >> ${h}
2626 for i in `printf '%s\n' *.c |
${sort}`; do
2627 if [ "${i}" = "${j}" ] || [ "${i}" = main.c ] || \
2628 [ "${i}" = privsep.c ]; then
2631 printf "${i} " >> ${mk}
2632 printf "# include \"${i}\"\n" >> ${h}
2635 # tcc(1) fails on 2015-11-13 unless this #else clause existed
2636 echo '#else' >> ${h}
2639 # Finally, create the string that is used by *features* and `version
'.
2640 # Take this nice opportunity and generate a visual listing of included and
2641 # non-included features for the person who runs the configuration
2642 msg '\nThe following features are included
(+) or not
(-):'
2643 set -- ${OPTIONS_DETECT} ${OPTIONS} ${OPTIONS_XTRA}
2644 printf '/* The
"feature string" */\n' >> ${h}
2645 # Because + is expanded by *folder* if first in "echo $features", put something
2646 printf '#define VAL_FEATURES_CNT '${#}'\n#define VAL_FEATURES "#' >> ${h}
2650 sopt
="`echo ${opt} | ${tr} '[A-Z]_' '[a-z]-'`"
2651 feat_yes
${opt} && sign
=+ || sign
=-
2652 printf -- "${sep}${sign}${sopt}" >> ${h}
2654 i=`option_doc_of ${opt}`
2655 [ -z "${i}" ] && continue
2656 msg " %s
%s
: %s
" ${sign} ${sopt} "${i}"
2658 # TODO instead of using sh+tr+awk+printf, use awk, drop option_doc_of, inc here
2660 #${awk} -v opts="${OPTIONS_DETECT} ${OPTIONS} ${OPTIONS_XTRA}" \
2661 # -v xopts="${XOPTIONS_DETECT} ${XOPTIONS} ${XOPTIONS_XTRA}" \
2663 printf '"\n#endif /* n_CONFIG_H */\n' >> ${h}
2665 echo "LIBS = `${cat} ${lib}`" >> ${mk}
2666 echo "INCS
= `${cat} ${inc}`" >> ${mk}
2668 ${cat} ./mk-mk.in >> ${mk}
2673 msg ' . System-wide resource file: %s/%s' "${VAL_SYSCONFDIR}" "${VAL_SYSCONFRC}"
2674 msg ' . bindir: %s' "${VAL_BINDIR}"
2675 if feat_yes DOTLOCK; then
2676 msg ' . libexecdir: %s' "${VAL_LIBEXECDIR}"
2678 msg ' . mandir: %s' "${VAL_MANDIR}"
2679 msg ' . M(ail)T(ransfer)A(gent): %s (argv0 %s)' "${VAL_MTA}" "${VAL_MTA_ARGV0}"
2680 msg ' . $MAIL spool directory: %s' "${VAL_MAIL}"
2683 if [ -n "${have_fnmatch}" ] && [ -n "${have_fchdir}" ]; then
2687 if [ -z "${have_fnmatch}" ]; then
2688 msg ' . The function fnmatch(3) could not be found.'
2689 msg ' Filename patterns like wildcard are not supported on your system'
2691 if [ -z "${have_fchdir}" ]; then
2692 msg ' . The function fchdir(2) could not be found.'
2693 msg ' We will use chdir(2) instead.'
2694 msg ' This is a problem only if the current working directory is changed'
2695 msg ' while this program is inside of it'