make-config.sh: integrate DYLD_LIBRARY_PATH in LD_.. (Alexander Harm)
[s-mailx.git] / make-config.sh
blobc25abf44d6655ab2de592d31b748cec203b8558b
1 #!/bin/sh -
2 #@ Please see INSTALL and make.rc instead.
4 LC_ALL=C
5 export LC_ALL
7 : ${SHELL:=/bin/sh}
9 # The feature set, to be kept in sync with make.rc
10 # If no documentation given, the option is used as such; if doc is a hyphen,
11 # entry is suppressed when configuration overview is printed, and also in the
12 # *features* string: most likely for obsolete features etc.
13 XOPTIONS="\
14 ICONV='Character set conversion using iconv(3)' \
15 SOCKETS='Network support' \
16 SSL='SSL/TLS (OpenSSL / LibreSSL)' \
17 SSL_ALL_ALGORITHMS='Support of all digest and cipher algorithms' \
18 SMTP='Simple Mail Transfer Protocol client' \
19 POP3='Post Office Protocol Version 3 client' \
20 IMAP='IMAP v4r1 client' \
21 GSSAPI='Generic Security Service authentication' \
22 NETRC='.netrc file support' \
23 AGENT='-' \
24 MD5='MD5 message digest (APOP, CRAM-MD5)' \
25 IDNA='Internationalized Domain Names for Applications (encode only)' \
26 IMAP_SEARCH='IMAP-style search expressions' \
27 REGEX='Regular expressions' \
28 MLE='Mailx Line Editor' \
29 HISTORY='Line editor history management' \
30 KEY_BINDINGS='Configurable key bindings' \
31 TERMCAP='Terminal capability queries (termcap(5))' \
32 TERMCAP_VIA_TERMINFO='Terminal capability queries use terminfo(5)' \
33 ERRORS='Error log message ring' \
34 SPAM_SPAMC='Spam management via spamc(1) of spamassassin(1)' \
35 SPAM_SPAMD='-' \
36 SPAM_FILTER='Freely configurable *spam-filter-..*s' \
37 DOCSTRINGS='Command documentation help strings' \
38 QUOTE_FOLD='Extended *quote-fold*ing' \
39 FILTER_HTML_TAGSOUP='Simple built-in HTML-to-text display filter' \
40 COLOUR='Coloured message display' \
41 DOTLOCK='Dotlock files and privilege-separated dotlock program' \
44 # Options which are automatically deduced from host environment, i.e., these
45 # need special treatment all around here to warp from/to OPT_ stuff
46 # setlocale, C90AMEND1, NL_LANGINFO, wcwidth
47 XOPTIONS_DETECT="\
48 LOCALES='Locale support - printable characters etc. depend on environment' \
49 MULTIBYTE_CHARSETS='Multibyte character sets' \
50 TERMINAL_CHARSET='Automatic detection of terminal character set' \
51 WIDE_GLYPHS='Wide glyph support' \
54 # Rather special options, for custom building, or which always exist.
55 # Mostly for generating the visual overview and the *features* string
56 XOPTIONS_XTRA="\
57 MIME='Multipurpose Internet Mail Extensions' \
58 SMIME='S/MIME message signing, verification, en- and decryption' \
59 CROSS_BUILD='Cross-compilation: trust any detected environment' \
60 DEBUG='Debug enabled binary, not for end-users: THANKS!' \
61 DEVEL='Computers do not blunder' \
64 # The problem is that we don't have any tools we can use right now, so
65 # encapsulate stuff in functions which get called in right order later on
67 option_reset() {
68 set -- ${OPTIONS}
69 for i
71 eval OPT_${i}=0
72 done
75 option_maximal() {
76 set -- ${OPTIONS}
77 for i
79 eval OPT_${i}=1
80 done
81 OPT_DOTLOCK=require OPT_ICONV=require OPT_REGEX=require
84 option_setup() {
85 option_parse OPTIONS_DETECT "${XOPTIONS_DETECT}"
86 option_parse OPTIONS "${XOPTIONS}"
87 option_parse OPTIONS_XTRA "${XOPTIONS_XTRA}"
88 OPT_MIME=1
90 # Predefined CONFIG= urations take precedence over anything else
91 if [ -n "${CONFIG}" ]; then
92 option_reset
93 case "${CONFIG}" in
94 [nN][uU][lL][lL])
96 [nN][uU][lL][lL][iI])
97 OPT_ICONV=require
99 [mM][iI][nN][iI][mM][aA][lL])
100 OPT_DOTLOCK=require OPT_ICONV=require OPT_REGEX=require
101 OPT_COLOUR=1
102 OPT_DOCSTRINGS=1
103 OPT_ERRORS=1
104 OPT_IDNA=1
105 OPT_MLE=1
106 OPT_HISTORY=1 OPT_KEY_BINDINGS=1
107 OPT_SPAM_FILTER=1
109 [nN][eE][tT][sS][eE][nN][dD])
110 OPT_DOTLOCK=require OPT_ICONV=require OPT_REGEX=require
111 OPT_SOCKETS=require
112 OPT_SSL=require
113 OPT_SMTP=require
114 OPT_GSSAPI=1 OPT_NETRC=1
115 OPT_AGENT=1
116 OPT_COLOUR=1
117 OPT_DOCSTRINGS=1
118 OPT_ERRORS=1
119 OPT_IDNA=1
120 OPT_MLE=1
121 OPT_HISTORY=1 OPT_KEY_BINDINGS=1
122 OPT_SPAM_FILTER=1
124 [mM][aA][xX][iI][mM][aA][lL])
125 option_maximal
127 [dD][eE][vV][eE][lL])
128 option_maximal
129 OPT_DEVEL=1 OPT_DEBUG=1 OPT_NYD2=1
131 [oO][dD][eE][vV][eE][lL])
132 option_maximal
133 OPT_DEVEL=1
136 echo >&2 "Unknown CONFIG= setting: ${CONFIG}"
137 echo >&2 ' NULL, NULLI, MINIMAL, NETSEND, MAXIMAL'
138 exit 1
140 esac
141 msg_nonl "CONFIG=${CONFIG} ... "
145 # Inter-relationships
146 option_update() {
147 if feat_no SMTP && feat_no POP3 && feat_no IMAP; then
148 OPT_SOCKETS=0
150 if feat_no SOCKETS; then
151 if feat_require SMTP; then
152 msg 'ERROR: need SOCKETS for required feature SMTP'
153 config_exit 13
155 if feat_require POP3; then
156 msg 'ERROR: need SOCKETS for required feature POP3'
157 config_exit 13
159 if feat_require IMAP; then
160 msg 'ERROR: need SOCKETS for required feature IMAP'
161 config_exit 13
163 OPT_SSL=0 OPT_SSL_ALL_ALGORITHMS=0
164 OPT_SMTP=0 OPT_POP3=0 OPT_IMAP=0
165 OPT_GSSAPI=0 OPT_NETRC=0 OPT_AGENT=0
167 if feat_no SMTP && feat_no IMAP; then
168 OPT_GSSAPI=0
171 if feat_no ICONV; then
172 if feat_yes IMAP; then
173 if feat_require IMAP; then
174 msg 'ERROR: need ICONV for required feature IMAP'
175 config_exit 13
177 msg 'ERROR: disabling IMAP due to missing ICONV'
178 OPT_IMAP=0
181 if feat_yes IDNA; then
182 if feat_require IDNA; then
183 msg 'ERROR: need ICONV for required feature IDNA'
184 config_exit 13
186 msg 'ERROR: disabling IDNA due to missing ICONV'
187 OPT_IDNA=0
191 if feat_no MLE; then
192 OPT_HISTORY=0 OPT_KEY_BINDINGS=0
195 # If we don't need MD5 leave it alone
196 if feat_no SOCKETS; then
197 OPT_MD5=0
200 if feat_no TERMCAP; then
201 OPT_TERMCAP_VIA_TERMINFO=0
204 if feat_yes DEVEL; then
205 OPT_DEBUG=1
209 rc=./make.rc
210 lst=./mk-config.lst
211 ev=./mk-config.ev
212 h=./mk-config.h h_name=mk-config.h
213 mk=./mk-config.mk
215 newlst=./mk-nconfig.lst
216 newmk=./mk-nconfig.mk
217 newev=./mk-nconfig.ev
218 newh=./mk-nconfig.h
219 tmp0=___tmp
220 tmp=./${tmp0}1$$
221 tmp2=./${tmp0}2$$
223 ## -- >8 - << OPTIONS | OS/CC >> - 8< -- ##
225 # Note that potential duplicates in PATH, C_INCLUDE_PATH etc. will be cleaned
226 # via path_check() later on once possible
228 # TODO cc_maxopt is brute simple, we should compile test program and dig real
229 # compiler versions for known compilers, then be more specific
230 cc_maxopt=100
231 _CFLAGS= _LDFLAGS=
233 os_early_setup() {
234 # We don't "have any utility": only path adjustments and such in here!
235 i="${OS:-`uname -s`}"
237 if [ ${i} = SunOS ]; then
238 msg 'SunOS / Solaris? Applying some "early setup" rules ...'
239 _os_early_setup_sunos
243 _os_early_setup_sunos() {
244 # According to standards(5), this is what we need to do
245 if [ -d /usr/xpg4 ]; then :; else
246 msg 'ERROR: On SunOS / Solaris we need /usr/xpg4 environment! Sorry.'
247 config_exit 1
249 PATH="/usr/xpg4/bin:/usr/ccs/bin:/usr/bin:${PATH}"
250 [ -d /usr/xpg6 ] && PATH="/usr/xpg6/bin:${PATH}"
251 export PATH
254 os_setup() {
255 # OSENV ends up in *build-osenv*
256 # OSFULLSPEC is used to recognize changes (i.e., machine type, updates etc.)
257 : ${OS:=`uname -s | ${tr} '[A-Z]' '[a-z]'`}
258 : ${OSENV:=`uname -srm`}
259 : ${OSFULLSPEC:=`uname -a`}
260 msg 'Operating system is %s' ${OS}
262 if [ ${OS} = darwin ]; then
263 msg ' . have special Darwin environmental addons...'
264 LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${DYLD_LIBRARY_PATH}
265 elif [ ${OS} = sunos ]; then
266 msg ' . have special SunOS / Solaris "setup" rules ...'
267 _os_setup_sunos
268 elif [ ${OS} = unixware ]; then
269 if feat_yes AUTOCC && command -v cc >/dev/null 2>&1; then
270 msg ' . have special UnixWare environmental rules ...'
271 CC=cc
272 feat_yes DEBUG && _CFLAGS='-v -Xa -g' || _CFLAGS='-Xa -O'
274 CFLAGS="${_CFLAGS} ${EXTRA_CFLAGS}"
275 LDFLAGS="${_LDFLAGS} ${EXTRA_LDFLAGS}"
276 export CC CFLAGS LDFLAGS
277 OPT_AUTOCC=0 had_want_autocc=1 need_R_ldflags=-R
279 elif [ -n "${VERBOSE}" ]; then
280 msg ' . no special treatment for this system necessary or known'
283 # Sledgehammer: better set _GNU_SOURCE
284 # And in general: oh, boy!
285 OS_DEFINES="${OS_DEFINES}#define _GNU_SOURCE\n"
286 #OS_DEFINES="${OS_DEFINES}#define _POSIX_C_SOURCE 200809L\n"
287 #OS_DEFINES="${OS_DEFINES}#define _XOPEN_SOURCE 700\n"
288 #[ ${OS} = darwin ] && OS_DEFINES="${OS_DEFINES}#define _DARWIN_C_SOURCE\n"
290 # On pkgsrc(7) systems automatically add /usr/pkg/*
291 if [ -d /usr/pkg ]; then
292 C_INCLUDE_PATH=/usr/pkg/include:${C_INCLUDE_PATH}
293 LD_LIBRARY_PATH=/usr/pkg/lib:${LD_LIBRARY_PATH}
297 _os_setup_sunos() {
298 C_INCLUDE_PATH=/usr/xpg4/include:${C_INCLUDE_PATH}
299 LD_LIBRARY_PATH=/usr/xpg4/lib:${LD_LIBRARY_PATH}
301 # Include packages
302 if [ -d /opt/csw ]; then
303 C_INCLUDE_PATH=/opt/csw/include:${C_INCLUDE_PATH}
304 LD_LIBRARY_PATH=/opt/csw/lib:${LD_LIBRARY_PATH}
307 OS_DEFINES="${OS_DEFINES}#define __EXTENSIONS__\n"
308 #OS_DEFINES="${OS_DEFINES}#define _POSIX_C_SOURCE 200112L\n"
310 [ -n "${cksum}" ] || cksum=/opt/csw/gnu/cksum
311 if [ -x "${cksum}" ]; then :; else
312 msg 'ERROR: Not an executable program: %s' "${cksum}"
313 msg 'ERROR: We need a CRC-32 cksum(1), as specified in POSIX.'
314 msg 'ERROR: However, we do so only for tests.'
315 msg 'ERROR: If that is ok, set "cksum=/usr/bin/true", then rerun'
316 config_exit 1
319 if feat_yes AUTOCC; then
320 if command -v cc >/dev/null 2>&1; then
321 CC=cc
322 feat_yes DEBUG && _CFLAGS="-v -Xa -g" || _CFLAGS="-Xa -O"
324 CFLAGS="${_CFLAGS} ${EXTRA_CFLAGS}"
325 LDFLAGS="${_LDFLAGS} ${EXTRA_LDFLAGS}"
326 export CC CFLAGS LDFLAGS
327 OPT_AUTOCC=0 had_want_autocc=1 need_R_ldflags=-R
328 else
329 # Assume gcc(1), which supports -R for compat
330 cc_maxopt=2 force_no_stackprot=1 need_R_ldflags=-Wl,-R
335 # Check out compiler ($CC) and -flags ($CFLAGS)
336 cc_setup() {
337 # Even though it belongs into cc_flags we will try to compile and link
338 # something, so ensure we have a clean state regarding CFLAGS/LDFLAGS or
339 # EXTRA_CFLAGS/EXTRA_LDFLAGS
340 if feat_no AUTOCC; then
341 _cc_default
342 # Ensure those don't do any harm
343 EXTRA_CFLAGS= EXTRA_LDFLAGS=
344 export EXTRA_CFLAGS EXTRA_LDFLAGS
345 return
346 else
347 CFLAGS= LDFLAGS=
348 export CFLAGS LDFLAGS
351 [ -n "${CC}" ] && [ "${CC}" != cc ] && { _cc_default; return; }
353 msg_nonl 'Searching for a usable C compiler .. $CC='
354 if { i="`command -v clang`"; }; then
355 CC=${i}
356 elif { i="`command -v gcc`"; }; then
357 CC=${i}
358 elif { i="`command -v c99`"; }; then
359 CC=${i}
360 elif { i="`command -v tcc`"; }; then
361 CC=${i}
362 elif { i="`command -v pcc`"; }; then
363 CC=${i}
364 else
365 if [ "${CC}" = cc ]; then
367 elif { i="`command -v c89`"; }; then
368 CC=${i}
369 else
370 msg 'boing booom tschak'
371 msg 'ERROR: I cannot find a compiler!'
372 msg ' Neither of clang(1), gcc(1), tcc(1), pcc(1), c89(1) and c99(1).'
373 msg ' Please set ${CC} environment variable, maybe ${CFLAGS}, rerun.'
374 config_exit 1
377 msg '%s' "${CC}"
378 export CC
381 _cc_default() {
382 if [ -z "${CC}" ]; then
383 msg 'To go on like you have chosen, please set $CC, rerun.'
384 config_exit 1
387 if [ -z "${VERBOSE}" ] && [ -f ${lst} ] && feat_no DEBUG; then
389 else
390 msg 'Using C compiler ${CC}=%s' "${CC}"
394 cc_flags() {
395 if feat_yes AUTOCC; then
396 if [ -f ${lst} ] && feat_no DEBUG && [ -z "${VERBOSE}" ]; then
397 cc_check_silent=1
398 msg 'Detecting ${CFLAGS}/${LDFLAGS} for ${CC}=%s, just a second..' \
399 "${CC}"
400 else
401 cc_check_silent=
402 msg 'Testing usable ${CFLAGS}/${LDFLAGS} for ${CC}=%s' "${CC}"
405 i=`echo "${CC}" | ${awk} 'BEGIN{FS="/"}{print $NF}'`
406 if { echo "${i}" | ${grep} tcc; } >/dev/null 2>&1; then
407 msg ' . have special tcc(1) environmental rules ...'
408 _cc_flags_tcc
409 else
410 # As of pcc CVS 2016-04-02, stack protection support is announced but
411 # will break if used on Linux
412 if { echo "${i}" | ${grep} pcc; } >/dev/null 2>&1; then
413 force_no_stackprot=1
415 _cc_flags_generic
418 feat_no DEBUG && _CFLAGS="-DNDEBUG ${_CFLAGS}"
419 CFLAGS="${_CFLAGS} ${EXTRA_CFLAGS}"
420 LDFLAGS="${_LDFLAGS} ${EXTRA_LDFLAGS}"
421 else
422 if feat_no DEBUG; then
423 CFLAGS="-DNDEBUG ${CFLAGS}"
426 msg ''
427 export CFLAGS LDFLAGS
430 _cc_flags_tcc() {
431 __cflags=${_CFLAGS} __ldflags=${_LDFLAGS}
432 _CFLAGS= _LDFLAGS=
434 cc_check -Wall
435 cc_check -Wextra
436 cc_check -pedantic
438 if feat_yes DEBUG; then
439 # May have problems to find libtcc cc_check -b
440 cc_check -g
443 if ld_check -Wl,-rpath =./ no; then
444 need_R_ldflags=-Wl,-rpath=
445 ld_check -Wl,--enable-new-dtags
446 ld_runtime_flags # update!
449 _CFLAGS="${_CFLAGS} ${__cflags}" _LDFLAGS="${_LDFLAGS} ${__ldflags}"
450 unset __cflags __ldflags
453 _cc_flags_generic() {
454 __cflags=${_CFLAGS} __ldflags=${_LDFLAGS}
455 _CFLAGS= _LDFLAGS=
456 feat_yes DEVEL && cc_check -std=c89 || cc_check -std=c99
458 # Check -g first since some others may rely upon -g / optim. level
459 if feat_yes DEBUG; then
460 cc_check -O
461 cc_check -g
462 elif [ ${cc_maxopt} -gt 2 ] && cc_check -O3; then
464 elif [ ${cc_maxopt} -gt 1 ] && cc_check -O2; then
466 elif [ ${cc_maxopt} -gt 0 ] && cc_check -O1; then
468 else
469 cc_check -O
472 if feat_yes AMALGAMATION; then
473 cc_check -pipe
476 #if feat_yes DEVEL && cc_check -Weverything; then
478 #else
479 cc_check -Wall
480 cc_check -Wextra
481 cc_check -Wbad-function-cast
482 cc_check -Wcast-align
483 cc_check -Wcast-qual
484 cc_check -Winit-self
485 cc_check -Wmissing-prototypes
486 cc_check -Wshadow
487 cc_check -Wunused
488 cc_check -Wwrite-strings
489 cc_check -Wno-long-long
491 cc_check -pedantic
493 if feat_yes AMALGAMATION && feat_no DEVEL; then
494 cc_check -Wno-unused-function
496 feat_no DEVEL && cc_check -Wno-unused-result # XXX do right way (pragma too)
498 cc_check -fno-unwind-tables
499 cc_check -fno-asynchronous-unwind-tables
500 cc_check -fstrict-aliasing
501 if cc_check -fstrict-overflow && feat_yes DEVEL; then
502 cc_check -Wstrict-overflow=5
505 if feat_yes DEBUG || feat_yes FORCED_STACKPROT; then
506 if [ -z "${force_no_stackprot}" ]; then
507 if cc_check -fstack-protector-strong ||
508 cc_check -fstack-protector-all; then
509 cc_check -D_FORTIFY_SOURCE=2
511 else
512 msg 'Not checking for -fstack-protector compiler option,'
513 msg 'since that caused errors in a "similar" configuration.'
514 msg 'You may turn off OPT_AUTOCC and use your own settings, rerun'
518 # LD (+ dependend CC)
520 if feat_yes ASAN_ADDRESS; then
521 _ccfg=${_CFLAGS}
522 if cc_check -fsanitize=address &&
523 ld_check -fsanitize=address; then
525 else
526 feat_bail_required ASAN_ADDRESS
527 _CFLAGS=${_ccfg}
531 if feat_yes ASAN_MEMORY; then
532 _ccfg=${_CFLAGS}
533 if cc_check -fsanitize=memory &&
534 ld_check -fsanitize=memory &&
535 cc_check -fsanitize-memory-track-origins=2 &&
536 ld_check -fsanitize-memory-track-origins=2; then
538 else
539 feat_bail_required ASAN_MEMORY
540 _CFLAGS=${_ccfg}
544 ld_check -Wl,-z,relro
545 ld_check -Wl,-z,now
546 ld_check -Wl,-z,noexecstack
547 if ld_check -Wl,-rpath =./ no; then
548 need_R_ldflags=-Wl,-rpath=
549 # Choose DT_RUNPATH (after $LD_LIBRARY_PATH) over DT_RPATH (before)
550 ld_check -Wl,--enable-new-dtags
551 ld_runtime_flags # update!
552 elif ld_check -Wl,-R ./ no; then
553 need_R_ldflags=-Wl,-R
554 ld_check -Wl,--enable-new-dtags
555 ld_runtime_flags # update!
558 # Address randomization
559 _ccfg=${_CFLAGS}
560 if cc_check -fPIE || cc_check -fpie; then
561 ld_check -pie || _CFLAGS=${_ccfg}
563 unset _ccfg
565 _CFLAGS="${_CFLAGS} ${__cflags}" _LDFLAGS="${_LDFLAGS} ${__ldflags}"
566 unset __cflags __ldflags
569 ## -- >8 - <<OS/CC | SUPPORT FUNS>> - 8< -- ##
571 ## Notes:
572 ## - Heirloom sh(1) (and same origin) have _sometimes_ problems with ': >'
573 ## redirection, so use "printf '' >" instead
575 ## Very first: we undergo several states regarding I/O redirection etc.,
576 ## but need to deal with option updates from within all. Since all the
577 ## option stuff should be above the scissor line, define utility functions
578 ## and redefine them as necessary.
579 ## And, since we have those functions, simply use them for whatever
581 config_exit() {
582 exit ${1}
585 msg() {
586 fmt=${1}
587 shift
588 printf >&2 -- "${fmt}\\n" "${@}"
591 msg_nonl() {
592 fmt=${1}
593 shift
594 printf >&2 -- "${fmt}" "${@}"
597 t1=ten10one1ten10one1
598 if ( [ ${t1##*ten10} = one1 ] && [ ${t1#*ten10} = one1ten10one1 ] &&
599 [ ${t1%%one1*} = ten10 ] && [ ${t1%one1*} = ten10one1ten10 ]
600 ) > /dev/null 2>&1; then
601 good_shell=1
602 else
603 unset good_shell
605 unset t1
607 # We need some standard utilities
608 unset -f command
609 check_tool() {
610 n=${1} i=${2} opt=${3:-0}
611 # Evaluate, just in case user comes in with shell snippets (..well..)
612 eval i="${i}"
613 if type "${i}" >/dev/null 2>&1; then # XXX why have i type not command -v?
614 [ -n "${VERBOSE}" ] && msg ' . ${%s} ... %s' "${n}" "${i}"
615 eval ${n}=${i}
616 return 0
618 if [ ${opt} -eq 0 ]; then
619 msg 'ERROR: no trace of utility %s' "${n}"
620 config_exit 1
622 return 1
625 # Our feature check environment
626 feat_val_no() {
627 [ "x${1}" = x0 ] || [ "x${1}" = xn ] ||
628 [ "x${1}" = xfalse ] || [ "x${1}" = xno ] || [ "x${1}" = xoff ]
631 feat_val_yes() {
632 [ "x${1}" = x1 ] || [ "x${1}" = xy ] ||
633 [ "x${1}" = xtrue ] || [ "x${1}" = xyes ] || [ "x${1}" = xon ] ||
634 [ "x${1}" = xrequire ]
637 feat_val_require() {
638 [ "x${1}" = xrequire ]
641 _feat_check() {
642 eval i=\$OPT_${1}
643 i="`echo ${i} | ${tr} '[A-Z]' '[a-z]'`"
644 if feat_val_no "${i}"; then
645 return 1
646 elif feat_val_yes "${i}"; then
647 return 0
648 else
649 msg "ERROR: %s: 0/n/false/no/off or 1/y/true/yes/on/require, got: %s" \
650 "${1}" "${i}"
651 config_exit 11
655 feat_yes() {
656 _feat_check ${1}
659 feat_no() {
660 _feat_check ${1} && return 1
661 return 0
664 feat_require() {
665 eval i=\$OPT_${1}
666 i="`echo ${i} | ${tr} '[A-Z]' '[a-z]'`"
667 [ "x${i}" = xrequire ] || [ "x${i}" = xrequired ]
670 feat_bail_required() {
671 if feat_require ${1}; then
672 msg 'ERROR: feature OPT_%s is required but not available' "${1}"
673 config_exit 13
675 eval OPT_${1}=0
676 option_update # XXX this is rather useless here (dependency chain..)
679 option_parse() {
680 # Parse one of our XOPTIONS* in $2 and assign the sh(1) compatible list of
681 # options, without documentation, to $1
682 j=\'
683 i="`${awk} -v input=\"${2}\" '
684 BEGIN{
685 for(i = 0;;){
686 voff = match(input, /[[:alnum:]_]+(='${j}'[^'${j}']+)?/)
687 if(voff == 0)
688 break
689 v = substr(input, voff, RLENGTH)
690 input = substr(input, voff + RLENGTH)
691 doff = index(v, "=")
692 if(doff > 0){
693 d = substr(v, doff + 2, length(v) - doff - 1)
694 v = substr(v, 1, doff - 1)
696 print v
700 eval ${1}=\"${i}\"
703 option_doc_of() {
704 # Return the "documentation string" for option $1, itself if none such
705 j=\'
706 ${awk} -v want="${1}" \
707 -v input="${XOPTIONS_DETECT}${XOPTIONS}${XOPTIONS_XTRA}" '
708 BEGIN{
709 for(;;){
710 voff = match(input, /[[:alnum:]_]+(='${j}'[^'${j}']+)?/)
711 if(voff == 0)
712 break
713 v = substr(input, voff, RLENGTH)
714 input = substr(input, voff + RLENGTH)
715 doff = index(v, "=")
716 if(doff > 0){
717 d = substr(v, doff + 2, length(v) - doff - 1)
718 v = substr(v, 1, doff - 1)
719 }else
720 d = v
721 if(v == want){
722 if(d != "-")
723 print d
724 exit
731 option_join_rc() {
732 # Join the values from make.rc into what currently is defined, not
733 # overwriting yet existing settings
734 ${rm} -f ${tmp}
735 # We want read(1) to perform reverse solidus escaping in order to be able to
736 # use multiline values in make.rc; the resulting sh(1)/sed(1) code was very
737 # slow in VMs (see [fa2e248]), Aharon Robbins suggested the following
738 < ${rc} ${awk} 'BEGIN{line = ""}{
739 gsub(/^[[:space:]]+/, "", $0)
740 gsub(/[[:space:]]+$/, "", $0)
741 if(gsub(/\\$/, "", $0)){
742 line = line $0
743 next
744 }else
745 line = line $0
746 if(index(line, "#") == 1){
747 line = ""
748 }else if(length(line)){
749 print line
750 line = ""
752 }' |
753 while read line; do
754 if [ -n "${good_shell}" ]; then
755 i=${line%%=*}
756 else
757 i=`${awk} -v LINE="${line}" 'BEGIN{
758 gsub(/=.*$/, "", LINE)
759 print LINE
762 if [ "${i}" = "${line}" ]; then
763 msg 'ERROR: invalid syntax in: %s' "${line}"
764 continue
767 eval j="\$${i}" jx="\${${i}+x}"
768 if [ -n "${j}" ] || [ "${jx}" = x ]; then
769 : # Yet present
770 else
771 j=`${awk} -v LINE="${line}" 'BEGIN{
772 gsub(/^[^=]*=/, "", LINE)
773 gsub(/^\"*/, "", LINE)
774 gsub(/\"*$/, "", LINE)
775 print LINE
778 [ "${i}" = "DESTDIR" ] && continue
779 echo "${i}=\"${j}\""
780 done > ${tmp}
781 # Reread the mixed version right now
782 . ./${tmp}
785 option_evaluate() {
786 # Expand the option values, which may contain shell snippets
787 ${rm} -f ${newlst} ${newmk} ${newh}
788 exec 5<&0 6>&1 <${tmp} >${newlst}
789 while read line; do
791 if [ -n "${good_shell}" ]; then
792 i=${line%%=*}
793 [ "${i}" != "${i#OPT_}" ] && z=1
794 else
795 i=`${awk} -v LINE="${line}" 'BEGIN{
796 gsub(/=.*$/, "", LINE);\
797 print LINE
799 if echo "${i}" | ${grep} '^OPT_' >/dev/null 2>&1; then
804 eval j=\$${i}
805 if [ -n "${z}" ]; then
806 j="`echo ${j} | ${tr} '[A-Z]' '[a-z]'`"
807 if [ -z "${j}" ] || feat_val_no "${j}"; then
809 printf " /* #undef ${i} */\n" >> ${newh}
810 elif feat_val_yes "${j}"; then
811 if feat_val_require "${j}"; then
812 j=require
813 else
816 printf " /* #define ${i} */\n" >> ${newh}
817 else
818 msg 'ERROR: cannot parse <%s>' "${line}"
819 config_exit 1
821 else
822 printf "#define ${i} \"${j}\"\n" >> ${newh}
824 printf "${i} = ${j}\n" >> ${newmk}
825 printf "${i}=${j}\n"
826 eval "${i}=\"${j}\""
827 done
828 exec 0<&5 1>&6 5<&- 6<&-
831 path_check() {
832 # "path_check VARNAME" or "path_check VARNAME FLAG VARNAME"
833 varname=${1} addflag=${2} flagvarname=${3}
834 j=${IFS}
835 IFS=:
836 eval "set -- \$${1}"
837 IFS=${j}
838 j= k= y= z=
839 for i
841 [ -z "${i}" ] && continue
842 [ -d "${i}" ] || continue
843 if [ -n "${j}" ]; then
844 if { z=${y}; echo "${z}"; } | ${grep} ":${i}:" >/dev/null 2>&1; then
846 else
847 y="${y} :${i}:"
848 j="${j}:${i}"
849 # But do not link any fakeroot path into our binaries!
850 if [ -n "${addflag}" ]; then
851 case "${i}" in *fakeroot*) continue;; esac
852 k="${k} ${addflag}${i}"
855 else
856 y=" :${i}:"
857 j="${i}"
858 # But do not link any fakeroot path into our binaries!
859 if [ -n "${addflag}" ]; then
860 case "${i}" in *fakeroot*) continue;; esac
861 k="${k} ${addflag}${i}"
864 done
865 eval "${varname}=\"${j}\""
866 [ -n "${addflag}" ] && eval "${flagvarname}=\"${k}\""
867 unset varname
870 ld_runtime_flags() {
871 if [ -n "${need_R_ldflags}" ]; then
872 i=${IFS}
873 IFS=:
874 set -- ${LD_LIBRARY_PATH}
875 IFS=${i}
876 for i
878 # But do not link any fakeroot path into our binaries!
879 case "${i}" in *fakeroot*) continue;; esac
880 LDFLAGS="${LDFLAGS} ${need_R_ldflags}${i}"
881 _LDFLAGS="${_LDFLAGS} ${need_R_ldflags}${i}"
882 done
883 export LDFLAGS
885 # Disable it for a possible second run.
886 need_R_ldflags=
889 cc_check() {
890 [ -n "${cc_check_silent}" ] || msg_nonl ' . CC %s .. ' "${1}"
891 if "${CC}" ${INCS} \
892 ${_CFLAGS} ${1} ${EXTRA_CFLAGS} ${_LDFLAGS} ${EXTRA_LDFLAGS} \
893 -o ${tmp2} ${tmp}.c ${LIBS} >/dev/null 2>&1; then
894 _CFLAGS="${_CFLAGS} ${1}"
895 [ -n "${cc_check_silent}" ] || msg 'yes'
896 return 0
898 [ -n "${cc_check_silent}" ] || msg 'no'
899 return 1
902 ld_check() {
903 # $1=option [$2=option argument] [$3=if set, shall NOT be added to _LDFLAGS]
904 [ -n "${cc_check_silent}" ] || msg_nonl ' . LD %s .. ' "${1}"
905 if "${CC}" ${INCS} ${_CFLAGS} ${_LDFLAGS} ${1}${2} ${EXTRA_LDFLAGS} \
906 -o ${tmp2} ${tmp}.c ${LIBS} >/dev/null 2>&1; then
907 [ -n "${3}" ] || _LDFLAGS="${_LDFLAGS} ${1}"
908 [ -n "${cc_check_silent}" ] || msg 'yes'
909 return 0
911 [ -n "${cc_check_silent}" ] || msg 'no'
912 return 1
915 _check_preface() {
916 variable=$1 topic=$2 define=$3
918 echo '**********'
919 msg_nonl ' . %s ... ' "${topic}"
920 echo "/* checked ${topic} */" >> ${h}
921 ${rm} -f ${tmp} ${tmp}.o
922 echo '*** test program is'
923 { echo '#include <'"${h_name}"'>'; cat; } | ${tee} ${tmp}.c
924 #echo '*** the preprocessor generates'
925 #${make} -f ${makefile} ${tmp}.x
926 #${cat} ${tmp}.x
927 echo '*** results are'
930 without_check() {
931 yesno=$1 variable=$2 topic=$3 define=$4 libs=$5 incs=$6
933 echo '**********'
934 msg_nonl ' . %s ... ' "${topic}"
936 echo '*** enforced unchecked results are'
937 if feat_val_yes ${yesno}; then
938 if [ -n "${incs}" ] || [ -n "${libs}" ]; then
939 echo "*** adding INCS<${incs}> LIBS<${libs}>"
940 LIBS="${LIBS} ${libs}"
941 echo "${libs}" >> ${lib}
942 INCS="${INCS} ${incs}"
943 echo "${incs}" >> ${inc}
945 msg 'yes (deduced)'
946 echo "${define}" >> ${h}
947 eval have_${variable}=yes
948 return 0
949 else
950 echo "/* ${define} */" >> ${h}
951 msg 'no (deduced)'
952 eval unset have_${variable}
953 return 1
957 compile_check() {
958 variable=$1 topic=$2 define=$3
960 _check_preface "${variable}" "${topic}" "${define}"
962 if ${make} -f ${makefile} XINCS="${INCS}" \
963 CFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}" \
964 ./${tmp}.o &&
965 [ -f ./${tmp}.o ]; then
966 msg 'yes'
967 echo "${define}" >> ${h}
968 eval have_${variable}=yes
969 return 0
970 else
971 echo "/* ${define} */" >> ${h}
972 msg 'no'
973 eval unset have_${variable}
974 return 1
978 _link_mayrun() {
979 run=$1 variable=$2 topic=$3 define=$4 libs=$5 incs=$6
981 _check_preface "${variable}" "${topic}" "${define}"
983 if feat_yes CROSS_BUILD; then
984 if [ ${run} = 1 ]; then
985 run=0
989 if ${make} -f ${makefile} XINCS="${INCS} ${incs}" \
990 CFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}" \
991 XLIBS="${LIBS} ${libs}" \
992 ./${tmp} &&
993 [ -f ./${tmp} ] &&
994 { [ ${run} -eq 0 ] || ./${tmp}; }; then
995 echo "*** adding INCS<${incs}> LIBS<${libs}>; executed: ${run}"
996 msg 'yes'
997 echo "${define}" >> ${h}
998 LIBS="${LIBS} ${libs}"
999 echo "${libs}" >> ${lib}
1000 INCS="${INCS} ${incs}"
1001 echo "${incs}" >> ${inc}
1002 eval have_${variable}=yes
1003 return 0
1004 else
1005 msg 'no'
1006 echo "/* ${define} */" >> ${h}
1007 eval unset have_${variable}
1008 return 1
1012 link_check() {
1013 _link_mayrun 0 "${1}" "${2}" "${3}" "${4}" "${5}"
1016 run_check() {
1017 _link_mayrun 1 "${1}" "${2}" "${3}" "${4}" "${5}"
1020 xrun_check() {
1021 _link_mayrun 2 "${1}" "${2}" "${3}" "${4}" "${5}"
1024 feat_def() {
1025 if feat_yes ${1}; then
1026 echo '#define HAVE_'${1}'' >> ${h}
1027 return 0
1028 else
1029 echo '/* OPT_'${1}'=0 */' >> ${h}
1030 return 1
1034 squeeze_em() {
1035 < "${1}" > "${2}" ${awk} \
1036 'BEGIN {ORS = " "} /^[^#]/ {print} {next} END {ORS = ""; print "\n"}'
1039 ## -- >8 - <<SUPPORT FUNS | RUNNING>> - 8< -- ##
1041 # First of all, create new configuration and check whether it changed
1043 # Very easy checks for the operating system in order to be able to adjust paths
1044 # or similar very basic things which we need to be able to go at all
1045 os_early_setup
1047 # Check those tools right now that we need before including $rc
1048 msg 'Checking for basic utility set'
1049 check_tool awk "${awk:-`command -v awk`}"
1050 check_tool rm "${rm:-`command -v rm`}"
1051 check_tool tr "${tr:-`command -v tr`}"
1053 # Initialize the option set
1054 msg_nonl 'Setting up configuration options ... '
1055 option_setup
1056 msg 'done'
1058 # Include $rc, but only take from it what wasn't overwritten by the user from
1059 # within the command line or from a chosen fixed CONFIG=
1060 # Note we leave alone the values
1061 trap "exit 1" HUP INT TERM
1062 trap "${rm} -f ${tmp}" EXIT
1064 msg_nonl 'Joining in %s ... ' ${rc}
1065 option_join_rc
1066 msg 'done'
1068 # We need to know about that now, in order to provide utility overwrites etc.
1069 os_setup
1071 msg 'Checking for remaining set of utilities'
1072 check_tool grep "${grep:-`command -v grep`}"
1074 # Before we step ahead with the other utilities perform a path cleanup first.
1075 path_check PATH
1077 # awk(1) above
1078 check_tool basename "${basename:-`command -v basename`}"
1079 check_tool cat "${cat:-`command -v cat`}"
1080 check_tool chmod "${chmod:-`command -v chmod`}"
1081 check_tool cp "${cp:-`command -v cp`}"
1082 check_tool cmp "${cmp:-`command -v cmp`}"
1083 # grep(1) above
1084 check_tool mkdir "${mkdir:-`command -v mkdir`}"
1085 check_tool mv "${mv:-`command -v mv`}"
1086 # rm(1) above
1087 check_tool sed "${sed:-`command -v sed`}"
1088 check_tool sort "${sort:-`command -v sort`}"
1089 check_tool tee "${tee:-`command -v tee`}"
1091 check_tool chown "${chown:-`command -v chown`}" 1 ||
1092 check_tool chown "/sbin/chown" 1 ||
1093 check_tool chown "/usr/sbin/chown"
1095 check_tool make "${MAKE:-`command -v make`}"
1096 MAKE=${make}
1097 check_tool strip "${STRIP:-`command -v strip`}" 1 &&
1098 HAVE_STRIP=1 || HAVE_STRIP=0
1100 # For ./cc-test.sh only
1101 check_tool cksum "${cksum:-`command -v cksum`}"
1103 # Update OPT_ options now, in order to get possible inter-dependencies right
1104 option_update
1106 # (No functions since some shells loose non-exported variables in traps)
1107 trap "trap \"\" HUP INT TERM; exit 1" HUP INT TERM
1108 trap "trap \"\" HUP INT TERM EXIT;\
1109 ${rm} -rf ${newlst} ${tmp0}.* ${tmp0}* ${newmk} ${newev} ${newh}" EXIT
1111 # Our configuration options may at this point still contain shell snippets,
1112 # we need to evaluate them in order to get them expanded, and we need those
1113 # evaluated values not only in our new configuration file, but also at hand..
1114 msg_nonl 'Evaluating all configuration items ... '
1115 option_evaluate
1116 msg 'done'
1118 # Add the known utility and some other variables
1119 printf "#define VAL_UAGENT \"${VAL_SID}${VAL_MAILX}\"\n" >> ${newh}
1120 printf "VAL_UAGENT = ${VAL_SID}${VAL_MAILX}\n" >> ${newmk}
1122 printf "#define VAL_PRIVSEP \"${VAL_SID}${VAL_MAILX}-privsep\"\n" >> ${newh}
1123 printf "VAL_PRIVSEP = \$(VAL_UAGENT)-privsep\n" >> ${newmk}
1124 if feat_yes DOTLOCK; then
1125 printf "OPTIONAL_PRIVSEP = \$(VAL_PRIVSEP)\n" >> ${newmk}
1126 else
1127 printf "OPTIONAL_PRIVSEP =\n" >> ${newmk}
1130 for i in \
1131 SRCDIR \
1132 awk basename cat chmod chown cp cmp grep mkdir mv rm sed sort tee tr \
1133 MAKE MAKEFLAGS make SHELL strip \
1134 cksum; do
1135 eval j=\$${i}
1136 printf "${i} = ${j}\n" >> ${newmk}
1137 printf "${i}=${j}\n" >> ${newlst}
1138 printf "${i}=\"${j}\";export ${i}; " >> ${newev}
1139 done
1140 printf "\n" >> ${newev}
1142 # Build a basic set of INCS and LIBS according to user environment.
1143 C_INCLUDE_PATH="./:${SRCDIR}:${C_INCLUDE_PATH}"
1144 path_check C_INCLUDE_PATH -I _INCS
1145 INCS="${INCS} ${_INCS}"
1146 path_check LD_LIBRARY_PATH -L _LIBS
1147 LIBS="${LIBS} ${_LIBS}"
1148 unset _INCS _LIBS
1149 export C_INCLUDE_PATH LD_LIBRARY_PATH
1151 # Some environments need runtime path flags to be able to go at all
1152 ld_runtime_flags
1154 ## Detect CC, whether we can use it, and possibly which CFLAGS we can use
1156 cc_setup
1158 ${cat} > ${tmp}.c << \!
1159 #include <stdio.h>
1160 #include <string.h>
1161 static void doit(char const *s);
1163 main(int argc, char **argv){
1164 (void)argc;
1165 (void)argv;
1166 doit("Hello world");
1167 return 0;
1169 static void
1170 doit(char const *s){
1171 char buf[12];
1172 memcpy(buf, s, strlen(s) +1);
1173 puts(s);
1177 if "${CC}" ${INCS} ${CFLAGS} ${EXTRA_CFLAGS} ${LDFLAGS} ${EXTRA_LDFLAGS} \
1178 -o ${tmp2} ${tmp}.c ${LIBS}; then
1180 else
1181 msg 'ERROR: i cannot compile a "Hello world" via'
1182 msg ' %s' \
1183 "${CC} ${INCS} ${CFLAGS} ${EXTRA_CFLAGS} ${LDFLAGS} ${EXTRA_LDFLAGS} ${LIBS}"
1184 msg 'ERROR: Please read INSTALL, rerun'
1185 config_exit 1
1188 # This may also update ld_runtime_flags() (again)
1189 cc_flags
1191 for i in \
1192 INCS LIBS \
1193 ; do
1194 eval j=\$${i}
1195 printf -- "${i}=${j}\n" >> ${newlst}
1196 done
1197 for i in \
1198 CC \
1199 CFLAGS \
1200 LDFLAGS \
1201 PATH C_INCLUDE_PATH LD_LIBRARY_PATH \
1202 OSFULLSPEC \
1203 ; do
1204 eval j=\$${i}
1205 printf -- "${i} = ${j}\n" >> ${newmk}
1206 printf -- "${i}=${j}\n" >> ${newlst}
1207 done
1209 # Now finally check whether we already have a configuration and if so, whether
1210 # all those parameters are still the same.. or something has actually changed
1211 if [ -f ${lst} ] && ${cmp} ${newlst} ${lst} >/dev/null 2>&1; then
1212 echo 'Configuration is up-to-date'
1213 exit 0
1214 elif [ -f ${lst} ]; then
1215 echo 'Configuration has been updated..'
1216 ( eval "${MAKE} -f ./mk-config.mk clean" )
1217 echo
1218 else
1219 echo 'Shiny configuration..'
1222 # Time to redefine helper 1
1223 config_exit() {
1224 ${rm} -f ${lst} ${h} ${mk}
1225 exit ${1}
1228 ${mv} -f ${newlst} ${lst}
1229 ${mv} -f ${newev} ${ev}
1230 ${mv} -f ${newh} ${h}
1231 ${mv} -f ${newmk} ${mk}
1233 if [ -z "${VERBOSE}" ]; then
1234 printf -- "ECHO_CC = @echo ' 'CC \$(@);\n" >> ${mk}
1235 printf -- "ECHO_LINK = @echo ' 'LINK \$(@);\n" >> ${mk}
1236 printf -- "ECHO_GEN = @echo ' 'GEN \$(@);\n" >> ${mk}
1237 printf -- "ECHO_TEST = @\n" >> ${mk}
1238 printf -- "ECHO_CMD = @echo ' CMD';\n" >> ${mk}
1239 printf -- "ECHO_BLOCK_BEGIN = @( \n" >> ${mk}
1240 printf -- "ECHO_BLOCK_END = ) >/dev/null\n" >> ${mk}
1243 ## Compile and link checking
1245 tmp3=./${tmp0}3$$
1246 log=./mk-config.log
1247 lib=./mk-config.lib
1248 inc=./mk-config.inc
1249 makefile=./${tmp0}.mk
1251 # (No function since some shells loose non-exported variables in traps)
1252 trap "trap \"\" HUP INT TERM;\
1253 ${rm} -f ${lst} ${h} ${mk} ${lib} ${inc}; exit 1" HUP INT TERM
1254 trap "trap \"\" HUP INT TERM EXIT;\
1255 ${rm} -rf ${tmp0}.* ${tmp0}*" EXIT
1257 # Time to redefine helper 2
1258 msg() {
1259 fmt=${1}
1260 shift
1261 printf "*** ${fmt}\\n" "${@}"
1262 printf -- "${fmt}\\n" "${@}" >&5
1264 msg_nonl() {
1265 fmt=${1}
1266 shift
1267 printf "*** ${fmt}\\n" "${@}"
1268 printf -- "${fmt}" "${@}" >&5
1271 # !!
1272 exec 5>&2 > ${log} 2>&1
1274 echo "${LIBS}" > ${lib}
1275 echo "${INCS}" > ${inc}
1276 ${cat} > ${makefile} << \!
1277 .SUFFIXES: .o .c .x .y
1278 .c.o:
1279 $(CC) -I./ $(XINCS) $(CFLAGS) -c $(<)
1280 .c.x:
1281 $(CC) -I./ $(XINCS) -E $(<) > $(@)
1283 $(CC) -I./ $(XINCS) $(CFLAGS) $(LDFLAGS) -o $(@) $(<) $(XLIBS)
1286 ## Generics
1288 # May be multiline..
1289 echo >> ${h}
1290 [ -n "${OS_DEFINES}" ] && printf -- "${OS_DEFINES}" >> ${h}
1291 echo '#define VAL_BUILD_OS "'"${OS}"'"' >> ${h}
1292 echo '#define VAL_BUILD_OSENV "'"${OSENV}"'"' >> ${h}
1294 # Generate n_err_number OS mappings
1296 feat_yes DEVEL && NV= || NV=noverbose
1297 SRCDIR="${SRCDIR}" TARGET="${h}" awk="${awk}" \
1298 ${SHELL} "${SRCDIR}"make-errors.sh ${NV} config
1300 xrun_check oserrno 'OS error mapping table generated' || config_exit 1
1302 feat_def ALWAYS_UNICODE_LOCALE
1303 feat_def AMALGAMATION
1304 feat_def CROSS_BUILD
1305 feat_def DOCSTRINGS
1306 feat_def ERRORS
1308 feat_def ASAN_ADDRESS
1309 feat_def ASAN_MEMORY
1310 feat_def DEBUG
1311 feat_def DEVEL
1312 feat_def NYD2
1313 feat_def NOMEMDBG
1315 if xrun_check inline 'inline functions' \
1316 '#define HAVE_INLINE
1317 #define n_INLINE static inline' << \!
1318 static inline int ilf(int i){return ++i;}
1319 int main(void){return ilf(-1);}
1321 then
1323 elif xrun_check inline 'inline functions (via __inline)' \
1324 '#define HAVE_INLINE
1325 #define n_INLINE static __inline' << \!
1326 static __inline int ilf(int i){return ++i;}
1327 int main(void){return ilf(-1);}
1329 then
1333 ## Test for "basic" system-calls / functionality that is used by all parts
1334 ## of our program. Once this is done fork away BASE_LIBS and other BASE_*
1335 ## macros to be used by only the subprograms (potentially).
1337 if run_check clock_gettime 'clock_gettime(2)' \
1338 '#define HAVE_CLOCK_GETTIME' << \!
1339 #include <time.h>
1340 # include <errno.h>
1341 int main(void){
1342 struct timespec ts;
1344 if(!clock_gettime(CLOCK_REALTIME, &ts) || errno != ENOSYS)
1345 return 0;
1346 return 1;
1349 then
1351 elif run_check clock_gettime 'clock_gettime(2) (via -lrt)' \
1352 '#define HAVE_CLOCK_GETTIME' '-lrt' << \!
1353 #include <time.h>
1354 # include <errno.h>
1355 int main(void){
1356 struct timespec ts;
1358 if(!clock_gettime(CLOCK_REALTIME, &ts) || errno != ENOSYS)
1359 return 0;
1360 return 1;
1363 then
1365 elif run_check gettimeofday 'gettimeofday(2)' \
1366 '#define HAVE_GETTIMEOFDAY' << \!
1367 #include <stdio.h> /* For C89 NULL */
1368 #include <sys/time.h>
1369 # include <errno.h>
1370 int main(void){
1371 struct timeval tv;
1373 if(!gettimeofday(&tv, NULL) || errno != ENOSYS)
1374 return 0;
1375 return 1;
1378 then
1380 else
1381 have_no_subsecond_time=1
1384 if run_check nanosleep 'nanosleep(2)' \
1385 '#define HAVE_NANOSLEEP' << \!
1386 #include <time.h>
1387 # include <errno.h>
1388 int main(void){
1389 struct timespec ts;
1391 ts.tv_sec = 1;
1392 ts.tv_nsec = 100000;
1393 if(!nanosleep(&ts, NULL) || errno != ENOSYS)
1394 return 0;
1395 return 1;
1398 then
1400 elif run_check nanosleep 'nanosleep(2) (via -lrt)' \
1401 '#define HAVE_NANOSLEEP' '-lrt' << \!
1402 #include <time.h>
1403 # include <errno.h>
1404 int main(void){
1405 struct timespec ts;
1407 ts.tv_sec = 1;
1408 ts.tv_nsec = 100000;
1409 if(!nanosleep(&ts, NULL) || errno != ENOSYS)
1410 return 0;
1411 return 1;
1414 then
1416 # link_check is enough for this, that function is so old, trust the proto
1417 elif link_check sleep 'sleep(3)' \
1418 '#define HAVE_SLEEP' << \!
1419 #include <unistd.h>
1420 # include <errno.h>
1421 int main(void){
1422 if(!sleep(1) || errno != ENOSYS)
1423 return 0;
1424 return 1;
1427 then
1429 else
1430 msg 'ERROR: we require one of nanosleep(2) and sleep(3).'
1431 config_exit 1
1434 if run_check userdb 'gete?[gu]id(2), getpwuid(3), getpwnam(3)' << \!
1435 #include <pwd.h>
1436 #include <unistd.h>
1437 # include <errno.h>
1438 int main(void){
1439 struct passwd *pw;
1440 gid_t gid;
1441 uid_t uid;
1443 if((gid = getgid()) != 0)
1444 gid = getegid();
1445 if((uid = getuid()) != 0)
1446 uid = geteuid();
1447 if((pw = getpwuid(uid)) == NULL && errno == ENOSYS)
1448 return 1;
1449 if((pw = getpwnam("root")) == NULL && errno == ENOSYS)
1450 return 1;
1451 return 0;
1454 then
1456 else
1457 msg 'ERROR: we require user and group info / database searches.'
1458 msg 'That much Unix we indulge ourselfs.'
1459 config_exit 1
1462 if link_check ftruncate 'ftruncate(2)' \
1463 '#define HAVE_FTRUNCATE' << \!
1464 #include <unistd.h>
1465 #include <sys/types.h>
1466 int main(void){
1467 return (ftruncate(0, 0) != 0);
1470 then
1472 else
1473 msg 'ERROR: we require the ftruncate(2) system call.'
1474 config_exit 1
1477 if run_check sa_restart 'SA_RESTART (for sigaction(2))' << \!
1478 #include <signal.h>
1479 # include <errno.h>
1480 int main(void){
1481 struct sigaction nact, oact;
1483 nact.sa_handler = SIG_DFL;
1484 sigemptyset(&nact.sa_mask);
1485 nact.sa_flags = SA_RESTART;
1486 return !(!sigaction(SIGCHLD, &nact, &oact) || errno != ENOSYS);
1489 then
1491 else
1492 msg 'ERROR: we (yet) require the SA_RESTART flag for sigaction(2).'
1493 config_exit 1
1496 if link_check snprintf 'snprintf(3)' << \!
1497 #include <stdio.h>
1498 int main(void){
1499 char b[20];
1501 snprintf(b, sizeof b, "%s", "string");
1502 return 0;
1505 then
1507 else
1508 msg 'ERROR: we require the snprintf(3) function.'
1509 config_exit 1
1512 if link_check environ 'environ(3)' << \!
1513 #include <stdio.h> /* For C89 NULL */
1514 int main(void){
1515 extern char **environ;
1517 return environ[0] == NULL;
1520 then
1522 else
1523 msg 'ERROR: we require the environ(3) array for subprocess control.'
1524 config_exit 1
1527 if link_check setenv '(un)?setenv(3)' '#define HAVE_SETENV' << \!
1528 #include <stdlib.h>
1529 int main(void){
1530 setenv("s-mailx", "i want to see it cute!", 1);
1531 unsetenv("s-mailx");
1532 return 0;
1535 then
1537 elif link_check setenv 'putenv(3)' '#define HAVE_PUTENV' << \!
1538 #include <stdlib.h>
1539 int main(void){
1540 putenv("s-mailx=i want to see it cute!");
1541 return 0;
1544 then
1546 else
1547 msg 'ERROR: we require either the setenv(3) or putenv(3) functions.'
1548 config_exit 1
1551 if link_check termios 'termios.h and tc*(3) family' << \!
1552 #include <termios.h>
1553 int main(void){
1554 struct termios tios;
1556 tcgetattr(0, &tios);
1557 tcsetattr(0, TCSANOW | TCSADRAIN | TCSAFLUSH, &tios);
1558 return 0;
1561 then
1563 else
1564 msg 'ERROR: we require termios.h and the tc*() family of functions.'
1565 msg 'That much Unix we indulge ourselfs.'
1566 config_exit 1
1569 ## optional stuff
1571 if link_check vsnprintf 'vsnprintf(3)' << \!
1572 #include <stdarg.h>
1573 #include <stdio.h>
1574 static void dome(char *buf, size_t blen, ...){
1575 va_list ap;
1577 va_start(ap, blen);
1578 vsnprintf(buf, blen, "%s", ap);
1579 va_end(ap);
1581 int main(void){
1582 char b[20];
1584 dome(b, sizeof b, "string");
1585 return 0;
1588 then
1590 else
1591 feat_bail_required ERRORS
1594 if [ "${have_vsnprintf}" = yes ]; then
1595 __va_copy() {
1596 link_check va_copy "va_copy(3) (as ${2})" \
1597 "#define HAVE_N_VA_COPY
1598 #define n_va_copy ${2}" <<_EOT
1599 #include <stdarg.h>
1600 #include <stdio.h>
1601 #if ${1}
1602 # if defined __va_copy && !defined va_copy
1603 # define va_copy __va_copy
1604 # endif
1605 #endif
1606 static void dome2(char *buf, size_t blen, va_list src){
1607 va_list ap;
1609 va_copy(ap, src);
1610 vsnprintf(buf, blen, "%s", ap);
1611 va_end(ap);
1613 static void dome(char *buf, size_t blen, ...){
1614 va_list ap;
1616 va_start(ap, blen);
1617 dome2(buf, blen, ap);
1618 va_end(ap);
1620 int main(void){
1621 char b[20];
1623 dome(b, sizeof b, "string");
1624 return 0;
1626 _EOT
1628 __va_copy 0 va_copy || __va_copy 1 __va_copy
1631 run_check pathconf 'f?pathconf(2)' '#define HAVE_PATHCONF' << \!
1632 #include <unistd.h>
1633 #include <errno.h>
1634 int main(void){
1635 int rv = 0;
1637 errno = 0;
1638 rv |= !(pathconf(".", _PC_NAME_MAX) >= 0 || errno == 0 || errno != ENOSYS);
1639 errno = 0;
1640 rv |= !(pathconf(".", _PC_PATH_MAX) >= 0 || errno == 0 || errno != ENOSYS);
1642 /* Only link check */
1643 fpathconf(0, _PC_NAME_MAX);
1645 return rv;
1649 run_check pipe2 'pipe2(2)' '#define HAVE_PIPE2' << \!
1650 #include <fcntl.h>
1651 #include <unistd.h>
1652 # include <errno.h>
1653 int main(void){
1654 int fds[2];
1656 if(!pipe2(fds, O_CLOEXEC) || errno != ENOSYS)
1657 return 0;
1658 return 1;
1662 # We use this only then for now (need NOW+1)
1663 run_check utimensat 'utimensat(2)' '#define HAVE_UTIMENSAT' << \!
1664 #include <fcntl.h> /* For AT_* */
1665 #include <sys/stat.h>
1666 # include <errno.h>
1667 int main(void){
1668 struct timespec ts[2];
1670 ts[0].tv_nsec = UTIME_NOW;
1671 ts[1].tv_nsec = UTIME_OMIT;
1672 if(!utimensat(AT_FDCWD, "", ts, 0) || errno != ENOSYS)
1673 return 0;
1674 return 1;
1680 # XXX Add POSIX check once standardized
1681 if link_check posix_random 'arc4random(3)' '#define HAVE_POSIX_RANDOM 0' << \!
1682 #include <stdlib.h>
1683 int main(void){
1684 arc4random();
1685 return 0;
1688 then
1690 elif link_check getrandom 'getrandom(2) (in sys/random.h)' \
1691 '#define HAVE_GETRANDOM(B,S) getrandom(B, S, 0)
1692 #define HAVE_GETRANDOM_HEADER <sys/random.h>' <<\!
1693 #include <sys/random.h>
1694 int main(void){
1695 char buf[256];
1696 getrandom(buf, sizeof buf, 0);
1697 return 0;
1700 then
1702 elif link_check getrandom 'getrandom(2) (via syscall(2))' \
1703 '#define HAVE_GETRANDOM(B,S) syscall(SYS_getrandom, B, S, 0)
1704 #define HAVE_GETRANDOM_HEADER <sys/syscall.h>' <<\!
1705 #include <sys/syscall.h>
1706 int main(void){
1707 char buf[256];
1708 syscall(SYS_getrandom, buf, sizeof buf, 0);
1709 return 0;
1712 then
1714 elif [ -n "${have_no_subsecond_time}" ]; then
1715 msg 'ERROR: %s %s' 'without a native random' \
1716 'one of clock_gettime(2) and gettimeofday(2) is required.'
1717 config_exit 1
1721 link_check putc_unlocked 'putc_unlocked(3)' '#define HAVE_PUTC_UNLOCKED' <<\!
1722 #include <stdio.h>
1723 int main(void){
1724 putc_unlocked('@', stdout);
1725 return 0;
1729 link_check fchdir 'fchdir(3)' '#define HAVE_FCHDIR' << \!
1730 #include <unistd.h>
1731 int main(void){
1732 fchdir(0);
1733 return 0;
1737 if run_check realpath 'realpath(3)' '#define HAVE_REALPATH' << \!
1738 #include <stdlib.h>
1739 int main(void){
1740 char x_buf[4096], *x = realpath(".", x_buf);
1742 return (x != NULL) ? 0 : 1;
1745 then
1746 if run_check realpath_malloc 'realpath(3) takes NULL' \
1747 '#define HAVE_REALPATH_NULL' << \!
1748 #include <stdlib.h>
1749 int main(void){
1750 char *x = realpath(".", NULL);
1752 if(x != NULL)
1753 free(x);
1754 return (x != NULL) ? 0 : 1;
1757 then
1762 ## optional and selectable
1764 if feat_yes DOTLOCK; then
1765 if run_check readlink 'readlink(2)' << \!
1766 #include <unistd.h>
1767 # include <errno.h>
1768 int main(void){
1769 char buf[128];
1771 if(!readlink("here", buf, sizeof buf) || errno != ENOSYS)
1772 return 0;
1773 return 1;
1776 then
1778 else
1779 feat_bail_required DOTLOCK
1783 if feat_yes DOTLOCK; then
1784 if run_check fchown 'fchown(2)' << \!
1785 #include <unistd.h>
1786 # include <errno.h>
1787 int main(void){
1788 if(!fchown(0, 0, 0) || errno != ENOSYS)
1789 return 0;
1790 return 1;
1793 then
1795 else
1796 feat_bail_required DOTLOCK
1800 ## Now it is the time to fork away the BASE_ series
1802 ${rm} -f ${tmp}
1803 squeeze_em ${inc} ${tmp}
1804 ${mv} ${tmp} ${inc}
1805 squeeze_em ${lib} ${tmp}
1806 ${mv} ${tmp} ${lib}
1808 echo "BASE_LIBS = `${cat} ${lib}`" >> ${mk}
1809 echo "BASE_INCS = `${cat} ${inc}`" >> ${mk}
1811 ## The remains are expected to be used only by the main MUA binary!
1813 OPT_LOCALES=0
1814 link_check setlocale 'setlocale(3)' '#define HAVE_SETLOCALE' << \!
1815 #include <locale.h>
1816 int main(void){
1817 setlocale(LC_ALL, "");
1818 return 0;
1821 [ -n "${have_setlocale}" ] && OPT_LOCALES=1
1823 OPT_MULTIBYTE_CHARSETS=0
1824 OPT_WIDE_GLYPHS=0
1825 OPT_TERMINAL_CHARSET=0
1826 if [ -n "${have_setlocale}" ]; then
1827 link_check c90amend1 'ISO/IEC 9899:1990/Amendment 1:1995' \
1828 '#define HAVE_C90AMEND1' << \!
1829 #include <limits.h>
1830 #include <stdlib.h>
1831 #include <wchar.h>
1832 #include <wctype.h>
1833 int main(void){
1834 char mbb[MB_LEN_MAX + 1];
1835 wchar_t wc;
1837 iswprint(L'c');
1838 towupper(L'c');
1839 mbtowc(&wc, "x", 1);
1840 mbrtowc(&wc, "x", 1, NULL);
1841 wctomb(mbb, wc);
1842 return (mblen("\0", 1) == 0);
1845 [ -n "${have_c90amend1}" ] && OPT_MULTIBYTE_CHARSETS=1
1847 if [ -n "${have_c90amend1}" ]; then
1848 link_check wcwidth 'wcwidth(3)' '#define HAVE_WCWIDTH' << \!
1849 #include <wchar.h>
1850 int main(void){
1851 wcwidth(L'c');
1852 return 0;
1855 [ -n "${have_wcwidth}" ] && OPT_WIDE_GLYPHS=1
1858 link_check nl_langinfo 'nl_langinfo(3)' '#define HAVE_NL_LANGINFO' << \!
1859 #include <langinfo.h>
1860 #include <stdlib.h>
1861 int main(void){
1862 nl_langinfo(DAY_1);
1863 return (nl_langinfo(CODESET) == NULL);
1866 [ -n "${have_nl_langinfo}" ] && OPT_TERMINAL_CHARSET=1
1867 fi # have_setlocale
1869 link_check fnmatch 'fnmatch(3)' '#define HAVE_FNMATCH' << \!
1870 #include <fnmatch.h>
1871 int main(void){
1872 return (fnmatch("*", ".", FNM_PATHNAME | FNM_PERIOD) == FNM_NOMATCH);
1876 link_check dirent_d_type 'struct dirent.d_type' '#define HAVE_DIRENT_TYPE' << \!
1877 #include <dirent.h>
1878 int main(void){
1879 struct dirent de;
1880 return !(de.d_type == DT_UNKNOWN ||
1881 de.d_type == DT_DIR || de.d_type == DT_LNK);
1885 ## optional and selectable
1887 if feat_yes ICONV; then
1888 ${cat} > ${tmp2}.c << \!
1889 #include <stdio.h> /* For C89 NULL */
1890 #include <iconv.h>
1891 int main(void){
1892 iconv_t id;
1894 id = iconv_open("foo", "bar");
1895 iconv(id, NULL, NULL, NULL, NULL);
1896 iconv_close(id);
1897 return 0;
1900 < ${tmp2}.c link_check iconv 'iconv(3) functionality' \
1901 '#define HAVE_ICONV' ||
1902 < ${tmp2}.c link_check iconv 'iconv(3) functionality (via -liconv)' \
1903 '#define HAVE_ICONV' '-liconv' ||
1904 feat_bail_required ICONV
1905 else
1906 echo '/* OPT_ICONV=0 */' >> ${h}
1907 fi # feat_yes ICONV
1909 if feat_yes SOCKETS || feat_yes SPAM_SPAMD; then
1910 ${cat} > ${tmp2}.c << \!
1911 #include <sys/types.h>
1912 #include <sys/socket.h>
1913 #include <sys/un.h>
1914 # include <errno.h>
1915 int main(void){
1916 struct sockaddr_un soun;
1918 if(socket(AF_UNIX, SOCK_STREAM, 0) == -1 && errno == ENOSYS)
1919 return 1;
1920 if(connect(0, (struct sockaddr*)&soun, 0) == -1 && errno == ENOSYS)
1921 return 1;
1922 if(shutdown(0, SHUT_RD | SHUT_WR | SHUT_RDWR) == -1 && errno == ENOSYS)
1923 return 1;
1924 return 0;
1928 < ${tmp2}.c run_check af_unix 'AF_UNIX sockets' \
1929 '#define HAVE_UNIX_SOCKETS' ||
1930 < ${tmp2}.c run_check af_unix 'AF_UNIX sockets (via -lnsl)' \
1931 '#define HAVE_UNIX_SOCKETS' '-lnsl' ||
1932 < ${tmp2}.c run_check af_unix 'AF_UNIX sockets (via -lsocket -lnsl)' \
1933 '#define HAVE_UNIX_SOCKETS' '-lsocket -lnsl'
1936 if feat_yes SOCKETS; then
1937 ${cat} > ${tmp2}.c << \!
1938 #include <sys/types.h>
1939 #include <sys/socket.h>
1940 #include <netinet/in.h>
1941 # include <errno.h>
1942 int main(void){
1943 struct sockaddr s;
1945 if(socket(AF_INET, SOCK_STREAM, 0) == -1 && errno == ENOSYS)
1946 return 1;
1947 if(connect(0, &s, 0) == -1 && errno == ENOSYS)
1948 return 1;
1949 return 0;
1953 < ${tmp2}.c run_check sockets 'sockets' \
1954 '#define HAVE_SOCKETS' ||
1955 < ${tmp2}.c run_check sockets 'sockets (via -lnsl)' \
1956 '#define HAVE_SOCKETS' '-lnsl' ||
1957 < ${tmp2}.c run_check sockets 'sockets (via -lsocket -lnsl)' \
1958 '#define HAVE_SOCKETS' '-lsocket -lnsl' ||
1959 feat_bail_required SOCKETS
1960 else
1961 echo '/* OPT_SOCKETS=0 */' >> ${h}
1962 fi # feat_yes SOCKETS
1964 if feat_yes SOCKETS; then
1965 link_check getaddrinfo 'getaddrinfo(3)' \
1966 '#define HAVE_GETADDRINFO' << \!
1967 #include <sys/types.h>
1968 #include <sys/socket.h>
1969 #include <stdio.h>
1970 #include <netdb.h>
1971 int main(void){
1972 struct addrinfo a, *ap;
1973 int lrv;
1975 switch((lrv = getaddrinfo("foo", "0", &a, &ap))){
1976 case EAI_NONAME:
1977 case EAI_SERVICE:
1978 default:
1979 fprintf(stderr, "%s\n", gai_strerror(lrv));
1980 case 0:
1981 break;
1983 return 0;
1988 if feat_yes SOCKETS && [ -z "${have_getaddrinfo}" ]; then
1989 compile_check arpa_inet_h '<arpa/inet.h>' \
1990 '#define HAVE_ARPA_INET_H' << \!
1991 #include <sys/types.h>
1992 #include <sys/socket.h>
1993 #include <netdb.h>
1994 #include <netinet/in.h>
1995 #include <arpa/inet.h>
1998 ${cat} > ${tmp2}.c << \!
1999 #include <sys/types.h>
2000 #include <sys/socket.h>
2001 #include <stdio.h>
2002 #include <string.h>
2003 #include <netdb.h>
2004 #include <netinet/in.h>
2005 #ifdef HAVE_ARPA_INET_H
2006 #include <arpa/inet.h>
2007 #endif
2008 int main(void){
2009 struct sockaddr_in servaddr;
2010 unsigned short portno;
2011 struct servent *ep;
2012 struct hostent *hp;
2013 struct in_addr **pptr;
2015 portno = 0;
2016 if((ep = getservbyname("POPPY-PORT", "tcp")) != NULL)
2017 portno = (unsigned short)ep->s_port;
2019 if((hp = gethostbyname("POPPY-HOST")) != NULL){
2020 pptr = (struct in_addr**)hp->h_addr_list;
2021 if(hp->h_addrtype != AF_INET)
2022 fprintf(stderr, "au\n");
2023 }else{
2024 switch(h_errno){
2025 case HOST_NOT_FOUND:
2026 case TRY_AGAIN:
2027 case NO_RECOVERY:
2028 case NO_DATA:
2029 break;
2030 default:
2031 fprintf(stderr, "au\n");
2032 break;
2036 memset(&servaddr, 0, sizeof servaddr);
2037 servaddr.sin_family = AF_INET;
2038 servaddr.sin_port = htons(portno);
2039 memcpy(&servaddr.sin_addr, *pptr, sizeof(struct in_addr));
2040 fprintf(stderr, "Would connect to %s:%d ...\n",
2041 inet_ntoa(**pptr), (int)portno);
2042 return 0;
2046 < ${tmp2}.c link_check gethostbyname 'get(serv|host)byname(3)' ||
2047 < ${tmp2}.c link_check gethostbyname \
2048 'get(serv|host)byname(3) (via -nsl)' '' '-lnsl' ||
2049 < ${tmp2}.c link_check gethostbyname \
2050 'get(serv|host)byname(3) (via -lsocket -nsl)' \
2051 '' '-lsocket -lnsl' ||
2052 feat_bail_required SOCKETS
2055 feat_yes SOCKETS &&
2056 run_check setsockopt 'setsockopt(2)' '#define HAVE_SETSOCKOPT' << \!
2057 #include <sys/socket.h>
2058 #include <stdlib.h>
2059 # include <errno.h>
2060 int main(void){
2061 int sockfd = 3;
2063 if(setsockopt(sockfd, SOL_SOCKET, SO_KEEPALIVE, NULL, 0) == -1 &&
2064 errno == ENOSYS)
2065 return 1;
2066 return 0;
2070 feat_yes SOCKETS && [ -n "${have_setsockopt}" ] &&
2071 link_check so_sndtimeo 'SO_SNDTIMEO' '#define HAVE_SO_SNDTIMEO' << \!
2072 #include <sys/socket.h>
2073 #include <stdlib.h>
2074 int main(void){
2075 struct timeval tv;
2076 int sockfd = 3;
2078 tv.tv_sec = 42;
2079 tv.tv_usec = 21;
2080 setsockopt(sockfd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof tv);
2081 setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof tv);
2082 return 0;
2086 feat_yes SOCKETS && [ -n "${have_setsockopt}" ] &&
2087 link_check so_linger 'SO_LINGER' '#define HAVE_SO_LINGER' << \!
2088 #include <sys/socket.h>
2089 #include <stdlib.h>
2090 int main(void){
2091 struct linger li;
2092 int sockfd = 3;
2094 li.l_onoff = 1;
2095 li.l_linger = 42;
2096 setsockopt(sockfd, SOL_SOCKET, SO_LINGER, &li, sizeof li);
2097 return 0;
2101 if feat_yes SSL; then # {{{
2102 # {{{ LibreSSL decided to define OPENSSL_VERSION_NUMBER with a useless value
2103 # instead of keeping it at the one that corresponds to the OpenSSL at fork
2104 # time: we need to test it first in order to get things right
2105 if compile_check _xssl 'TLS/SSL (LibreSSL)' \
2106 '#define HAVE_SSL
2107 #define HAVE_XSSL
2108 #define HAVE_XSSL_RESSL
2109 #define HAVE_XSSL_OPENSSL 0' << \!
2110 #include <openssl/opensslv.h>
2111 #ifdef LIBRESSL_VERSION_NUMBER
2112 #else
2113 # error nope
2114 #endif
2116 then
2117 ossl_v1_1=
2118 # TODO OPENSSL_IS_BORINGSSL, but never tried that one!
2119 elif compile_check _xssl 'TLS/SSL (OpenSSL >= v1.1.0)' \
2120 '#define HAVE_SSL
2121 #define HAVE_XSSL
2122 #define HAVE_XSSL_OPENSSL 0x10100' << \!
2123 #include <openssl/opensslv.h>
2124 #if OPENSSL_VERSION_NUMBER + 0 >= 0x10100000L
2125 #else
2126 # error nope
2127 #endif
2129 then
2130 ossl_v1_1=1
2131 elif compile_check _xssl 'TLS/SSL (OpenSSL)' \
2132 '#define HAVE_SSL
2133 #define HAVE_XSSL
2134 #define HAVE_XSSL_OPENSSL 0x10000' << \!
2135 #include <openssl/opensslv.h>
2136 #ifdef OPENSSL_VERSION_NUMBER
2137 #else
2138 # error nope
2139 #endif
2141 then
2142 ossl_v1_1=
2143 else
2144 feat_bail_required SSL
2145 fi # }}}
2147 if feat_yes SSL; then # {{{
2148 if [ -n "${ossl_v1_1}" ]; then
2149 without_check yes xssl 'TLS/SSL (new style *_client_method(3ssl))' \
2150 '#define n_XSSL_CLIENT_METHOD TLS_client_method' \
2151 '-lssl -lcrypto'
2152 elif link_check xssl 'TLS/SSL (new style *_client_method(3ssl))' \
2153 '#define n_XSSL_CLIENT_METHOD TLS_client_method' \
2154 '-lssl -lcrypto' << \!
2155 #include <openssl/ssl.h>
2156 #include <openssl/err.h>
2157 #include <openssl/x509v3.h>
2158 #include <openssl/x509.h>
2159 #include <openssl/rand.h>
2160 #ifdef OPENSSL_NO_TLS1 /* TODO only deduced from OPENSSL_NO_SSL[23]! */
2161 # error We need TLSv1.
2162 #endif
2163 int main(void){
2164 SSL_CTX *ctx = SSL_CTX_new(TLS_client_method());
2166 SSL_CTX_free(ctx);
2167 PEM_read_PrivateKey(0, 0, 0, 0);
2168 return 0;
2171 then
2173 elif link_check xssl 'TLS/SSL (old style *_client_method(3ssl))' \
2174 '#define n_XSSL_CLIENT_METHOD SSLv23_client_method' \
2175 '-lssl -lcrypto' << \!
2176 #include <openssl/ssl.h>
2177 #include <openssl/err.h>
2178 #include <openssl/x509v3.h>
2179 #include <openssl/x509.h>
2180 #include <openssl/rand.h>
2181 #if defined OPENSSL_NO_SSL3 &&\
2182 defined OPENSSL_NO_TLS1 /* TODO only deduced from OPENSSL_NO_SSL[23]! */
2183 # error We need one of SSLv3 and TLSv1.
2184 #endif
2185 int main(void){
2186 SSL_CTX *ctx = SSL_CTX_new(SSLv23_client_method());
2188 SSL_CTX_free(ctx);
2189 PEM_read_PrivateKey(0, 0, 0, 0);
2190 return 0;
2193 then
2195 else
2196 feat_bail_required SSL
2198 fi # }}}
2200 if feat_yes SSL; then # {{{
2201 if [ -n "${ossl_v1_1}" ]; then
2202 without_check yes xssl_stack_of 'TLS/SSL STACK_OF()' \
2203 '#define HAVE_XSSL_STACK_OF'
2204 elif compile_check xssl_stack_of 'TLS/SSL STACK_OF()' \
2205 '#define HAVE_XSSL_STACK_OF' << \!
2206 #include <stdio.h> /* For C89 NULL */
2207 #include <openssl/ssl.h>
2208 #include <openssl/err.h>
2209 #include <openssl/x509v3.h>
2210 #include <openssl/x509.h>
2211 #include <openssl/rand.h>
2212 int main(void){
2213 STACK_OF(GENERAL_NAME) *gens = NULL;
2215 printf("%p", gens); /* to use it */
2216 return 0;
2219 then
2223 if [ -n "${ossl_v1_1}" ]; then
2224 without_check yes xssl_conf 'TLS/SSL OpenSSL_modules_load_file()' \
2225 '#define HAVE_XSSL_CONFIG'
2226 elif link_check xssl_conf 'TLS/SSL OpenSSL_modules_load_file() support' \
2227 '#define HAVE_XSSL_CONFIG' << \!
2228 #include <stdio.h> /* For C89 NULL */
2229 #include <openssl/conf.h>
2230 int main(void){
2231 CONF_modules_load_file(NULL, NULL, CONF_MFLAGS_IGNORE_MISSING_FILE);
2232 CONF_modules_free();
2233 return 0;
2236 then
2240 if [ -n "${ossl_v1_1}" ]; then
2241 without_check yes xssl_conf_ctx 'TLS/SSL SSL_CONF_CTX support' \
2242 '#define HAVE_XSSL_CONF_CTX'
2243 elif link_check xssl_conf_ctx 'TLS/SSL SSL_CONF_CTX support' \
2244 '#define HAVE_XSSL_CONF_CTX' << \!
2245 #include <openssl/ssl.h>
2246 #include <openssl/err.h>
2247 int main(void){
2248 SSL_CTX *ctx = SSL_CTX_new(n_XSSL_CLIENT_METHOD());
2249 SSL_CONF_CTX *cctx = SSL_CONF_CTX_new();
2251 SSL_CONF_CTX_set_flags(cctx,
2252 SSL_CONF_FLAG_FILE | SSL_CONF_FLAG_CLIENT |
2253 SSL_CONF_FLAG_CERTIFICATE | SSL_CONF_FLAG_SHOW_ERRORS);
2254 SSL_CONF_CTX_set_ssl_ctx(cctx, ctx);
2255 SSL_CONF_cmd(cctx, "Protocol", "ALL");
2256 SSL_CONF_CTX_finish(cctx);
2257 SSL_CONF_CTX_free(cctx);
2258 SSL_CTX_free(ctx);
2259 return 0;
2262 then
2266 if [ -n "${ossl_v1_1}" ]; then
2267 without_check no xssl_rand_egd 'TLS/SSL RAND_egd(3ssl)' \
2268 '#define HAVE_XSSL_RAND_EGD'
2269 elif link_check xssl_rand_egd 'TLS/SSL RAND_egd(3ssl)' \
2270 '#define HAVE_XSSL_RAND_EGD' << \!
2271 #include <openssl/rand.h>
2272 int main(void){
2273 return RAND_egd("some.where") > 0;
2276 then
2280 if feat_yes SSL_ALL_ALGORITHMS; then
2281 if [ -n "${ossl_v1_1}" ]; then
2282 without_check yes ssl_all_algo 'TLS/SSL all-algorithms support' \
2283 '#define HAVE_SSL_ALL_ALGORITHMS'
2284 elif link_check ssl_all_algo 'TLS/SSL all-algorithms support' \
2285 '#define HAVE_SSL_ALL_ALGORITHMS' << \!
2286 #include <openssl/evp.h>
2287 int main(void){
2288 OpenSSL_add_all_algorithms();
2289 EVP_get_cipherbyname("two cents i never exist");
2290 EVP_cleanup();
2291 return 0;
2294 then
2296 else
2297 feat_bail_required SSL_ALL_ALGORITHMS
2300 fi # feat_yes SSL }}}
2302 if feat_yes SSL && feat_yes MD5 && feat_no NOEXTMD5; then # {{{
2303 run_check ssl_md5 'MD5 digest in the used crypto library' \
2304 '#define HAVE_XSSL_MD5' << \!
2305 #include <stdlib.h>
2306 #include <string.h>
2307 #include <openssl/md5.h>
2308 int main(void){
2309 char const dat[] = "abrakadabrafidibus";
2310 char dig[16], hex[16 * 2];
2311 MD5_CTX ctx;
2312 size_t i, j;
2314 memset(dig, 0, sizeof(dig));
2315 memset(hex, 0, sizeof(hex));
2316 MD5_Init(&ctx);
2317 MD5_Update(&ctx, dat, sizeof(dat) - 1);
2318 MD5_Final(dig, &ctx);
2320 #define hexchar(n) ((n) > 9 ? (n) - 10 + 'a' : (n) + '0')
2321 for(i = 0; i < sizeof(hex) / 2; i++){
2322 j = i << 1;
2323 hex[j] = hexchar((dig[i] & 0xf0) >> 4);
2324 hex[++j] = hexchar(dig[i] & 0x0f);
2326 return !!memcmp("6d7d0a3d949da2e96f2aa010f65d8326", hex, sizeof(hex));
2329 fi # }}}
2330 else
2331 echo '/* OPT_SSL=0 */' >> ${h}
2332 fi # }}} feat_yes SSL
2334 if [ "${have_xssl}" = yes ]; then
2335 OPT_SMIME=1
2336 else
2337 OPT_SMIME=0
2339 feat_def SMIME
2341 feat_def SMTP
2342 feat_def POP3
2343 feat_def IMAP
2345 if feat_yes GSSAPI; then
2346 ${cat} > ${tmp2}.c << \!
2347 #include <gssapi/gssapi.h>
2348 int main(void){
2349 gss_import_name(0, 0, GSS_C_NT_HOSTBASED_SERVICE, 0);
2350 gss_init_sec_context(0,0,0,0,0,0,0,0,0,0,0,0,0);
2351 return 0;
2354 ${sed} -e '1s/gssapi\///' < ${tmp2}.c > ${tmp3}.c
2356 if command -v krb5-config >/dev/null 2>&1; then
2357 i=`command -v krb5-config`
2358 GSS_LIBS="`CFLAGS= ${i} --libs gssapi`"
2359 GSS_INCS="`CFLAGS= ${i} --cflags`"
2360 i='GSS-API via krb5-config(1)'
2361 else
2362 GSS_LIBS='-lgssapi'
2363 GSS_INCS=
2364 i='GSS-API in gssapi/gssapi.h, libgssapi'
2366 if < ${tmp2}.c link_check gss \
2367 "${i}" '#define HAVE_GSSAPI' "${GSS_LIBS}" "${GSS_INCS}" ||\
2368 < ${tmp3}.c link_check gss \
2369 'GSS-API in gssapi.h, libgssapi' \
2370 '#define HAVE_GSSAPI
2371 #define GSSAPI_REG_INCLUDE' \
2372 '-lgssapi' ||\
2373 < ${tmp2}.c link_check gss 'GSS-API in libgssapi_krb5' \
2374 '#define HAVE_GSSAPI' \
2375 '-lgssapi_krb5' ||\
2376 < ${tmp3}.c link_check gss \
2377 'GSS-API in libgssapi, OpenBSD-style (pre 5.3)' \
2378 '#define HAVE_GSSAPI
2379 #define GSS_REG_INCLUDE' \
2380 '-lgssapi -lkrb5 -lcrypto' \
2381 '-I/usr/include/kerberosV' ||\
2382 < ${tmp2}.c link_check gss 'GSS-API in libgss' \
2383 '#define HAVE_GSSAPI' \
2384 '-lgss' ||\
2385 link_check gss 'GSS-API in libgssapi_krb5, old-style' \
2386 '#define HAVE_GSSAPI
2387 #define GSSAPI_OLD_STYLE' \
2388 '-lgssapi_krb5' << \!
2389 #include <gssapi/gssapi.h>
2390 #include <gssapi/gssapi_generic.h>
2391 int main(void){
2392 gss_import_name(0, 0, gss_nt_service_name, 0);
2393 gss_init_sec_context(0,0,0,0,0,0,0,0,0,0,0,0,0);
2394 return 0;
2397 then
2399 else
2400 feat_bail_required GSSAPI
2402 else
2403 echo '/* OPT_GSSAPI=0 */' >> ${h}
2404 fi # feat_yes GSSAPI
2406 feat_def NETRC
2407 feat_def AGENT
2409 if feat_yes IDNA; then
2410 if link_check idna 'GNU Libidn' '#define HAVE_IDNA HAVE_IDNA_LIBIDNA' \
2411 '-lidn' << \!
2412 #include <idna.h>
2413 #include <idn-free.h>
2414 #include <stringprep.h>
2415 int main(void){
2416 char *utf8, *idna_ascii, *idna_utf8;
2418 utf8 = stringprep_locale_to_utf8("does.this.work");
2419 if (idna_to_ascii_8z(utf8, &idna_ascii, IDNA_USE_STD3_ASCII_RULES)
2420 != IDNA_SUCCESS)
2421 return 1;
2422 idn_free(idna_ascii);
2423 /* (Rather link check only here) */
2424 idna_utf8 = stringprep_convert(idna_ascii, "UTF-8", "de_DE");
2425 return 0;
2428 then
2430 elif link_check idna 'idnkit' '#define HAVE_IDNA HAVE_IDNA_IDNKIT' \
2431 '-lidnkit' << \!
2432 #include <stdio.h>
2433 #include <idn/api.h>
2434 #include <idn/result.h>
2435 int main(void){
2436 idn_result_t r;
2437 char ace_name[256];
2438 char local_name[256];
2440 r = idn_encodename(IDN_ENCODE_APP, "does.this.work", ace_name,
2441 sizeof(ace_name));
2442 if (r != idn_success) {
2443 fprintf(stderr, "idn_encodename failed: %s\n", idn_result_tostring(r));
2444 return 1;
2446 r = idn_decodename(IDN_DECODE_APP, ace_name, local_name, sizeof(local_name));
2447 if (r != idn_success) {
2448 fprintf(stderr, "idn_decodename failed: %s\n", idn_result_tostring(r));
2449 return 1;
2451 return 0;
2454 then
2456 else
2457 feat_bail_required IDNA
2460 if [ -n "${have_idna}" ]; then
2461 echo '#define HAVE_IDNA_LIBIDNA 0' >> ${h}
2462 echo '#define HAVE_IDNA_IDNKIT 1' >> ${h}
2464 else
2465 echo '/* OPT_IDNA=0 */' >> ${h}
2468 feat_def IMAP_SEARCH
2470 if feat_yes REGEX; then
2471 if link_check regex 'regular expressions' '#define HAVE_REGEX' << \!
2472 #include <regex.h>
2473 #include <stdlib.h>
2474 int main(void){
2475 size_t xret;
2476 int status;
2477 regex_t re;
2479 status = regcomp(&re, ".*bsd", REG_EXTENDED | REG_ICASE | REG_NOSUB);
2480 xret = regerror(status, &re, NULL, 0);
2481 status = regexec(&re, "plan9", 0,NULL, 0);
2482 regfree(&re);
2483 return !(status == REG_NOMATCH);
2486 then
2488 else
2489 feat_bail_required REGEX
2491 else
2492 echo '/* OPT_REGEX=0 */' >> ${h}
2495 if feat_yes MLE && [ -n "${have_c90amend1}" ]; then
2496 have_mle=1
2497 echo '#define HAVE_MLE' >> ${h}
2498 else
2499 feat_bail_required MLE
2500 echo '/* OPT_MLE=0 */' >> ${h}
2503 # Generic have-a-line-editor switch for those who need it below
2504 if [ -n "${have_mle}" ]; then
2505 have_cle=1
2508 if [ -n "${have_cle}" ] && feat_yes HISTORY; then
2509 echo '#define HAVE_HISTORY' >> ${h}
2510 else
2511 echo '/* OPT_HISTORY=0 */' >> ${h}
2514 if [ -n "${have_mle}" ] && feat_yes KEY_BINDINGS; then
2515 echo '#define HAVE_KEY_BINDINGS' >> ${h}
2516 else
2517 echo '/* OPT_KEY_BINDINGS=0 */' >> ${h}
2520 if feat_yes TERMCAP; then
2521 __termcaplib() {
2522 link_check termcap "termcap(5) (via ${4})" \
2523 "#define HAVE_TERMCAP${3}" "${1}" << _EOT
2524 #include <stdio.h>
2525 #include <stdlib.h>
2526 ${2}
2527 #include <term.h>
2528 #define UNCONST(P) ((void*)(unsigned long)(void const*)(P))
2529 static int my_putc(int c){return putchar(c);}
2530 int main(void){
2531 char buf[1024+512], cmdbuf[2048], *cpb, *r1;
2532 int r2 = OK, r3 = ERR;
2534 tgetent(buf, getenv("TERM"));
2535 cpb = cmdbuf;
2536 r1 = tgetstr(UNCONST("cm"), &cpb);
2537 tgoto(r1, 1, 1);
2538 r2 = tgetnum(UNCONST("Co"));
2539 r3 = tgetflag(UNCONST("ut"));
2540 tputs("cr", 1, &my_putc);
2541 return (r1 == NULL || r2 == -1 || r3 == 0);
2543 _EOT
2546 __terminfolib() {
2547 link_check terminfo "terminfo(5) (via ${2})" \
2548 '#define HAVE_TERMCAP
2549 #define HAVE_TERMCAP_CURSES
2550 #define HAVE_TERMINFO' "${1}" << _EOT
2551 #include <stdio.h>
2552 #include <curses.h>
2553 #include <term.h>
2554 #define UNCONST(P) ((void*)(unsigned long)(void const*)(P))
2555 static int my_putc(int c){return putchar(c);}
2556 int main(void){
2557 int er, r0, r1, r2;
2558 char *r3, *tp;
2560 er = OK;
2561 r0 = setupterm(NULL, 1, &er);
2562 r1 = tigetflag(UNCONST("bce"));
2563 r2 = tigetnum(UNCONST("colors"));
2564 r3 = tigetstr(UNCONST("cr"));
2565 tp = tparm(r3, NULL, NULL, 0,0,0,0,0,0,0);
2566 tputs(tp, 1, &my_putc);
2567 return (r0 == ERR || r1 == -1 || r2 == -2 || r2 == -1 ||
2568 r3 == (char*)-1 || r3 == NULL);
2570 _EOT
2573 if feat_yes TERMCAP_VIA_TERMINFO; then
2574 __terminfolib -ltinfo -ltinfo ||
2575 __terminfolib -lcurses -lcurses ||
2576 __terminfolib -lcursesw -lcursesw ||
2577 feat_bail_required TERMCAP_VIA_TERMINFO
2580 if [ -z "${have_terminfo}" ]; then
2581 __termcaplib -ltermcap '' '' '-ltermcap' ||
2582 __termcaplib -ltermcap '#include <curses.h>' '
2583 #define HAVE_TERMCAP_CURSES' \
2584 'curses.h / -ltermcap' ||
2585 __termcaplib -lcurses '#include <curses.h>' '
2586 #define HAVE_TERMCAP_CURSES' \
2587 'curses.h / -lcurses' ||
2588 __termcaplib -lcursesw '#include <curses.h>' '
2589 #define HAVE_TERMCAP_CURSES' \
2590 'curses.h / -lcursesw' ||
2591 feat_bail_required TERMCAP
2593 if [ -n "${have_termcap}" ]; then
2594 run_check tgetent_null \
2595 "tgetent(3) of termcap(5) takes NULL buffer" \
2596 "#define HAVE_TGETENT_NULL_BUF" << _EOT
2597 #include <stdio.h> /* For C89 NULL */
2598 #include <stdlib.h>
2599 #ifdef HAVE_TERMCAP_CURSES
2600 # include <curses.h>
2601 #endif
2602 #include <term.h>
2603 int main(void){
2604 tgetent(NULL, getenv("TERM"));
2605 return 0;
2607 _EOT
2610 else
2611 echo '/* OPT_TERMCAP=0 */' >> ${h}
2612 echo '/* OPT_TERMCAP_VIA_TERMINFO=0 */' >> ${h}
2615 if feat_def SPAM_SPAMC; then
2616 if command -v spamc >/dev/null 2>&1; then
2617 echo "#define SPAM_SPAMC_PATH \"`command -v spamc`\"" >> ${h}
2621 if feat_yes SPAM_SPAMD && [ -n "${have_af_unix}" ]; then
2622 echo '#define HAVE_SPAM_SPAMD' >> ${h}
2623 else
2624 feat_bail_required SPAM_SPAMD
2625 echo '/* OPT_SPAM_SPAMD=0 */' >> ${h}
2628 feat_def SPAM_FILTER
2630 if feat_yes SPAM_SPAMC || feat_yes SPAM_SPAMD || feat_yes SPAM_FILTER; then
2631 echo '#define HAVE_SPAM' >> ${h}
2632 else
2633 echo '/* HAVE_SPAM */' >> ${h}
2636 if feat_yes QUOTE_FOLD &&\
2637 [ -n "${have_c90amend1}" ] && [ -n "${have_wcwidth}" ]; then
2638 echo '#define HAVE_QUOTE_FOLD' >> ${h}
2639 else
2640 feat_bail_required QUOTE_FOLD
2641 echo '/* OPT_QUOTE_FOLD=0 */' >> ${h}
2644 feat_def FILTER_HTML_TAGSOUP
2645 feat_def COLOUR
2646 feat_def DOTLOCK
2647 feat_def MD5
2648 feat_def NOMEMDBG
2650 ## Summarizing
2652 ${rm} -f ${tmp}
2653 squeeze_em ${inc} ${tmp}
2654 ${mv} ${tmp} ${inc}
2655 squeeze_em ${lib} ${tmp}
2656 ${mv} ${tmp} ${lib}
2658 # mk-config.h
2659 ${mv} ${h} ${tmp}
2660 printf '#ifndef n_MK_CONFIG_H\n# define n_MK_CONFIG_H 1\n' > ${h}
2661 ${cat} ${tmp} >> ${h}
2662 ${rm} -f ${tmp}
2663 printf '\n' >> ${h}
2665 # Create the string that is used by *features* and `version'.
2666 # Take this nice opportunity and generate a visual listing of included and
2667 # non-included features for the person who runs the configuration
2668 msg '\nThe following features are included (+) or not (-):'
2669 set -- ${OPTIONS_DETECT} ${OPTIONS} ${OPTIONS_XTRA}
2670 printf '/* The "feature string" */\n' >> ${h}
2671 # Because + is expanded by *folder* if first in "echo $features", put something
2672 printf '#define VAL_FEATURES_CNT '${#}'\n#define VAL_FEATURES "#' >> ${h}
2673 sep=
2674 for opt
2676 sdoc=`option_doc_of ${opt}`
2677 [ -z "${sdoc}" ] && continue
2678 sopt="`echo ${opt} | ${tr} '[A-Z]_' '[a-z]-'`"
2679 feat_yes ${opt} && sign=+ || sign=-
2680 printf -- "${sep}${sign}${sopt}" >> ${h}
2681 sep=','
2682 msg " %s %s: %s" ${sign} ${sopt} "${sdoc}"
2683 done
2684 # TODO instead of using sh+tr+awk+printf, use awk, drop option_doc_of, inc here
2685 #exec 5>&1 >>${h}
2686 #${awk} -v opts="${OPTIONS_DETECT} ${OPTIONS} ${OPTIONS_XTRA}" \
2687 # -v xopts="${XOPTIONS_DETECT} ${XOPTIONS} ${XOPTIONS_XTRA}" \
2688 printf '"\n' >> ${h}
2690 # Create the real mk-config.mk
2691 # Note we cannout use explicit ./ filename prefix for source and object
2692 # pathnames because of a bug in bmake(1)
2693 ${rm} -rf ${tmp0}.* ${tmp0}*
2694 srclist= objlist=
2695 if feat_no AMALGAMATION; then
2696 for i in `printf '%s\n' "${SRCDIR}"*.c | ${sort}`; do
2697 i=`basename "${i}" .c`
2698 if [ "${i}" = privsep ]; then
2699 continue
2701 objlist="${objlist} ${i}.o"
2702 srclist="${srclist} \$(SRCDIR)${i}.c"
2703 printf '%s: %s\n\t$(ECHO_CC)$(CC) $(CFLAGS) $(INCS) -c %s\n' \
2704 "${i}.o" "\$(SRCDIR)${i}.c" "\$(SRCDIR)${i}.c" >> ${mk}
2705 done
2706 printf '\nAMALGAM_TARGET =\nAMALGAM_DEP =\n' >> ${mk}
2707 else
2708 printf '%s:\n\t$(ECHO_CC)$(CC) $(CFLAGS) $(INCS) -c $(SRCDIR)%s\n' \
2709 "main.o" "main.c" >> ${mk}
2710 srclist=main.c objlist=main.o
2711 printf '\nAMALGAM_TARGET = main.o\nAMALGAM_DEP = ' >> ${mk}
2713 printf '\n/* HAVE_AMALGAMATION: include sources */\n' >> ${h}
2714 printf '#elif n_MK_CONFIG_H + 0 == 1\n' >> ${h}
2715 printf '# undef n_MK_CONFIG_H\n' >> ${h}
2716 printf '# define n_MK_CONFIG_H 2\n' >> ${h}
2717 for i in `printf '%s\n' "${SRCDIR}"*.c | ${sort}`; do
2718 i=`basename "${i}"`
2719 if [ "${i}" = main.c ] ||
2720 [ "${i}" = privsep.c ]; then
2721 continue
2723 printf '$(SRCDIR)%s ' "${i}" >> ${mk}
2724 printf '# include "%s%s"\n' "${SRCDIR}" "${i}" >> ${h}
2725 done
2726 echo >> ${mk}
2728 printf 'OBJ_SRC = %s\nOBJ = %s\n' "${srclist}" "${objlist}" >> "${mk}"
2730 printf '#endif /* n_MK_CONFIG_H */\n' >> ${h}
2732 echo "LIBS = `${cat} ${lib}`" >> ${mk}
2733 echo "INCS = `${cat} ${inc}`" >> ${mk}
2734 echo >> ${mk}
2735 ${cat} "${SRCDIR}"make-config.in >> ${mk}
2737 ## Finished!
2739 msg '\nSetup:'
2740 msg ' . System-wide resource file: %s/%s' "${VAL_SYSCONFDIR}" "${VAL_SYSCONFRC}"
2741 msg ' . bindir: %s' "${VAL_BINDIR}"
2742 if feat_yes DOTLOCK; then
2743 msg ' . libexecdir: %s' "${VAL_LIBEXECDIR}"
2745 msg ' . mandir: %s' "${VAL_MANDIR}"
2746 msg ' . M(ail)T(ransfer)A(gent): %s (argv0 %s)' "${VAL_MTA}" "${VAL_MTA_ARGV0}"
2747 msg ' . $MAIL spool directory: %s' "${VAL_MAIL}"
2748 msg ''
2750 if [ -n "${have_fnmatch}" ] && [ -n "${have_fchdir}" ]; then
2751 exit 0
2753 msg 'Remarks:'
2754 if [ -z "${have_fnmatch}" ]; then
2755 msg ' . The function fnmatch(3) could not be found.'
2756 msg ' Filename patterns like wildcard are not supported on your system'
2758 if [ -z "${have_fchdir}" ]; then
2759 msg ' . The function fchdir(2) could not be found.'
2760 msg ' We will use chdir(2) instead.'
2761 msg ' This is a problem only if the current working directory is changed'
2762 msg ' while this program is inside of it'
2764 msg ''
2766 # s-it-mode