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 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_no TERMCAP
; then
186 OPT_TERMCAP_VIA_TERMINFO
=0
189 if feat_yes DEVEL
; then
197 h
=.
/mk-config.h h_name
=mk-config.h
200 newlst
=.
/mk-nconfig.lst
201 newmk
=.
/mk-nconfig.mk
202 newev
=.
/mk-nconfig.ev
208 ## -- >8 - << OPTIONS | OS/CC >> - 8< -- ##
210 # Note that potential duplicates in PATH, C_INCLUDE_PATH etc. will be cleaned
211 # via path_check() later on once possible
213 # TODO cc_maxopt is brute simple, we should compile test program and dig real
214 # compiler versions for known compilers, then be more specific
219 # We don't "have any utility": only path adjustments and such in here!
220 i
="${OS:-`uname -s`}"
222 if [ ${i} = SunOS
]; then
223 msg
'SunOS / Solaris? Applying some "early setup" rules ...'
224 _os_early_setup_sunos
228 _os_early_setup_sunos
() {
229 # According to standards(5), this is what we need to do
230 if [ -d /usr
/xpg4
]; then :; else
231 msg
'ERROR: On SunOS / Solaris we need /usr/xpg4 environment! Sorry.'
234 PATH
="/usr/xpg4/bin:/usr/ccs/bin:/usr/bin:${PATH}"
235 [ -d /usr
/xpg6
] && PATH
="/usr/xpg6/bin:${PATH}"
240 # OSENV ends up in *build-osenv*
241 # OSFULLSPEC is used to recognize changes (i.e., machine type, updates etc.)
242 : ${OS:=`uname -s | ${tr} '[A-Z]' '[a-z]'`}
243 : ${OSENV:=`uname -srm`}
244 : ${OSFULLSPEC:=`uname -a`}
245 msg
'Operating system is %s' ${OS}
247 if [ ${OS} = sunos
]; then
248 msg
' . have special SunOS / Solaris "setup" rules ...'
250 elif [ ${OS} = unixware
]; then
251 msg
' . have special UnixWare environmental rules ...'
252 if feat_yes AUTOCC
&& command -v cc
>/dev
/null
2>&1; then
254 feat_yes DEBUG
&& _CFLAGS
='-v -Xa -g' || _CFLAGS
='-Xa -O'
256 CFLAGS
="${_CFLAGS} ${EXTRA_CFLAGS}"
257 LDFLAGS
="${_LDFLAGS} ${EXTRA_LDFLAGS}"
258 export CC CFLAGS LDFLAGS
259 OPT_AUTOCC
=0 had_want_autocc
=1 need_R_ldflags
=-R
261 elif [ -n "${VERBOSE}" ]; then
262 msg
' . no special treatment for this system necessary or known'
265 # Sledgehammer: better set _GNU_SOURCE
266 # And in general: oh, boy!
267 OS_DEFINES
="${OS_DEFINES}#define _GNU_SOURCE\n"
268 #OS_DEFINES="${OS_DEFINES}#define _POSIX_C_SOURCE 200809L\n"
269 #OS_DEFINES="${OS_DEFINES}#define _XOPEN_SOURCE 700\n"
270 #[ ${OS} = darwin ] && OS_DEFINES="${OS_DEFINES}#define _DARWIN_C_SOURCE\n"
272 # On pkgsrc(7) systems automatically add /usr/pkg/*
273 if [ -d /usr
/pkg
]; then
274 C_INCLUDE_PATH
="${C_INCLUDE_PATH}:/usr/pkg/include"
275 LD_LIBRARY_PATH
="${LD_LIBRARY_PATH}:/usr/pkg/lib"
280 C_INCLUDE_PATH
="/usr/xpg4/include:${C_INCLUDE_PATH}"
281 LD_LIBRARY_PATH
="/usr/xpg4/lib:${LD_LIBRARY_PATH}"
284 if [ -d /opt
/csw
]; then
285 C_INCLUDE_PATH
="${C_INCLUDE_PATH}:/opt/csw/include"
286 LD_LIBRARY_PATH
="${LD_LIBRARY_PATH}:/opt/csw/lib"
289 OS_DEFINES
="${OS_DEFINES}#define __EXTENSIONS__\n"
290 #OS_DEFINES="${OS_DEFINES}#define _POSIX_C_SOURCE 200112L\n"
292 [ -n "${cksum}" ] ||
cksum=/opt
/csw
/gnu
/cksum
293 if [ -x "${cksum}" ]; then :; else
294 msg
'ERROR: Not an executable program: %s' "${cksum}"
295 msg
'ERROR: We need a CRC-32 cksum(1), as specified in POSIX.'
296 msg
'ERROR: However, we do so only for tests.'
297 msg
'ERROR: If that is ok, set "cksum=/usr/bin/true", then rerun'
301 if feat_yes AUTOCC
; then
302 if command -v cc
>/dev
/null
2>&1; then
304 feat_yes DEBUG
&& _CFLAGS
="-v -Xa -g" || _CFLAGS
="-Xa -O"
306 CFLAGS
="${_CFLAGS} ${EXTRA_CFLAGS}"
307 LDFLAGS
="${_LDFLAGS} ${EXTRA_LDFLAGS}"
308 export CC CFLAGS LDFLAGS
309 OPT_AUTOCC
=0 had_want_autocc
=1 need_R_ldflags
=-R
311 # Assume gcc(1), which supports -R for compat
312 cc_maxopt
=2 force_no_stackprot
=1 need_R_ldflags
=-Wl,-R
317 # Check out compiler ($CC) and -flags ($CFLAGS)
319 # Even though it belongs into cc_flags we will try to compile and link
320 # something, so ensure we have a clean state regarding CFLAGS/LDFLAGS or
321 # EXTRA_CFLAGS/EXTRA_LDFLAGS
322 if feat_no AUTOCC
; then
324 # Ensure those don't do any harm
325 EXTRA_CFLAGS
= EXTRA_LDFLAGS
=
326 export EXTRA_CFLAGS EXTRA_LDFLAGS
330 export CFLAGS LDFLAGS
333 [ -n "${CC}" ] && [ "${CC}" != cc ] && { _cc_default; return; }
335 msg_nonl 'Searching for a usable C compiler .. $CC='
336 if { i="`command -v clang`"; }; then
338 elif { i="`command -v gcc`"; }; then
340 elif { i="`command -v c99`"; }; then
342 elif { i="`command -v tcc`"; }; then
344 elif { i="`command -v pcc`"; }; then
347 if [ "${CC}" = cc ]; then
349 elif { i="`command -v c89`"; }; then
352 msg 'boing booom tschak'
353 msg 'ERROR: I cannot find a compiler!'
354 msg ' Neither of clang(1), gcc(1), tcc(1), pcc(1), c89(1) and c99(1).'
355 msg ' Please set ${CC} environment variable, maybe ${CFLAGS}, rerun.'
364 if [ -z "${CC}" ]; then
365 msg 'To go on like you have chosen, please set $CC, rerun.'
369 if [ -z "${VERBOSE}" ] && [ -f ${lst} ] && feat_no DEBUG; then
372 msg 'Using C compiler ${CC}=%s' "${CC}"
377 if feat_yes AUTOCC; then
378 if [ -f ${lst} ] && feat_no DEBUG && [ -z "${VERBOSE}" ]; then
380 msg 'Detecting ${CFLAGS}/${LDFLAGS} for ${CC}=%s, just a second..' \
384 msg 'Testing usable ${CFLAGS}/${LDFLAGS} for ${CC}=%s' "${CC}"
387 i
=`echo "${CC}" | ${awk} 'BEGIN{FS="/"}{print $NF}'`
388 if { echo "${i}" | ${grep} tcc; } >/dev/null 2>&1; then
389 msg ' . have special tcc(1) environmental rules ...'
392 # As of pcc CVS 2016-04-02, stack protection support is announced but
393 # will break if used on Linux
394 if { echo "${i}" | ${grep} pcc; } >/dev
/null
2>&1; then
400 feat_no DEBUG
&& _CFLAGS
="-DNDEBUG ${_CFLAGS}"
401 CFLAGS
="${_CFLAGS} ${EXTRA_CFLAGS}"
402 LDFLAGS
="${_LDFLAGS} ${EXTRA_LDFLAGS}"
404 if feat_no DEBUG
; then
405 CFLAGS
="-DNDEBUG ${CFLAGS}"
409 export CFLAGS LDFLAGS
413 __cflags
=${_CFLAGS} __ldflags
=${_LDFLAGS}
420 if feat_yes DEBUG
; then
421 # May have problems to find libtcc cc_check -b
425 if ld_check
-Wl,-rpath =.
/ no
; then
426 need_R_ldflags
=-Wl,-rpath=
427 ld_check
-Wl,--enable-new-dtags
428 ld_runtime_flags
# update!
431 _CFLAGS
="${_CFLAGS} ${__cflags}" _LDFLAGS="${_LDFLAGS} ${__ldflags}"
432 unset __cflags __ldflags
435 _cc_flags_generic
() {
436 __cflags
=${_CFLAGS} __ldflags
=${_LDFLAGS}
438 feat_yes DEVEL
&& cc_check
-std=c89 || cc_check
-std=c99
440 # Check -g first since some others may rely upon -g / optim. level
441 if feat_yes DEBUG
; then
444 elif [ ${cc_maxopt} -gt 2 ] && cc_check
-O3; then
446 elif [ ${cc_maxopt} -gt 1 ] && cc_check
-O2; then
448 elif [ ${cc_maxopt} -gt 0 ] && cc_check
-O1; then
454 if feat_yes AMALGAMATION
; then
458 #if feat_yes DEVEL && cc_check -Weverything; then
463 cc_check
-Wbad-function-cast
464 cc_check
-Wcast-align
467 cc_check
-Wmissing-prototypes
470 cc_check
-Wwrite-strings
471 cc_check
-Wno-long-long
475 if feat_yes AMALGAMATION
&& feat_no DEVEL
; then
476 cc_check
-Wno-unused-function
478 feat_no DEVEL
&& cc_check
-Wno-unused-result # XXX do right way (pragma too)
480 cc_check
-fno-unwind-tables
481 cc_check
-fno-asynchronous-unwind-tables
482 cc_check
-fstrict-aliasing
483 if cc_check
-fstrict-overflow && feat_yes DEVEL
; then
484 cc_check
-Wstrict-overflow=5
487 if feat_yes DEBUG || feat_yes FORCED_STACKPROT
; then
488 if [ -z "${force_no_stackprot}" ]; then
489 if cc_check
-fstack-protector-strong ||
490 cc_check
-fstack-protector-all; then
491 cc_check
-D_FORTIFY_SOURCE=2
494 msg
'Not checking for -fstack-protector compiler option,'
495 msg
'since that caused errors in a "similar" configuration.'
496 msg
'You may turn off OPT_AUTOCC and use your own settings, rerun'
500 # LD (+ dependend CC)
502 if feat_yes ASAN_ADDRESS
; then
504 if cc_check
-fsanitize=address
&&
505 ld_check
-fsanitize=address
; then
508 feat_bail_required ASAN_ADDRESS
513 if feat_yes ASAN_MEMORY
; then
515 if cc_check
-fsanitize=memory
&&
516 ld_check
-fsanitize=memory
&&
517 cc_check
-fsanitize-memory-track-origins=2 &&
518 ld_check
-fsanitize-memory-track-origins=2; then
521 feat_bail_required ASAN_MEMORY
526 ld_check
-Wl,-z,relro
528 ld_check
-Wl,-z,noexecstack
529 if ld_check
-Wl,-rpath =.
/ no
; then
530 need_R_ldflags
=-Wl,-rpath=
531 # Choose DT_RUNPATH (after $LD_LIBRARY_PATH) over DT_RPATH (before)
532 ld_check
-Wl,--enable-new-dtags
533 ld_runtime_flags
# update!
534 elif ld_check
-Wl,-R .
/ no
; then
535 need_R_ldflags
=-Wl,-R
536 ld_check
-Wl,--enable-new-dtags
537 ld_runtime_flags
# update!
540 # Address randomization
542 if cc_check
-fPIE || cc_check
-fpie; then
543 ld_check
-pie || _CFLAGS
=${_ccfg}
547 _CFLAGS
="${_CFLAGS} ${__cflags}" _LDFLAGS="${_LDFLAGS} ${__ldflags}"
548 unset __cflags __ldflags
551 ## -- >8 - <<OS/CC | SUPPORT FUNS>> - 8< -- ##
554 ## - Heirloom sh(1) (and same origin) have _sometimes_ problems with ': >'
555 ## redirection, so use "printf '' >" instead
557 ## Very first: we undergo several states regarding I/O redirection etc.,
558 ## but need to deal with option updates from within all. Since all the
559 ## option stuff should be above the scissor line, define utility functions
560 ## and redefine them as necessary.
561 ## And, since we have those functions, simply use them for whatever
570 printf >&2 -- "${fmt}\\n" "${@}"
576 printf >&2 -- "${fmt}" "${@}"
579 t1
=ten10one1ten10one1
580 if ( [ ${t1##*ten10} = one1
] && [ ${t1#*ten10} = one1ten10one1
] &&
581 [ ${t1%%one1*} = ten10
] && [ ${t1%one1*} = ten10one1ten10
]
582 ) > /dev
/null
2>&1; then
589 # We need some standard utilities
592 n
=${1} i=${2} opt=${3:-0}
593 # Evaluate, just in case user comes in with shell snippets (..well..)
595 if type "${i}" >/dev
/null
2>&1; then # XXX why have i type not command -v?
596 [ -n "${VERBOSE}" ] && msg ' . ${%s} ... %s' "${n}" "${i}"
600 if [ ${opt} -eq 0 ]; then
601 msg
'ERROR: no trace of utility %s' "${n}"
607 # Our feature check environment
609 [ "x${1}" = x0
] ||
[ "x${1}" = xn
] ||
610 [ "x${1}" = xfalse ] || [ "x${1}" = xno ] || [ "x${1}" = xoff
]
614 [ "x${1}" = x1
] ||
[ "x${1}" = xy
] ||
615 [ "x${1}" = xtrue ] || [ "x${1}" = xyes ] || [ "x${1}" = xon
] ||
616 [ "x${1}" = xrequire
]
620 [ "x${1}" = xrequire
]
625 i
="`echo ${i} | ${tr} '[A-Z]' '[a-z]'`"
626 if feat_val_no
"${i}"; then
628 elif feat_val_yes
"${i}"; then
631 msg
"ERROR: %s: 0/n/false/no/off or 1/y/true/yes/on/require, got: %s" \
642 _feat_check
${1} && return 1
648 i
="`echo ${i} | ${tr} '[A-Z]' '[a-z]'`"
649 [ "x${i}" = xrequire
] ||
[ "x${i}" = xrequired
]
652 feat_bail_required
() {
653 if feat_require
${1}; then
654 msg
'ERROR: feature OPT_%s is required but not available' "${1}"
658 option_update
# XXX this is rather useless here (dependency chain..)
662 # Parse one of our XOPTIONS* in $2 and assign the sh(1) compatible list of
663 # options, without documentation, to $1
665 i
="`${awk} -v input=\"${2}\" '
668 voff = match(input, /[[:alnum:]_]+(='${j}'[^'${j}']+)?/)
671 v = substr(input, voff, RLENGTH)
672 input = substr(input, voff + RLENGTH)
675 d = substr(v, doff + 2, length(v) - doff - 1)
676 v = substr(v, 1, doff - 1)
686 # Return the "documentation string" for option $1, itself if none such
688 ${awk} -v want
="${1}" \
689 -v input
="${XOPTIONS_DETECT}${XOPTIONS}${XOPTIONS_XTRA}" '
692 voff = match(input, /[[:alnum:]_]+(='${j}'[^'${j}']+)?/)
695 v = substr(input, voff, RLENGTH)
696 input = substr(input, voff + RLENGTH)
699 d = substr(v, doff + 2, length(v) - doff - 1)
700 v = substr(v, 1, doff - 1)
714 # Join the values from make.rc into what currently is defined, not
715 # overwriting yet existing settings
717 # We want read(1) to perform reverse solidus escaping in order to be able to
718 # use multiline values in make.rc; the resulting sh(1)/sed(1) code was very
719 # slow in VMs (see [fa2e248]), Aharon Robbins suggested the following
720 < ${rc} ${awk} 'BEGIN{line = ""}{
721 gsub
(/^
[[:space
:]]+/, "", $0)
722 gsub
(/[[:space
:]]+$
/, "", $0)
723 if(gsub
(/\\$
/, "", $0)){
728 if(index
(line
, "#") == 1){
730 }else if(length
(line
)){
736 if [ -n "${good_shell}" ]; then
739 i=`${awk} -v LINE="${line}" 'BEGIN
{
740 gsub
(/=.
*$
/, "", LINE
)
744 if [ "${i}" = "${line}" ]; then
745 msg 'ERROR
: invalid syntax
in: %s
' "${line}"
749 eval j="\$${i}" jx="\${${i}+x}"
750 if [ -n "${j}" ] || [ "${jx}" = x ]; then
753 j=`${awk} -v LINE="${line}" 'BEGIN
{
754 gsub
(/^
[^
=]*=/, "", LINE
)
755 gsub
(/^
\"*/, "", LINE
)
756 gsub
(/\"*$
/, "", LINE
)
760 [ "${i}" = "DESTDIR" ] && continue
763 # Reread the mixed version right now
768 # Expand the option values, which may contain shell snippets
769 ${rm} -f ${newlst} ${newmk} ${newh}
770 exec 5<&0 6>&1 <${tmp} >${newlst}
773 if [ -n "${good_shell}" ]; then
775 [ "${i}" != "${i#OPT_}" ] && z=1
777 i=`${awk} -v LINE="${line}" 'BEGIN
{
778 gsub
(/=.
*$
/, "", LINE
);\
781 if echo "${i}" | ${grep} '^OPT_
' >/dev/null 2>&1; then
787 if [ -n "${z}" ]; then
788 j="`echo ${j} | ${tr} '[A-Z
]' '[a-z
]'`"
789 if [ -z "${j}" ] || feat_val_no "${j}"; then
791 printf " /* #undef ${i} */\n" >> ${newh}
792 elif feat_val_yes "${j}"; then
793 if feat_val_require "${j}"; then
798 printf " /* #define ${i} */\n" >> ${newh}
800 msg 'ERROR
: cannot parse
<%s
>' "${line}"
804 printf "#define ${i} \"${j}\"\n" >> ${newh}
806 printf "${i} = ${j}\n" >> ${newmk}
810 exec 0<&5 1>&6 5<&- 6<&-
814 # "path_check VARNAME" or "path_check VARNAME FLAG VARNAME"
815 varname=${1} addflag=${2} flagvarname=${3}
823 [ -z "${i}" ] && continue
824 [ -d "${i}" ] || continue
825 # Skip any fakeroot packager environment
826 case "${i}" in *fakeroot*) continue;; esac
827 if [ -n "${j}" ]; then
828 if { z=${y}; echo "${z}"; } | ${grep} ":${i}:" >/dev/null 2>&1; then
833 [ -n "${addflag}" ] && k="${k} ${addflag}${i}"
838 [ -n "${addflag}" ] && k="${addflag}${i}"
841 eval "${varname}=\"${j}\""
842 [ -n "${addflag}" ] && eval "${flagvarname}=\"${k}\""
847 if [ -n "${need_R_ldflags}" ]; then
850 set -- ${LD_LIBRARY_PATH}
854 LDFLAGS="${LDFLAGS} ${need_R_ldflags}${i}"
855 _LDFLAGS="${_LDFLAGS} ${need_R_ldflags}${i}"
859 # Disable it for a possible second run.
864 [ -n "${cc_check_silent}" ] || msg_nonl ' . CC
%s ..
' "${1}"
866 ${_CFLAGS} ${1} ${EXTRA_CFLAGS} ${_LDFLAGS} ${EXTRA_LDFLAGS} \
867 -o ${tmp2} ${tmp}.c ${LIBS} >/dev/null 2>&1; then
868 _CFLAGS="${_CFLAGS} ${1}"
869 [ -n "${cc_check_silent}" ] || msg 'yes'
872 [ -n "${cc_check_silent}" ] || msg 'no
'
877 # $1=option [$2=option argument] [$3=if set, shall NOT be added to _LDFLAGS]
878 [ -n "${cc_check_silent}" ] || msg_nonl ' . LD
%s ..
' "${1}"
879 if "${CC}" ${INCS} ${_CFLAGS} ${_LDFLAGS} ${1}${2} ${EXTRA_LDFLAGS} \
880 -o ${tmp2} ${tmp}.c ${LIBS} >/dev/null 2>&1; then
881 [ -n "${3}" ] || _LDFLAGS="${_LDFLAGS} ${1}"
882 [ -n "${cc_check_silent}" ] || msg 'yes'
885 [ -n "${cc_check_silent}" ] || msg 'no
'
890 variable=$1 topic=$2 define=$3
893 msg_nonl ' .
%s ...
' "${topic}"
894 echo "/* checked ${topic} */" >> ${h}
895 ${rm} -f ${tmp} ${tmp}.o
896 echo '*** test program is
'
897 { echo '#include <'"${h_name}"'>'; cat; } | ${tee} ${tmp}.c
898 #echo '*** the preprocessor generates'
899 #${make} -f ${makefile} ${tmp}.x
901 echo '*** results are'
905 yesno
=$1 variable
=$2 topic
=$3 define
=$4 libs
=$5 incs
=$6
908 msg_nonl
' . %s ... ' "${topic}"
910 echo '*** enforced unchecked results are'
911 if feat_val_yes
${yesno}; then
912 if [ -n "${incs}" ] ||
[ -n "${libs}" ]; then
913 echo "*** adding INCS<${incs}> LIBS<${libs}>"
914 LIBS
="${LIBS} ${libs}"
915 echo "${libs}" >> ${lib}
916 INCS
="${INCS} ${incs}"
917 echo "${incs}" >> ${inc}
920 echo "${define}" >> ${h}
921 eval have_
${variable}=yes
924 echo "/* ${define} */" >> ${h}
926 eval unset have_
${variable}
932 variable
=$1 topic
=$2 define
=$3
934 _check_preface
"${variable}" "${topic}" "${define}"
936 if ${make} -f ${makefile} XINCS="${INCS}" \
937 CFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}" \
939 [ -f ./${tmp}.o ]; then
941 echo "${define}" >> ${h}
942 eval have_${variable}=yes
945 echo "/* ${define} */" >> ${h}
947 eval unset have_${variable}
953 run=$1 variable=$2 topic=$3 define=$4 libs=$5 incs=$6
955 _check_preface "${variable}" "${topic}" "${define}"
957 if feat_yes CROSS_BUILD; then
958 if [ ${run} = 1 ]; then
963 if ${make} -f ${makefile} XINCS="${INCS} ${incs}" \
964 CFLAGS
="${CFLAGS}" LDFLAGS
="${LDFLAGS}" \
965 XLIBS
="${LIBS} ${libs}" \
968 { [ ${run} -eq 0 ] || ./${tmp}; }; then
969 echo "*** adding INCS<${incs}> LIBS<${libs}>; executed: ${run}"
971 echo "${define}" >> ${h}
972 LIBS
="${LIBS} ${libs}"
973 echo "${libs}" >> ${lib}
974 INCS
="${INCS} ${incs}"
975 echo "${incs}" >> ${inc}
976 eval have_
${variable}=yes
980 echo "/* ${define} */" >> ${h}
981 eval unset have_
${variable}
987 _link_mayrun
0 "${1}" "${2}" "${3}" "${4}" "${5}"
991 _link_mayrun
1 "${1}" "${2}" "${3}" "${4}" "${5}"
995 _link_mayrun
2 "${1}" "${2}" "${3}" "${4}" "${5}"
999 if feat_yes
${1}; then
1000 echo '#define HAVE_'${1}'' >> ${h}
1003 echo '/* OPT_'${1}'=0 */' >> ${h}
1009 < "${1}" > "${2}" ${awk} \
1010 'BEGIN {ORS = " "} /^[^#]/ {print} {next} END {ORS = ""; print "\n"}'
1013 ## -- >8 - <<SUPPORT FUNS | RUNNING>> - 8< -- ##
1015 # First of all, create new configuration and check whether it changed
1017 # Very easy checks for the operating system in order to be able to adjust paths
1018 # or similar very basic things which we need to be able to go at all
1021 # Check those tools right now that we need before including $rc
1022 msg 'Checking for basic utility set'
1023 check_tool awk "${awk:-`command -v awk`}"
1024 check_tool rm "${rm:-`command -v rm`}"
1025 check_tool tr "${tr:-`command -v tr`}"
1027 # Initialize the option set
1028 msg_nonl 'Setting up configuration options ... '
1032 # Include $rc, but only take from it what wasn't overwritten by the user from
1033 # within the command line or from a chosen fixed CONFIG=
1034 # Note we leave alone the values
1035 trap "exit 1" HUP INT TERM
1036 trap "${rm} -f ${tmp}" EXIT
1038 msg_nonl 'Joining in %s ... ' ${rc}
1042 # We need to know about that now, in order to provide utility overwrites etc.
1045 msg 'Checking for remaining set of utilities'
1046 check_tool grep "${grep:-`command -v grep`}"
1048 # Before we step ahead with the other utilities perform a path cleanup first.
1052 check_tool cat "${cat:-`command -v cat`}"
1053 check_tool chmod "${chmod:-`command -v chmod`}"
1054 check_tool cp "${cp:-`command -v cp`}"
1055 check_tool cmp "${cmp:-`command -v cmp`}"
1057 check_tool mkdir "${mkdir:-`command -v mkdir`}"
1058 check_tool mv "${mv:-`command -v mv`}"
1060 check_tool sed "${sed:-`command -v sed`}"
1061 check_tool sort "${sort:-`command -v sort`}"
1062 check_tool tee "${tee:-`command -v tee`}"
1064 check_tool chown "${chown:-`command -v chown`}" 1 ||
1065 check_tool chown "/sbin
/chown
" 1 ||
1066 check_tool chown "/usr
/sbin
/chown
"
1068 check_tool make "${MAKE:-`command -v make`}"
1070 check_tool strip "${STRIP:-`command -v strip`}" 1 &&
1071 HAVE_STRIP=1 || HAVE_STRIP=0
1073 # For ./cc-test.sh only
1074 check_tool cksum "${cksum:-`command -v cksum`}"
1076 # Update OPT_ options now, in order to get possible inter-dependencies right
1079 # (No functions since some shells loose non-exported variables in traps)
1080 trap "trap \"\" HUP INT TERM
; exit 1" HUP INT TERM
1081 trap "trap \"\" HUP INT TERM EXIT
;\
1082 ${rm} -rf ${newlst} ${tmp0}.* ${tmp0}* ${newmk} ${newev} ${newh}" EXIT
1084 # Our configuration options may at this point still contain shell snippets,
1085 # we need to evaluate them in order to get them expanded, and we need those
1086 # evaluated values not only in our new configuration file, but also at hand..
1087 msg_nonl 'Evaluating all configuration items ... '
1091 # Add the known utility and some other variables
1092 printf "#define VAL_UAGENT \"${VAL_SID}${VAL_MAILX}\"\n" >> ${newh}
1093 printf "VAL_UAGENT = ${VAL_SID}${VAL_MAILX}\n" >> ${newmk}
1095 printf "#define VAL_PRIVSEP \"${VAL_SID}${VAL_MAILX}-privsep\"\n" >> ${newh}
1096 printf "VAL_PRIVSEP = \$(VAL_UAGENT)-privsep\n" >> ${newmk}
1097 if feat_yes DOTLOCK
; then
1098 printf "OPTIONAL_PRIVSEP = \$(VAL_PRIVSEP)\n" >> ${newmk}
1100 printf "OPTIONAL_PRIVSEP =\n" >> ${newmk}
1104 awk cat chmod chown
cp cmp grep mkdir
mv rm sed sort tee tr \
1105 MAKE MAKEFLAGS
make SHELL strip \
1108 printf "${i} = ${j}\n" >> ${newmk}
1109 printf "${i}=${j}\n" >> ${newlst}
1110 printf "${i}=\"${j}\";export ${i}; " >> ${newev}
1112 printf "\n" >> ${newev}
1114 # Build a basic set of INCS and LIBS according to user environment.
1115 path_check C_INCLUDE_PATH -I _INCS
1116 INCS="${INCS} ${_INCS}"
1117 path_check LD_LIBRARY_PATH -L _LIBS
1118 LIBS="${LIBS} ${_LIBS}"
1120 export C_INCLUDE_PATH LD_LIBRARY_PATH
1122 # Some environments need runtime path flags to be able to go at all
1125 ## Detect CC, whether we can use it, and possibly which CFLAGS we can use
1129 ${cat} > ${tmp}.c << \!
1132 static void doit(char const *s);
1134 main(int argc, char **argv){
1137 doit("Hello world
");
1141 doit(char const *s){
1143 memcpy(buf, s, strlen(s) +1);
1148 if "${CC}" ${INCS} ${CFLAGS} ${EXTRA_CFLAGS} ${LDFLAGS} ${EXTRA_LDFLAGS} \
1149 -o ${tmp2} ${tmp}.c ${LIBS}; then
1152 msg
'ERROR: i cannot compile a "Hello world" via'
1154 "${CC} ${INCS} ${CFLAGS} ${EXTRA_CFLAGS} ${LDFLAGS} ${EXTRA_LDFLAGS} ${LIBS}"
1155 msg
'ERROR: Please read INSTALL, rerun'
1159 # This may also update ld_runtime_flags() (again)
1166 printf -- "${i}=${j}\n" >> ${newlst}
1172 PATH C_INCLUDE_PATH LD_LIBRARY_PATH \
1176 printf -- "${i} = ${j}\n" >> ${newmk}
1177 printf -- "${i}=${j}\n" >> ${newlst}
1180 # Now finally check whether we already have a configuration and if so, whether
1181 # all those parameters are still the same.. or something has actually changed
1182 if [ -f ${lst} ] && ${cmp} ${newlst} ${lst} >/dev/null 2>&1; then
1183 echo 'Configuration is up-to-date'
1185 elif [ -f ${lst} ]; then
1186 echo 'Configuration has been updated..'
1187 ( eval "${MAKE} -f .
/mk-config.mk clean
" )
1190 echo 'Shiny configuration..'
1193 # Time to redefine helper 1
1195 ${rm} -f ${lst} ${h} ${mk}
1199 ${mv} -f ${newlst} ${lst}
1200 ${mv} -f ${newev} ${ev}
1201 ${mv} -f ${newh} ${h}
1202 ${mv} -f ${newmk} ${mk}
1204 if [ -z "${VERBOSE}" ]; then
1205 printf -- "ECHO_CC
= @
echo ' 'CC \$
(@
);\n" >> ${mk}
1206 printf -- "ECHO_LINK
= @
echo ' 'LINK \$
(@
);\n" >> ${mk}
1207 printf -- "ECHO_GEN
= @
echo ' 'GEN \$
(@
);\n" >> ${mk}
1208 printf -- "ECHO_TEST
= @
\n" >> ${mk}
1209 printf -- "ECHO_CMD
= @
echo ' CMD';\n" >> ${mk}
1210 printf -- "ECHO_BLOCK_BEGIN
= @
( \n" >> ${mk}
1211 printf -- "ECHO_BLOCK_END
= ) >/dev
/null
\n" >> ${mk}
1214 ## Compile and link checking
1220 makefile=./${tmp0}.mk
1222 # (No function since some shells loose non-exported variables in traps)
1223 trap "trap \"\" HUP INT TERM
;\
1224 ${rm} -f ${lst} ${h} ${mk} ${lib} ${inc}; exit 1" HUP INT TERM
1225 trap "trap \"\" HUP INT TERM EXIT
;\
1226 ${rm} -rf ${tmp0}.* ${tmp0}*" EXIT
1228 # Time to redefine helper 2
1232 printf "*** ${fmt}\\n
" "${@}"
1233 printf -- "${fmt}\\n
" "${@}" >&5
1238 printf "*** ${fmt}\\n
" "${@}"
1239 printf -- "${fmt}" "${@}" >&5
1243 exec 5>&2 > ${log} 2>&1
1245 echo "${LIBS}" > ${lib}
1246 echo "${INCS}" > ${inc}
1247 ${cat} > ${makefile} << \!
1248 .SUFFIXES: .o .c .x .y
1250 $(CC) -I./ $(XINCS) $(CFLAGS) -c $(<)
1252 $(CC) -I./ $(XINCS) -E $(<) > $(@)
1254 $(CC) -I./ $(XINCS) $(CFLAGS) $(LDFLAGS) -o $(@) $(<) $(XLIBS)
1259 # May be multiline..
1261 [ -n "${OS_DEFINES}" ] && printf -- "${OS_DEFINES}" >> ${h}
1262 echo '#define VAL_BUILD_OS "'"${OS}"'"' >> ${h}
1263 echo '#define VAL_BUILD_OSENV "'"${OSENV}"'"' >> ${h}
1265 # Generate n_err_number OS mappings
1267 feat_yes DEVEL
&& NV
= || NV
=noverbose
1268 TARGET
="${h}" awk="${awk}" ./make-errors.sh ${NV} config
1270 xrun_check oserrno 'OS error mapping table generated' || config_exit 1
1272 feat_def ALWAYS_UNICODE_LOCALE
1273 feat_def AMALGAMATION
1274 feat_def CROSS_BUILD
1278 feat_def ASAN_ADDRESS
1279 feat_def ASAN_MEMORY
1285 if xrun_check inline 'inline functions' \
1286 '#define HAVE_INLINE
1287 #define n_INLINE static inline' << \!
1288 static inline int ilf(int i){return ++i;}
1289 int main(void){return ilf(-1);}
1293 elif xrun_check inline 'inline functions (via __inline)' \
1294 '#define HAVE_INLINE
1295 #define n_INLINE static __inline' << \!
1296 static __inline int ilf(int i){return ++i;}
1297 int main(void){return ilf(-1);}
1303 ## Test for "basic
" system-calls / functionality that is used by all parts
1304 ## of our program. Once this is done fork away BASE_LIBS and other BASE_*
1305 ## macros to be used by only the subprograms (potentially).
1307 if run_check clock_gettime 'clock_gettime(2)' \
1308 '#define HAVE_CLOCK_GETTIME' << \!
1314 if(!clock_gettime(CLOCK_REALTIME, &ts) || errno != ENOSYS)
1321 elif run_check clock_gettime 'clock_gettime(2) (via -lrt)' \
1322 '#define HAVE_CLOCK_GETTIME' '-lrt' << \!
1328 if(!clock_gettime(CLOCK_REALTIME, &ts) || errno != ENOSYS)
1335 elif run_check gettimeofday 'gettimeofday(2)' \
1336 '#define HAVE_GETTIMEOFDAY' << \!
1337 #include <stdio.h> /* For C89 NULL */
1338 #include <sys/time.h>
1343 if(!gettimeofday(&tv, NULL) || errno != ENOSYS)
1351 have_no_subsecond_time=1
1354 if run_check nanosleep 'nanosleep(2)' \
1355 '#define HAVE_NANOSLEEP' << \!
1362 ts.tv_nsec = 100000;
1363 if(!nanosleep(&ts, NULL) || errno != ENOSYS)
1370 elif run_check nanosleep 'nanosleep(2) (via -lrt)' \
1371 '#define HAVE_NANOSLEEP' '-lrt' << \!
1378 ts.tv_nsec = 100000;
1379 if(!nanosleep(&ts, NULL) || errno != ENOSYS)
1386 # link_check is enough for this, that function is so old, trust the proto
1387 elif link_check sleep 'sleep(3)' \
1388 '#define HAVE_SLEEP' << \!
1392 if(!sleep(1) || errno != ENOSYS)
1400 msg 'ERROR: we require one of nanosleep(2) and sleep(3).'
1404 if run_check userdb 'gete?[gu]id(2), getpwuid(3), getpwnam(3)' << \!
1413 if((gid = getgid()) != 0)
1415 if((uid = getuid()) != 0)
1417 if((pw = getpwuid(uid)) == NULL && errno == ENOSYS)
1419 if((pw = getpwnam("root
")) == NULL && errno == ENOSYS)
1427 msg 'ERROR: we require user and group info / database searches.'
1428 msg 'That much Unix we indulge ourselfs.'
1432 if link_check ftruncate 'ftruncate(2)' \
1433 '#define HAVE_FTRUNCATE' << \!
1435 #include <sys/types.h>
1437 return (ftruncate(0, 0) != 0);
1443 msg 'ERROR: we require the ftruncate(2) system call.'
1447 if run_check sa_restart 'SA_RESTART (for sigaction(2))' << \!
1451 struct sigaction nact, oact;
1453 nact.sa_handler = SIG_DFL;
1454 sigemptyset(&nact.sa_mask);
1455 nact.sa_flags = SA_RESTART;
1456 return !(!sigaction(SIGCHLD, &nact, &oact) || errno != ENOSYS);
1462 msg 'ERROR: we (yet) require the SA_RESTART flag for sigaction(2).'
1466 if link_check snprintf 'snprintf(3)' << \!
1471 snprintf(b, sizeof b, "%s
", "string
");
1478 msg 'ERROR: we require the snprintf(3) function.'
1482 if link_check environ 'environ(3)' << \!
1483 #include <stdio.h> /* For C89 NULL */
1485 extern char **environ;
1487 return environ[0] == NULL;
1493 msg 'ERROR: we require the environ(3) array for subprocess control.'
1497 if link_check setenv '(un)?setenv(3)' '#define HAVE_SETENV' << \!
1500 setenv("s-mailx
", "i want to see it cute
!", 1);
1501 unsetenv("s-mailx
");
1507 elif link_check setenv 'putenv(3)' '#define HAVE_PUTENV' << \!
1510 putenv("s-mailx
=i want to see it cute
!");
1517 msg 'ERROR: we require either the setenv(3) or putenv(3) functions.'
1521 if link_check termios 'termios.h and tc*(3) family' << \!
1522 #include <termios.h>
1524 struct termios tios;
1526 tcgetattr(0, &tios);
1527 tcsetattr(0, TCSANOW | TCSADRAIN | TCSAFLUSH, &tios);
1534 msg 'ERROR: we require termios.h and the tc*() family of functions.'
1535 msg 'That much Unix we indulge ourselfs.'
1541 if link_check vsnprintf 'vsnprintf(3)' << \!
1544 static void dome(char *buf, size_t blen, ...){
1548 vsnprintf(buf, blen, "%s
", ap);
1554 dome(b, sizeof b, "string
");
1561 feat_bail_required ERRORS
1564 if [ "${have_vsnprintf}" = yes ]; then
1566 link_check va_copy "va_copy
(3) (as
${2})" \
1567 "#define HAVE_N_VA_COPY
1568 #define n_va_copy ${2}" <<_EOT
1572 # if defined __va_copy && !defined va_copy
1573 # define va_copy __va_copy
1576 static void dome2
(char
*buf
, size_t blen
, va_list src
){
1580 vsnprintf
(buf
, blen
, "%s", ap
);
1583 static void dome
(char
*buf
, size_t blen
, ...
){
1587 dome2
(buf
, blen
, ap
);
1593 dome
(b
, sizeof b
, "string");
1598 __va_copy
0 va_copy || __va_copy
1 __va_copy
1601 run_check pathconf
'f?pathconf(2)' '#define HAVE_PATHCONF' << \
!
1608 rv |
= !(pathconf
(".", _PC_NAME_MAX
) >= 0 || errno
== 0 || errno
!= ENOSYS
);
1610 rv |
= !(pathconf
(".", _PC_PATH_MAX
) >= 0 || errno
== 0 || errno
!= ENOSYS
);
1612 /* Only link check
*/
1613 fpathconf
(0, _PC_NAME_MAX
);
1619 run_check pipe2
'pipe2(2)' '#define HAVE_PIPE2' << \
!
1626 if(!pipe2
(fds
, O_CLOEXEC
) || errno
!= ENOSYS
)
1632 # We use this only then for now (need NOW+1)
1633 run_check utimensat
'utimensat(2)' '#define HAVE_UTIMENSAT' << \
!
1634 #include <fcntl.h> /* For AT_* */
1635 #include <sys/stat.h>
1638 struct timespec ts
[2];
1640 ts
[0].tv_nsec
= UTIME_NOW
;
1641 ts
[1].tv_nsec
= UTIME_OMIT
;
1642 if(!utimensat
(AT_FDCWD
, "", ts
, 0) || errno
!= ENOSYS
)
1650 # XXX Add POSIX check once standardized
1651 if link_check posix_random
'arc4random(3)' '#define HAVE_POSIX_RANDOM 0' << \
!
1660 elif link_check getrandom
'getrandom(2) (in sys/random.h)' \
1661 '#define HAVE_GETRANDOM(B,S) getrandom(B, S, 0)
1662 #define HAVE_GETRANDOM_HEADER <sys/random.h>' <<\
!
1663 #include <sys/random.h>
1666 getrandom
(buf
, sizeof buf
, 0);
1672 elif link_check getrandom
'getrandom(2) (via syscall(2))' \
1673 '#define HAVE_GETRANDOM(B,S) syscall(SYS_getrandom, B, S, 0)
1674 #define HAVE_GETRANDOM_HEADER <sys/syscall.h>' <<\
!
1675 #include <sys/syscall.h>
1678 syscall
(SYS_getrandom
, buf
, sizeof buf
, 0);
1684 elif [ -n "${have_no_subsecond_time}" ]; then
1685 msg
'ERROR: %s %s' 'without a native random' \
1686 'one of clock_gettime(2) and gettimeofday(2) is required.'
1691 link_check putc_unlocked
'putc_unlocked(3)' '#define HAVE_PUTC_UNLOCKED' <<\
!
1694 putc_unlocked
('@', stdout
);
1699 link_check fchdir
'fchdir(3)' '#define HAVE_FCHDIR' << \
!
1707 if run_check realpath
'realpath(3)' '#define HAVE_REALPATH' << \
!
1710 char x_buf
[4096], *x
= realpath
(".", x_buf
);
1712 return (x
!= NULL
) ?
0 : 1;
1716 if run_check realpath_malloc
'realpath(3) takes NULL' \
1717 '#define HAVE_REALPATH_NULL' << \
!
1720 char
*x
= realpath
(".", NULL
);
1724 return (x
!= NULL
) ?
0 : 1;
1732 ## optional and selectable
1734 if feat_yes DOTLOCK
; then
1735 if run_check readlink
'readlink(2)' << \
!
1741 if(!readlink
("here", buf
, sizeof buf
) || errno
!= ENOSYS
)
1749 feat_bail_required DOTLOCK
1753 if feat_yes DOTLOCK
; then
1754 if run_check fchown
'fchown(2)' << \
!
1758 if(!fchown
(0, 0, 0) || errno
!= ENOSYS
)
1766 feat_bail_required DOTLOCK
1770 ## Now it is the time to fork away the BASE_ series
1773 squeeze_em
${inc} ${tmp}
1775 squeeze_em
${lib} ${tmp}
1778 echo "BASE_LIBS = `${cat} ${lib}`" >> ${mk}
1779 echo "BASE_INCS
= `${cat} ${inc}`" >> ${mk}
1781 ## The remains are expected to be used only by the main MUA binary!
1784 link_check setlocale 'setlocale(3)' '#define HAVE_SETLOCALE' << \!
1787 setlocale(LC_ALL, "");
1791 [ -n "${have_setlocale}" ] && OPT_LOCALES=1
1793 OPT_MULTIBYTE_CHARSETS=0
1795 OPT_TERMINAL_CHARSET=0
1796 if [ -n "${have_setlocale}" ]; then
1797 link_check c90amend1 'ISO/IEC 9899:1990/Amendment 1:1995' \
1798 '#define HAVE_C90AMEND1' << \!
1804 char mbb[MB_LEN_MAX + 1];
1809 mbtowc(&wc, "x", 1);
1810 mbrtowc(&wc, "x", 1, NULL);
1812 return (mblen("\0", 1) == 0);
1815 [ -n "${have_c90amend1}" ] && OPT_MULTIBYTE_CHARSETS=1
1817 if [ -n "${have_c90amend1}" ]; then
1818 link_check wcwidth 'wcwidth(3)' '#define HAVE_WCWIDTH' << \!
1825 [ -n "${have_wcwidth}" ] && OPT_WIDE_GLYPHS=1
1828 link_check nl_langinfo 'nl_langinfo(3)' '#define HAVE_NL_LANGINFO' << \!
1829 #include <langinfo.h>
1833 return (nl_langinfo(CODESET) == NULL);
1836 [ -n "${have_nl_langinfo}" ] && OPT_TERMINAL_CHARSET=1
1839 link_check fnmatch 'fnmatch(3)' '#define HAVE_FNMATCH' << \!
1840 #include <fnmatch.h>
1842 return (fnmatch("*", ".", FNM_PATHNAME | FNM_PERIOD) == FNM_NOMATCH);
1846 link_check dirent_d_type 'struct dirent.d_type' '#define HAVE_DIRENT_TYPE' << \!
1850 return !(de.d_type == DT_UNKNOWN ||
1851 de.d_type == DT_DIR || de.d_type == DT_LNK);
1855 ## optional and selectable
1857 if feat_yes ICONV; then
1858 ${cat} > ${tmp2}.c << \!
1859 #include <stdio.h> /* For C89 NULL */
1864 id = iconv_open("foo", "bar");
1865 iconv(id, NULL, NULL, NULL, NULL);
1870 < ${tmp2}.c link_check iconv 'iconv(3) functionality' \
1871 '#define HAVE_ICONV' ||
1872 < ${tmp2}.c link_check iconv 'iconv(3) functionality (via -liconv)' \
1873 '#define HAVE_ICONV' '-liconv' ||
1874 feat_bail_required ICONV
1876 echo '/* OPT_ICONV=0 */' >> ${h}
1879 if feat_yes SOCKETS || feat_yes SPAM_SPAMD; then
1880 ${cat} > ${tmp2}.c << \!
1881 #include <sys/types.h>
1882 #include <sys/socket.h>
1886 struct sockaddr_un soun;
1888 if(socket(AF_UNIX, SOCK_STREAM, 0) == -1 && errno == ENOSYS)
1890 if(connect(0, (struct sockaddr*)&soun, 0) == -1 && errno == ENOSYS)
1892 if(shutdown(0, SHUT_RD | SHUT_WR | SHUT_RDWR) == -1 && errno == ENOSYS)
1898 < ${tmp2}.c run_check af_unix 'AF_UNIX sockets' \
1899 '#define HAVE_UNIX_SOCKETS' ||
1900 < ${tmp2}.c run_check af_unix 'AF_UNIX sockets (via -lnsl)' \
1901 '#define HAVE_UNIX_SOCKETS' '-lnsl' ||
1902 < ${tmp2}.c run_check af_unix 'AF_UNIX sockets (via -lsocket -lnsl)' \
1903 '#define HAVE_UNIX_SOCKETS' '-lsocket -lnsl'
1906 if feat_yes SOCKETS; then
1907 ${cat} > ${tmp2}.c << \!
1908 #include <sys/types.h>
1909 #include <sys/socket.h>
1910 #include <netinet/in.h>
1915 if(socket(AF_INET, SOCK_STREAM, 0) == -1 && errno == ENOSYS)
1917 if(connect(0, &s, 0) == -1 && errno == ENOSYS)
1923 < ${tmp2}.c run_check sockets 'sockets' \
1924 '#define HAVE_SOCKETS' ||
1925 < ${tmp2}.c run_check sockets 'sockets (via -lnsl)' \
1926 '#define HAVE_SOCKETS' '-lnsl' ||
1927 < ${tmp2}.c run_check sockets 'sockets (via -lsocket -lnsl)' \
1928 '#define HAVE_SOCKETS' '-lsocket -lnsl' ||
1929 feat_bail_required SOCKETS
1931 echo '/* OPT_SOCKETS=0 */' >> ${h}
1932 fi # feat_yes SOCKETS
1934 if feat_yes SOCKETS; then
1935 link_check getaddrinfo 'getaddrinfo(3)' \
1936 '#define HAVE_GETADDRINFO' << \!
1937 #include <sys/types.h>
1938 #include <sys/socket.h>
1942 struct addrinfo a, *ap;
1945 switch((lrv = getaddrinfo("foo", "0", &a, &ap))){
1949 fprintf(stderr, "%s\n", gai_strerror(lrv));
1958 if feat_yes SOCKETS && [ -z "${have_getaddrinfo}" ]; then
1959 compile_check arpa_inet_h '<arpa/inet.h>' \
1960 '#define HAVE_ARPA_INET_H' << \!
1961 #include <sys/types.h>
1962 #include <sys/socket.h>
1964 #include <netinet/in.h>
1965 #include <arpa/inet.h>
1968 ${cat} > ${tmp2}.c << \!
1969 #include <sys/types.h>
1970 #include <sys/socket.h>
1974 #include <netinet/in.h>
1975 #ifdef HAVE_ARPA_INET_H
1976 #include <arpa/inet.h>
1979 struct sockaddr_in servaddr;
1980 unsigned short portno;
1983 struct in_addr **pptr;
1986 if((ep = getservbyname("POPPY-PORT", "tcp")) != NULL)
1987 portno = (unsigned short)ep->s_port;
1989 if((hp = gethostbyname("POPPY-HOST")) != NULL){
1990 pptr = (struct in_addr**)hp->h_addr_list;
1991 if(hp->h_addrtype != AF_INET)
1992 fprintf(stderr, "au\n");
1995 case HOST_NOT_FOUND:
2001 fprintf(stderr, "au\n");
2006 memset(&servaddr, 0, sizeof servaddr);
2007 servaddr.sin_family = AF_INET;
2008 servaddr.sin_port = htons(portno);
2009 memcpy(&servaddr.sin_addr, *pptr, sizeof(struct in_addr));
2010 fprintf(stderr, "Would connect to %s:%d ...\n",
2011 inet_ntoa(**pptr), (int)portno);
2016 < ${tmp2}.c link_check gethostbyname 'get(serv|host)byname(3)' ||
2017 < ${tmp2}.c link_check gethostbyname \
2018 'get(serv|host)byname(3) (via -nsl)' '' '-lnsl' ||
2019 < ${tmp2}.c link_check gethostbyname \
2020 'get(serv|host)byname(3) (via -lsocket -nsl)' \
2021 '' '-lsocket -lnsl' ||
2022 feat_bail_required SOCKETS
2026 run_check setsockopt 'setsockopt(2)' '#define HAVE_SETSOCKOPT' << \!
2027 #include <sys/socket.h>
2033 if(setsockopt(sockfd, SOL_SOCKET, SO_KEEPALIVE, NULL, 0) == -1 &&
2040 feat_yes SOCKETS && [ -n "${have_setsockopt}" ] &&
2041 link_check so_sndtimeo 'SO_SNDTIMEO' '#define HAVE_SO_SNDTIMEO' << \!
2042 #include <sys/socket.h>
2050 setsockopt(sockfd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof tv);
2051 setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof tv);
2056 feat_yes SOCKETS && [ -n "${have_setsockopt}" ] &&
2057 link_check so_linger 'SO_LINGER' '#define HAVE_SO_LINGER' << \!
2058 #include <sys/socket.h>
2066 setsockopt(sockfd, SOL_SOCKET, SO_LINGER, &li, sizeof li);
2071 if feat_yes SSL; then # {{{
2072 # {{{ LibreSSL decided to define OPENSSL_VERSION_NUMBER with a useless value
2073 # instead of keeping it at the one that corresponds to the OpenSSL at fork
2074 # time: we need to test it first in order to get things right
2075 if compile_check _xssl 'TLS/SSL (LibreSSL)' \
2078 #define HAVE_XSSL_RESSL
2079 #define HAVE_XSSL_OPENSSL 0' << \!
2080 #include <openssl/opensslv.h>
2081 #ifdef LIBRESSL_VERSION_NUMBER
2088 # TODO OPENSSL_IS_BORINGSSL, but never tried that one!
2089 elif compile_check _xssl 'TLS/SSL (OpenSSL >= v1.1.0)' \
2092 #define HAVE_XSSL_OPENSSL 0x10100' << \!
2093 #include <openssl/opensslv.h>
2094 #if OPENSSL_VERSION_NUMBER + 0 >= 0x10100000L
2101 elif compile_check _xssl 'TLS/SSL (OpenSSL)' \
2104 #define HAVE_XSSL_OPENSSL 0x10000' << \!
2105 #include <openssl/opensslv.h>
2106 #ifdef OPENSSL_VERSION_NUMBER
2114 feat_bail_required SSL
2117 if feat_yes SSL; then # {{{
2118 if [ -n "${ossl_v1_1}" ]; then
2119 without_check yes xssl 'TLS/SSL (new style *_client_method(3ssl))' \
2120 '#define n_XSSL_CLIENT_METHOD TLS_client_method' \
2122 elif link_check xssl 'TLS/SSL (new style *_client_method(3ssl))' \
2123 '#define n_XSSL_CLIENT_METHOD TLS_client_method' \
2124 '-lssl -lcrypto' << \!
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>
2130 #ifdef OPENSSL_NO_TLS1 /* TODO only deduced from OPENSSL_NO_SSL[23]! */
2131 # error We need TLSv1.
2134 SSL_CTX *ctx = SSL_CTX_new(TLS_client_method());
2137 PEM_read_PrivateKey(0, 0, 0, 0);
2143 elif link_check xssl 'TLS/SSL (old style *_client_method(3ssl))' \
2144 '#define n_XSSL_CLIENT_METHOD SSLv23_client_method' \
2145 '-lssl -lcrypto' << \!
2146 #include <openssl/ssl.h>
2147 #include <openssl/err.h>
2148 #include <openssl/x509v3.h>
2149 #include <openssl/x509.h>
2150 #include <openssl/rand.h>
2151 #if defined OPENSSL_NO_SSL3 &&\
2152 defined OPENSSL_NO_TLS1 /* TODO only deduced from OPENSSL_NO_SSL[23]! */
2153 # error We need one of SSLv3 and TLSv1.
2156 SSL_CTX *ctx = SSL_CTX_new(SSLv23_client_method());
2159 PEM_read_PrivateKey(0, 0, 0, 0);
2166 feat_bail_required SSL
2170 if feat_yes SSL; then # {{{
2171 if [ -n "${ossl_v1_1}" ]; then
2172 without_check yes xssl_stack_of 'TLS/SSL STACK_OF()' \
2173 '#define HAVE_XSSL_STACK_OF'
2174 elif compile_check xssl_stack_of 'TLS/SSL STACK_OF()' \
2175 '#define HAVE_XSSL_STACK_OF' << \!
2176 #include <stdio.h> /* For C89 NULL */
2177 #include <openssl/ssl.h>
2178 #include <openssl/err.h>
2179 #include <openssl/x509v3.h>
2180 #include <openssl/x509.h>
2181 #include <openssl/rand.h>
2183 STACK_OF(GENERAL_NAME) *gens = NULL;
2185 printf("%p", gens); /* to use it */
2193 if [ -n "${ossl_v1_1}" ]; then
2194 without_check yes xssl_conf 'TLS/SSL OpenSSL_modules_load_file()' \
2195 '#define HAVE_XSSL_CONFIG'
2196 elif link_check xssl_conf 'TLS/SSL OpenSSL_modules_load_file() support' \
2197 '#define HAVE_XSSL_CONFIG' << \!
2198 #include <stdio.h> /* For C89 NULL */
2199 #include <openssl/conf.h>
2201 CONF_modules_load_file(NULL, NULL, CONF_MFLAGS_IGNORE_MISSING_FILE);
2202 CONF_modules_free();
2210 if [ -n "${ossl_v1_1}" ]; then
2211 without_check yes xssl_conf_ctx 'TLS/SSL SSL_CONF_CTX support' \
2212 '#define HAVE_XSSL_CONF_CTX'
2213 elif link_check xssl_conf_ctx 'TLS/SSL SSL_CONF_CTX support' \
2214 '#define HAVE_XSSL_CONF_CTX' << \!
2215 #include <openssl/ssl.h>
2216 #include <openssl/err.h>
2218 SSL_CTX *ctx = SSL_CTX_new(n_XSSL_CLIENT_METHOD());
2219 SSL_CONF_CTX *cctx = SSL_CONF_CTX_new();
2221 SSL_CONF_CTX_set_flags(cctx,
2222 SSL_CONF_FLAG_FILE | SSL_CONF_FLAG_CLIENT |
2223 SSL_CONF_FLAG_CERTIFICATE | SSL_CONF_FLAG_SHOW_ERRORS);
2224 SSL_CONF_CTX_set_ssl_ctx(cctx, ctx);
2225 SSL_CONF_cmd(cctx, "Protocol", "ALL");
2226 SSL_CONF_CTX_finish(cctx);
2227 SSL_CONF_CTX_free(cctx);
2236 if [ -n "${ossl_v1_1}" ]; then
2237 without_check no xssl_rand_egd 'TLS/SSL RAND_egd(3ssl)' \
2238 '#define HAVE_XSSL_RAND_EGD'
2239 elif link_check xssl_rand_egd 'TLS/SSL RAND_egd(3ssl)' \
2240 '#define HAVE_XSSL_RAND_EGD' << \!
2241 #include <openssl/rand.h>
2243 return RAND_egd("some.where") > 0;
2250 if feat_yes SSL_ALL_ALGORITHMS; then
2251 if [ -n "${ossl_v1_1}" ]; then
2252 without_check yes ssl_all_algo 'TLS/SSL all-algorithms support' \
2253 '#define HAVE_SSL_ALL_ALGORITHMS'
2254 elif link_check ssl_all_algo 'TLS/SSL all-algorithms support' \
2255 '#define HAVE_SSL_ALL_ALGORITHMS' << \!
2256 #include <openssl/evp.h>
2258 OpenSSL_add_all_algorithms();
2259 EVP_get_cipherbyname("two cents i never exist");
2267 feat_bail_required SSL_ALL_ALGORITHMS
2270 fi # feat_yes SSL }}}
2272 if feat_yes SSL && feat_yes MD5 && feat_no NOEXTMD5; then # {{{
2273 run_check ssl_md5 'MD5 digest in the used crypto library' \
2274 '#define HAVE_XSSL_MD5' << \!
2277 #include <openssl/md5.h>
2279 char const dat[] = "abrakadabrafidibus";
2280 char dig[16], hex[16 * 2];
2284 memset(dig, 0, sizeof(dig));
2285 memset(hex, 0, sizeof(hex));
2287 MD5_Update(&ctx, dat, sizeof(dat) - 1);
2288 MD5_Final(dig, &ctx);
2290 #define hexchar(n) ((n) > 9 ? (n) - 10 + 'a' : (n) + '0')
2291 for(i = 0; i < sizeof(hex) / 2; i++){
2293 hex[j] = hexchar((dig[i] & 0xf0) >> 4);
2294 hex[++j] = hexchar(dig[i] & 0x0f);
2296 return !!memcmp("6d7d0a3d949da2e96f2aa010f65d8326", hex, sizeof(hex));
2301 echo '/* OPT_SSL=0 */' >> ${h}
2302 fi # }}} feat_yes SSL
2304 if [ "${have_xssl}" = yes ]; then
2314 if feat_yes GSSAPI; then
2315 ${cat} > ${tmp2}.c << \!
2316 #include <gssapi/gssapi.h>
2318 gss_import_name(0, 0, GSS_C_NT_HOSTBASED_SERVICE, 0);
2319 gss_init_sec_context(0,0,0,0,0,0,0,0,0,0,0,0,0);
2323 ${sed} -e '1s/gssapi\///' < ${tmp2}.c > ${tmp3}.c
2325 if command -v krb5-config >/dev/null 2>&1; then
2326 i=`command -v krb5-config
`
2327 GSS_LIBS="`CFLAGS
= ${i} --libs gssapi
`"
2328 GSS_INCS="`CFLAGS
= ${i} --cflags`"
2329 i='GSS-API via krb5-config(1)'
2333 i='GSS-API in gssapi/gssapi.h, libgssapi'
2335 if < ${tmp2}.c link_check gss \
2336 "${i}" '#define HAVE_GSSAPI' "${GSS_LIBS}" "${GSS_INCS}" ||\
2337 < ${tmp3}.c link_check gss \
2338 'GSS-API in gssapi.h, libgssapi' \
2339 '#define HAVE_GSSAPI
2340 #define GSSAPI_REG_INCLUDE' \
2342 < ${tmp2}.c link_check gss 'GSS-API in libgssapi_krb5' \
2343 '#define HAVE_GSSAPI' \
2345 < ${tmp3}.c link_check gss \
2346 'GSS-API in libgssapi, OpenBSD-style (pre 5.3)' \
2347 '#define HAVE_GSSAPI
2348 #define GSS_REG_INCLUDE' \
2349 '-lgssapi -lkrb5 -lcrypto' \
2350 '-I/usr/include/kerberosV' ||\
2351 < ${tmp2}.c link_check gss 'GSS-API in libgss' \
2352 '#define HAVE_GSSAPI' \
2354 link_check gss 'GSS-API in libgssapi_krb5, old-style' \
2355 '#define HAVE_GSSAPI
2356 #define GSSAPI_OLD_STYLE' \
2357 '-lgssapi_krb5' << \!
2358 #include <gssapi/gssapi.h>
2359 #include <gssapi/gssapi_generic.h>
2361 gss_import_name(0, 0, gss_nt_service_name, 0);
2362 gss_init_sec_context(0,0,0,0,0,0,0,0,0,0,0,0,0);
2369 feat_bail_required GSSAPI
2372 echo '/* OPT_GSSAPI=0 */' >> ${h}
2373 fi # feat_yes GSSAPI
2378 if feat_yes IDNA; then
2379 if link_check idna 'GNU Libidn' '#define HAVE_IDNA HAVE_IDNA_LIBIDNA' \
2382 #include <idn-free.h>
2383 #include <stringprep.h>
2385 char *utf8, *idna_ascii, *idna_utf8;
2387 utf8 = stringprep_locale_to_utf8("does.this.work");
2388 if (idna_to_ascii_8z(utf8, &idna_ascii, IDNA_USE_STD3_ASCII_RULES)
2391 idn_free(idna_ascii);
2392 /* (Rather link check only here) */
2393 idna_utf8 = stringprep_convert(idna_ascii, "UTF-8", "de_DE");
2399 elif link_check idna 'idnkit' '#define HAVE_IDNA HAVE_IDNA_IDNKIT' \
2402 #include <idn/api.h>
2403 #include <idn/result.h>
2407 char local_name[256];
2409 r = idn_encodename(IDN_ENCODE_APP, "does.this.work", ace_name,
2411 if (r != idn_success) {
2412 fprintf(stderr, "idn_encodename failed: %s\n", idn_result_tostring(r));
2415 r = idn_decodename(IDN_DECODE_APP, ace_name, local_name, sizeof(local_name));
2416 if (r != idn_success) {
2417 fprintf(stderr, "idn_decodename failed: %s\n", idn_result_tostring(r));
2426 feat_bail_required IDNA
2429 if [ -n "${have_idna}" ]; then
2430 echo '#define HAVE_IDNA_LIBIDNA 0' >> ${h}
2431 echo '#define HAVE_IDNA_IDNKIT 1' >> ${h}
2434 echo '/* OPT_IDNA=0 */' >> ${h}
2437 feat_def IMAP_SEARCH
2439 if feat_yes REGEX; then
2440 if link_check regex 'regular expressions' '#define HAVE_REGEX' << \!
2448 status = regcomp(&re, ".*bsd", REG_EXTENDED | REG_ICASE | REG_NOSUB);
2449 xret = regerror(status, &re, NULL, 0);
2450 status = regexec(&re, "plan9", 0,NULL, 0);
2452 return !(status == REG_NOMATCH);
2458 feat_bail_required REGEX
2461 echo '/* OPT_REGEX=0 */' >> ${h}
2464 if feat_yes MLE && [ -n "${have_c90amend1}" ]; then
2466 echo '#define HAVE_MLE' >> ${h}
2468 feat_bail_required MLE
2469 echo '/* OPT_MLE=0 */' >> ${h}
2472 # Generic have-a-line-editor switch for those who need it below
2473 if [ -n "${have_mle}" ]; then
2477 if [ -n "${have_cle}" ] && feat_yes HISTORY; then
2478 echo '#define HAVE_HISTORY' >> ${h}
2480 echo '/* OPT_HISTORY=0 */' >> ${h}
2483 if [ -n "${have_mle}" ] && feat_yes KEY_BINDINGS; then
2484 echo '#define HAVE_KEY_BINDINGS' >> ${h}
2486 echo '/* OPT_KEY_BINDINGS=0 */' >> ${h}
2489 if feat_yes TERMCAP; then
2491 link_check termcap "termcap(5) (via ${4})" \
2492 "#define HAVE_TERMCAP${3}" "${1}" << _EOT
2497 #define UNCONST(P) ((void*)(unsigned long)(void const*)(P))
2498 static int my_putc(int c){return putchar(c);}
2500 char buf[1024+512], cmdbuf[2048], *cpb, *r1;
2501 int r2 = OK, r3 = ERR;
2503 tgetent(buf, getenv("TERM"));
2505 r1 = tgetstr(UNCONST("cm"), &cpb);
2507 r2 = tgetnum(UNCONST("Co"));
2508 r3 = tgetflag(UNCONST("ut"));
2509 tputs("cr", 1, &my_putc);
2510 return (r1 == NULL || r2 == -1 || r3 == 0);
2516 link_check terminfo "terminfo(5) (via ${2})" \
2517 '#define HAVE_TERMCAP
2518 #define HAVE_TERMCAP_CURSES
2519 #define HAVE_TERMINFO' "${1}" << _EOT
2523 #define UNCONST(P) ((void*)(unsigned long)(void const*)(P))
2524 static int my_putc(int c){return putchar(c);}
2530 r0 = setupterm(NULL, 1, &er);
2531 r1 = tigetflag(UNCONST("bce"));
2532 r2 = tigetnum(UNCONST("colors"));
2533 r3 = tigetstr(UNCONST("cr"));
2534 tp = tparm(r3, NULL, NULL, 0,0,0,0,0,0,0);
2535 tputs(tp, 1, &my_putc);
2536 return (r0 == ERR || r1 == -1 || r2 == -2 || r2 == -1 ||
2537 r3 == (char*)-1 || r3 == NULL);
2542 if feat_yes TERMCAP_VIA_TERMINFO; then
2543 __terminfolib -ltinfo -ltinfo ||
2544 __terminfolib -lcurses -lcurses ||
2545 __terminfolib -lcursesw -lcursesw ||
2546 feat_bail_required TERMCAP_VIA_TERMINFO
2549 if [ -z "${have_terminfo}" ]; then
2550 __termcaplib -ltermcap '' '' '-ltermcap' ||
2551 __termcaplib -ltermcap '#include <curses.h>' '
2552 #define HAVE_TERMCAP_CURSES' \
2553 'curses.h / -ltermcap' ||
2554 __termcaplib -lcurses '#include <curses.h>' '
2555 #define HAVE_TERMCAP_CURSES' \
2556 'curses.h / -lcurses' ||
2557 __termcaplib -lcursesw '#include <curses.h>' '
2558 #define HAVE_TERMCAP_CURSES' \
2559 'curses.h / -lcursesw' ||
2560 feat_bail_required TERMCAP
2562 if [ -n "${have_termcap}" ]; then
2563 run_check tgetent_null \
2564 "tgetent(3) of termcap(5) takes NULL buffer" \
2565 "#define HAVE_TGETENT_NULL_BUF" << _EOT
2566 #include <stdio.h> /* For C89 NULL */
2568 #ifdef HAVE_TERMCAP_CURSES
2569 # include <curses.h>
2573 tgetent(NULL, getenv("TERM"));
2580 echo '/* OPT_TERMCAP=0 */' >> ${h}
2581 echo '/* OPT_TERMCAP_VIA_TERMINFO=0 */' >> ${h}
2584 if feat_def SPAM_SPAMC; then
2585 if command -v spamc >/dev/null 2>&1; then
2586 echo "#define SPAM_SPAMC_PATH \"`command -v spamc
`\"" >> ${h}
2590 if feat_yes SPAM_SPAMD && [ -n "${have_af_unix}" ]; then
2591 echo '#define HAVE_SPAM_SPAMD' >> ${h}
2593 feat_bail_required SPAM_SPAMD
2594 echo '/* OPT_SPAM_SPAMD=0 */' >> ${h}
2597 feat_def SPAM_FILTER
2599 if feat_yes SPAM_SPAMC || feat_yes SPAM_SPAMD || feat_yes SPAM_FILTER; then
2600 echo '#define HAVE_SPAM' >> ${h}
2602 echo '/* HAVE_SPAM */' >> ${h}
2605 if feat_yes QUOTE_FOLD &&\
2606 [ -n "${have_c90amend1}" ] && [ -n "${have_wcwidth}" ]; then
2607 echo '#define HAVE_QUOTE_FOLD' >> ${h}
2609 feat_bail_required QUOTE_FOLD
2610 echo '/* OPT_QUOTE_FOLD=0 */' >> ${h}
2613 feat_def FILTER_HTML_TAGSOUP
2622 squeeze_em ${inc} ${tmp}
2624 squeeze_em ${lib} ${tmp}
2629 printf '#ifndef n_MK_CONFIG_H\n# define n_MK_CONFIG_H 1\n' > ${h}
2630 ${cat} ${tmp} >> ${h}
2634 # Create the real mk-config.mk
2635 # Note we cannout use explicit ./ filename prefix for source and object
2636 # pathnames because of a bug in bmake(1)
2637 ${rm} -rf ${tmp0}.* ${tmp0}*
2638 printf 'OBJ_SRC = ' >> ${mk}
2639 if feat_no AMALGAMATION; then
2640 for i in `printf '%s\n' *.c |
${sort}`; do
2641 if [ "${i}" = privsep.c ]; then
2644 printf "${i} " >> ${mk}
2646 printf '\nAMALGAM_TARGET =\nAMALGAM_DEP =\n' >> ${mk}
2648 printf 'main.c\nAMALGAM_TARGET = main.o\nAMALGAM_DEP = ' >> ${mk}
2650 printf '\n/* HAVE_AMALGAMATION: include sources */\n' >> ${h}
2651 printf '#elif _CONFIG_H + 0 == 1\n' >> ${h}
2652 printf '# undef _CONFIG_H\n' >> ${h}
2653 printf '# define _CONFIG_H 2\n' >> ${h}
2654 for i in `printf '%s\n' *.c |
${sort}`; do
2655 if [ "${i}" = "${j}" ] || [ "${i}" = main.c ] || \
2656 [ "${i}" = privsep.c ]; then
2659 printf "${i} " >> ${mk}
2660 printf "# include \"${i}\"\n" >> ${h}
2663 # tcc(1) fails on 2015-11-13 unless this #else clause existed
2664 echo '#else' >> ${h}
2667 # Finally, create the string that is used by *features* and `version
'.
2668 # Take this nice opportunity and generate a visual listing of included and
2669 # non-included features for the person who runs the configuration
2670 msg '\nThe following features are included
(+) or not
(-):'
2671 set -- ${OPTIONS_DETECT} ${OPTIONS} ${OPTIONS_XTRA}
2672 printf '/* The
"feature string" */\n' >> ${h}
2673 # Because + is expanded by *folder* if first in "echo $features", put something
2674 printf '#define VAL_FEATURES_CNT '${#}'\n#define VAL_FEATURES "#' >> ${h}
2678 sdoc
=`option_doc_of ${opt}`
2679 [ -z "${sdoc}" ] && continue
2680 sopt
="`echo ${opt} | ${tr} '[A-Z]_' '[a-z]-'`"
2681 feat_yes
${opt} && sign
=+ || sign
=-
2682 printf -- "${sep}${sign}${sopt}" >> ${h}
2684 msg " %s
%s
: %s
" ${sign} ${sopt} "${sdoc}"
2686 # TODO instead of using sh+tr+awk+printf, use awk, drop option_doc_of, inc here
2688 #${awk} -v opts="${OPTIONS_DETECT} ${OPTIONS} ${OPTIONS_XTRA}" \
2689 # -v xopts="${XOPTIONS_DETECT} ${XOPTIONS} ${XOPTIONS_XTRA}" \
2691 printf '"\n#endif /* n_MK_CONFIG_H */\n' >> ${h}
2693 echo "LIBS = `${cat} ${lib}`" >> ${mk}
2694 echo "INCS
= `${cat} ${inc}`" >> ${mk}
2696 ${cat} ./make-config.in >> ${mk}
2701 msg ' . System-wide resource file: %s/%s' "${VAL_SYSCONFDIR}" "${VAL_SYSCONFRC}"
2702 msg ' . bindir: %s' "${VAL_BINDIR}"
2703 if feat_yes DOTLOCK; then
2704 msg ' . libexecdir: %s' "${VAL_LIBEXECDIR}"
2706 msg ' . mandir: %s' "${VAL_MANDIR}"
2707 msg ' . M(ail)T(ransfer)A(gent): %s (argv0 %s)' "${VAL_MTA}" "${VAL_MTA_ARGV0}"
2708 msg ' . $MAIL spool directory: %s' "${VAL_MAIL}"
2711 if [ -n "${have_fnmatch}" ] && [ -n "${have_fchdir}" ]; then
2715 if [ -z "${have_fnmatch}" ]; then
2716 msg ' . The function fnmatch(3) could not be found.'
2717 msg ' Filename patterns like wildcard are not supported on your system'
2719 if [ -z "${have_fchdir}" ]; then
2720 msg ' . The function fchdir(2) could not be found.'
2721 msg ' We will use chdir(2) instead.'
2722 msg ' This is a problem only if the current working directory is changed'
2723 msg ' while this program is inside of it'