nail.1: COMMANDS: say what will never work
[s-mailx.git] / make-config.sh
blobee1e544e927915ad391d76a94374b6e4fbdfa893
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 if [ ${cc_maxopt} -gt 1 ] && feat_yes NOMEMDBG ||
459 feat_yes ASAN_ADDRESS || feat_yes ASAN_MEMORY; then
460 msg 'OP_NOMEMDBG or OPT_ASAN_{ADDRESS,MEMORY}, setting cc_maxopt=1 (-O1)'
461 cc_maxopt=1
463 # Check -g first since some others may rely upon -g / optim. level
464 if feat_yes DEBUG; then
465 cc_check -O
466 cc_check -g
467 elif [ ${cc_maxopt} -gt 2 ] && cc_check -O3; then
469 elif [ ${cc_maxopt} -gt 1 ] && cc_check -O2; then
471 elif [ ${cc_maxopt} -gt 0 ] && cc_check -O1; then
473 else
474 cc_check -O
477 if feat_yes AMALGAMATION; then
478 cc_check -pipe
481 #if feat_yes DEVEL && cc_check -Weverything; then
483 #else
484 cc_check -Wall
485 cc_check -Wextra
486 cc_check -Wbad-function-cast
487 cc_check -Wcast-align
488 cc_check -Wcast-qual
489 cc_check -Winit-self
490 cc_check -Wmissing-prototypes
491 cc_check -Wshadow
492 cc_check -Wunused
493 cc_check -Wwrite-strings
494 cc_check -Wno-long-long
496 cc_check -pedantic
498 if feat_yes AMALGAMATION && feat_no DEVEL; then
499 cc_check -Wno-unused-function
501 feat_no DEVEL && cc_check -Wno-unused-result # XXX do right way (pragma too)
503 cc_check -fno-unwind-tables
504 cc_check -fno-asynchronous-unwind-tables
505 cc_check -fstrict-aliasing
506 if cc_check -fstrict-overflow && feat_yes DEVEL; then
507 cc_check -Wstrict-overflow=5
510 if feat_yes DEBUG || feat_yes FORCED_STACKPROT; then
511 if [ -z "${force_no_stackprot}" ]; then
512 if cc_check -fstack-protector-strong ||
513 cc_check -fstack-protector-all; then
514 cc_check -D_FORTIFY_SOURCE=2
516 else
517 msg 'Not checking for -fstack-protector compiler option,'
518 msg 'since that caused errors in a "similar" configuration.'
519 msg 'You may turn off OPT_AUTOCC and use your own settings, rerun'
523 # LD (+ dependend CC)
525 if feat_yes ASAN_ADDRESS; then
526 _ccfg=${_CFLAGS}
527 if cc_check -fsanitize=address &&
528 ld_check -fsanitize=address; then
530 else
531 feat_bail_required ASAN_ADDRESS
532 _CFLAGS=${_ccfg}
536 if feat_yes ASAN_MEMORY; then
537 _ccfg=${_CFLAGS}
538 if cc_check -fsanitize=memory &&
539 ld_check -fsanitize=memory &&
540 cc_check -fsanitize-memory-track-origins=2 &&
541 ld_check -fsanitize-memory-track-origins=2; then
543 else
544 feat_bail_required ASAN_MEMORY
545 _CFLAGS=${_ccfg}
549 ld_check -Wl,-z,relro
550 ld_check -Wl,-z,now
551 ld_check -Wl,-z,noexecstack
552 if ld_check -Wl,-rpath =./ no; then
553 need_R_ldflags=-Wl,-rpath=
554 # Choose DT_RUNPATH (after $LD_LIBRARY_PATH) over DT_RPATH (before)
555 ld_check -Wl,--enable-new-dtags
556 ld_runtime_flags # update!
557 elif ld_check -Wl,-R ./ no; then
558 need_R_ldflags=-Wl,-R
559 ld_check -Wl,--enable-new-dtags
560 ld_runtime_flags # update!
563 # Address randomization
564 _ccfg=${_CFLAGS}
565 if cc_check -fPIE || cc_check -fpie; then
566 ld_check -pie || _CFLAGS=${_ccfg}
568 unset _ccfg
570 _CFLAGS="${_CFLAGS} ${__cflags}" _LDFLAGS="${_LDFLAGS} ${__ldflags}"
571 unset __cflags __ldflags
574 ## -- >8 - <<OS/CC | SUPPORT FUNS>> - 8< -- ##
576 ## Notes:
577 ## - Heirloom sh(1) (and same origin) have _sometimes_ problems with ': >'
578 ## redirection, so use "printf '' >" instead
580 ## Very first: we undergo several states regarding I/O redirection etc.,
581 ## but need to deal with option updates from within all. Since all the
582 ## option stuff should be above the scissor line, define utility functions
583 ## and redefine them as necessary.
584 ## And, since we have those functions, simply use them for whatever
586 config_exit() {
587 exit ${1}
590 msg() {
591 fmt=${1}
592 shift
593 printf >&2 -- "${fmt}\\n" "${@}"
596 msg_nonl() {
597 fmt=${1}
598 shift
599 printf >&2 -- "${fmt}" "${@}"
602 t1=ten10one1ten10one1
603 if ( [ ${t1##*ten10} = one1 ] && [ ${t1#*ten10} = one1ten10one1 ] &&
604 [ ${t1%%one1*} = ten10 ] && [ ${t1%one1*} = ten10one1ten10 ]
605 ) > /dev/null 2>&1; then
606 good_shell=1
607 else
608 unset good_shell
610 unset t1
612 # We need some standard utilities
613 unset -f command
614 check_tool() {
615 n=${1} i=${2} opt=${3:-0}
616 # Evaluate, just in case user comes in with shell snippets (..well..)
617 eval i="${i}"
618 if type "${i}" >/dev/null 2>&1; then # XXX why have i type not command -v?
619 [ -n "${VERBOSE}" ] && msg ' . ${%s} ... %s' "${n}" "${i}"
620 eval ${n}=${i}
621 return 0
623 if [ ${opt} -eq 0 ]; then
624 msg 'ERROR: no trace of utility %s' "${n}"
625 config_exit 1
627 return 1
630 # Our feature check environment
631 feat_val_no() {
632 [ "x${1}" = x0 ] || [ "x${1}" = xn ] ||
633 [ "x${1}" = xfalse ] || [ "x${1}" = xno ] || [ "x${1}" = xoff ]
636 feat_val_yes() {
637 [ "x${1}" = x1 ] || [ "x${1}" = xy ] ||
638 [ "x${1}" = xtrue ] || [ "x${1}" = xyes ] || [ "x${1}" = xon ] ||
639 [ "x${1}" = xrequire ]
642 feat_val_require() {
643 [ "x${1}" = xrequire ]
646 _feat_check() {
647 eval i=\$OPT_${1}
648 i="`echo ${i} | ${tr} '[A-Z]' '[a-z]'`"
649 if feat_val_no "${i}"; then
650 return 1
651 elif feat_val_yes "${i}"; then
652 return 0
653 else
654 msg "ERROR: %s: 0/n/false/no/off or 1/y/true/yes/on/require, got: %s" \
655 "${1}" "${i}"
656 config_exit 11
660 feat_yes() {
661 _feat_check ${1}
664 feat_no() {
665 _feat_check ${1} && return 1
666 return 0
669 feat_require() {
670 eval i=\$OPT_${1}
671 i="`echo ${i} | ${tr} '[A-Z]' '[a-z]'`"
672 [ "x${i}" = xrequire ] || [ "x${i}" = xrequired ]
675 feat_bail_required() {
676 if feat_require ${1}; then
677 msg 'ERROR: feature OPT_%s is required but not available' "${1}"
678 config_exit 13
680 eval OPT_${1}=0
681 option_update # XXX this is rather useless here (dependency chain..)
684 option_parse() {
685 # Parse one of our XOPTIONS* in $2 and assign the sh(1) compatible list of
686 # options, without documentation, to $1
687 j=\'
688 i="`${awk} -v input=\"${2}\" '
689 BEGIN{
690 for(i = 0;;){
691 voff = match(input, /[[:alnum:]_]+(='${j}'[^'${j}']+)?/)
692 if(voff == 0)
693 break
694 v = substr(input, voff, RLENGTH)
695 input = substr(input, voff + RLENGTH)
696 doff = index(v, "=")
697 if(doff > 0){
698 d = substr(v, doff + 2, length(v) - doff - 1)
699 v = substr(v, 1, doff - 1)
701 print v
705 eval ${1}=\"${i}\"
708 option_doc_of() {
709 # Return the "documentation string" for option $1, itself if none such
710 j=\'
711 ${awk} -v want="${1}" \
712 -v input="${XOPTIONS_DETECT}${XOPTIONS}${XOPTIONS_XTRA}" '
713 BEGIN{
714 for(;;){
715 voff = match(input, /[[:alnum:]_]+(='${j}'[^'${j}']+)?/)
716 if(voff == 0)
717 break
718 v = substr(input, voff, RLENGTH)
719 input = substr(input, voff + RLENGTH)
720 doff = index(v, "=")
721 if(doff > 0){
722 d = substr(v, doff + 2, length(v) - doff - 1)
723 v = substr(v, 1, doff - 1)
724 }else
725 d = v
726 if(v == want){
727 if(d != "-")
728 print d
729 exit
736 option_join_rc() {
737 # Join the values from make.rc into what currently is defined, not
738 # overwriting yet existing settings
739 ${rm} -f ${tmp}
740 # We want read(1) to perform reverse solidus escaping in order to be able to
741 # use multiline values in make.rc; the resulting sh(1)/sed(1) code was very
742 # slow in VMs (see [fa2e248]), Aharon Robbins suggested the following
743 < ${rc} ${awk} 'BEGIN{line = ""}{
744 gsub(/^[[:space:]]+/, "", $0)
745 gsub(/[[:space:]]+$/, "", $0)
746 if(gsub(/\\$/, "", $0)){
747 line = line $0
748 next
749 }else
750 line = line $0
751 if(index(line, "#") == 1){
752 line = ""
753 }else if(length(line)){
754 print line
755 line = ""
757 }' |
758 while read line; do
759 if [ -n "${good_shell}" ]; then
760 i=${line%%=*}
761 else
762 i=`${awk} -v LINE="${line}" 'BEGIN{
763 gsub(/=.*$/, "", LINE)
764 print LINE
767 if [ "${i}" = "${line}" ]; then
768 msg 'ERROR: invalid syntax in: %s' "${line}"
769 continue
772 eval j="\$${i}" jx="\${${i}+x}"
773 if [ -n "${j}" ] || [ "${jx}" = x ]; then
774 : # Yet present
775 else
776 j=`${awk} -v LINE="${line}" 'BEGIN{
777 gsub(/^[^=]*=/, "", LINE)
778 gsub(/^\"*/, "", LINE)
779 gsub(/\"*$/, "", LINE)
780 print LINE
783 [ "${i}" = "DESTDIR" ] && continue
784 echo "${i}=\"${j}\""
785 done > ${tmp}
786 # Reread the mixed version right now
787 . ./${tmp}
790 option_evaluate() {
791 # Expand the option values, which may contain shell snippets
792 ${rm} -f ${newlst} ${newmk} ${newh}
793 exec 5<&0 6>&1 <${tmp} >${newlst}
794 while read line; do
796 if [ -n "${good_shell}" ]; then
797 i=${line%%=*}
798 [ "${i}" != "${i#OPT_}" ] && z=1
799 else
800 i=`${awk} -v LINE="${line}" 'BEGIN{
801 gsub(/=.*$/, "", LINE);\
802 print LINE
804 if echo "${i}" | ${grep} '^OPT_' >/dev/null 2>&1; then
809 eval j=\$${i}
810 if [ -n "${z}" ]; then
811 j="`echo ${j} | ${tr} '[A-Z]' '[a-z]'`"
812 if [ -z "${j}" ] || feat_val_no "${j}"; then
814 printf " /* #undef ${i} */\n" >> ${newh}
815 elif feat_val_yes "${j}"; then
816 if feat_val_require "${j}"; then
817 j=require
818 else
821 printf " /* #define ${i} */\n" >> ${newh}
822 else
823 msg 'ERROR: cannot parse <%s>' "${line}"
824 config_exit 1
826 else
827 printf "#define ${i} \"${j}\"\n" >> ${newh}
829 printf "${i} = ${j}\n" >> ${newmk}
830 printf "${i}=${j}\n"
831 eval "${i}=\"${j}\""
832 done
833 exec 0<&5 1>&6 5<&- 6<&-
836 path_check() {
837 # "path_check VARNAME" or "path_check VARNAME FLAG VARNAME"
838 varname=${1} addflag=${2} flagvarname=${3}
839 j=${IFS}
840 IFS=:
841 eval "set -- \$${1}"
842 IFS=${j}
843 j= k= y= z=
844 for i
846 [ -z "${i}" ] && continue
847 [ -d "${i}" ] || continue
848 if [ -n "${j}" ]; then
849 if { z=${y}; echo "${z}"; } | ${grep} ":${i}:" >/dev/null 2>&1; then
851 else
852 y="${y} :${i}:"
853 j="${j}:${i}"
854 # But do not link any fakeroot path into our binaries!
855 if [ -n "${addflag}" ]; then
856 case "${i}" in *fakeroot*) continue;; esac
857 k="${k} ${addflag}${i}"
860 else
861 y=" :${i}:"
862 j="${i}"
863 # But do not link any fakeroot path into our binaries!
864 if [ -n "${addflag}" ]; then
865 case "${i}" in *fakeroot*) continue;; esac
866 k="${k} ${addflag}${i}"
869 done
870 eval "${varname}=\"${j}\""
871 [ -n "${addflag}" ] && eval "${flagvarname}=\"${k}\""
872 unset varname
875 ld_runtime_flags() {
876 if [ -n "${need_R_ldflags}" ]; then
877 i=${IFS}
878 IFS=:
879 set -- ${LD_LIBRARY_PATH}
880 IFS=${i}
881 for i
883 # But do not link any fakeroot path into our binaries!
884 case "${i}" in *fakeroot*) continue;; esac
885 LDFLAGS="${LDFLAGS} ${need_R_ldflags}${i}"
886 _LDFLAGS="${_LDFLAGS} ${need_R_ldflags}${i}"
887 done
888 export LDFLAGS
890 # Disable it for a possible second run.
891 need_R_ldflags=
894 cc_check() {
895 [ -n "${cc_check_silent}" ] || msg_nonl ' . CC %s .. ' "${1}"
896 if "${CC}" ${INCS} \
897 ${_CFLAGS} ${1} ${EXTRA_CFLAGS} ${_LDFLAGS} ${EXTRA_LDFLAGS} \
898 -o ${tmp2} ${tmp}.c ${LIBS} >/dev/null 2>&1; then
899 _CFLAGS="${_CFLAGS} ${1}"
900 [ -n "${cc_check_silent}" ] || msg 'yes'
901 return 0
903 [ -n "${cc_check_silent}" ] || msg 'no'
904 return 1
907 ld_check() {
908 # $1=option [$2=option argument] [$3=if set, shall NOT be added to _LDFLAGS]
909 [ -n "${cc_check_silent}" ] || msg_nonl ' . LD %s .. ' "${1}"
910 if "${CC}" ${INCS} ${_CFLAGS} ${_LDFLAGS} ${1}${2} ${EXTRA_LDFLAGS} \
911 -o ${tmp2} ${tmp}.c ${LIBS} >/dev/null 2>&1; then
912 [ -n "${3}" ] || _LDFLAGS="${_LDFLAGS} ${1}"
913 [ -n "${cc_check_silent}" ] || msg 'yes'
914 return 0
916 [ -n "${cc_check_silent}" ] || msg 'no'
917 return 1
920 _check_preface() {
921 variable=$1 topic=$2 define=$3
923 echo '**********'
924 msg_nonl ' . %s ... ' "${topic}"
925 echo "/* checked ${topic} */" >> ${h}
926 ${rm} -f ${tmp} ${tmp}.o
927 echo '*** test program is'
928 { echo '#include <'"${h_name}"'>'; cat; } | ${tee} ${tmp}.c
929 #echo '*** the preprocessor generates'
930 #${make} -f ${makefile} ${tmp}.x
931 #${cat} ${tmp}.x
932 echo '*** results are'
935 without_check() {
936 yesno=$1 variable=$2 topic=$3 define=$4 libs=$5 incs=$6
938 echo '**********'
939 msg_nonl ' . %s ... ' "${topic}"
941 echo '*** enforced unchecked results are'
942 if feat_val_yes ${yesno}; then
943 if [ -n "${incs}" ] || [ -n "${libs}" ]; then
944 echo "*** adding INCS<${incs}> LIBS<${libs}>"
945 LIBS="${LIBS} ${libs}"
946 echo "${libs}" >> ${lib}
947 INCS="${INCS} ${incs}"
948 echo "${incs}" >> ${inc}
950 msg 'yes (deduced)'
951 echo "${define}" >> ${h}
952 eval have_${variable}=yes
953 return 0
954 else
955 echo "/* ${define} */" >> ${h}
956 msg 'no (deduced)'
957 eval unset have_${variable}
958 return 1
962 compile_check() {
963 variable=$1 topic=$2 define=$3
965 _check_preface "${variable}" "${topic}" "${define}"
967 if ${make} -f ${makefile} XINCS="${INCS}" \
968 CFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}" \
969 ./${tmp}.o &&
970 [ -f ./${tmp}.o ]; then
971 msg 'yes'
972 echo "${define}" >> ${h}
973 eval have_${variable}=yes
974 return 0
975 else
976 echo "/* ${define} */" >> ${h}
977 msg 'no'
978 eval unset have_${variable}
979 return 1
983 _link_mayrun() {
984 run=$1 variable=$2 topic=$3 define=$4 libs=$5 incs=$6
986 _check_preface "${variable}" "${topic}" "${define}"
988 if feat_yes CROSS_BUILD; then
989 if [ ${run} = 1 ]; then
990 run=0
994 if ${make} -f ${makefile} XINCS="${INCS} ${incs}" \
995 CFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}" \
996 XLIBS="${LIBS} ${libs}" \
997 ./${tmp} &&
998 [ -f ./${tmp} ] &&
999 { [ ${run} -eq 0 ] || ./${tmp}; }; then
1000 echo "*** adding INCS<${incs}> LIBS<${libs}>; executed: ${run}"
1001 msg 'yes'
1002 echo "${define}" >> ${h}
1003 LIBS="${LIBS} ${libs}"
1004 echo "${libs}" >> ${lib}
1005 INCS="${INCS} ${incs}"
1006 echo "${incs}" >> ${inc}
1007 eval have_${variable}=yes
1008 return 0
1009 else
1010 msg 'no'
1011 echo "/* ${define} */" >> ${h}
1012 eval unset have_${variable}
1013 return 1
1017 link_check() {
1018 _link_mayrun 0 "${1}" "${2}" "${3}" "${4}" "${5}"
1021 run_check() {
1022 _link_mayrun 1 "${1}" "${2}" "${3}" "${4}" "${5}"
1025 xrun_check() {
1026 _link_mayrun 2 "${1}" "${2}" "${3}" "${4}" "${5}"
1029 feat_def() {
1030 if feat_yes ${1}; then
1031 echo '#define HAVE_'${1}'' >> ${h}
1032 return 0
1033 else
1034 echo '/* OPT_'${1}'=0 */' >> ${h}
1035 return 1
1039 squeeze_em() {
1040 < "${1}" > "${2}" ${awk} \
1041 'BEGIN {ORS = " "} /^[^#]/ {print} {next} END {ORS = ""; print "\n"}'
1044 ## -- >8 - <<SUPPORT FUNS | RUNNING>> - 8< -- ##
1046 # First of all, create new configuration and check whether it changed
1048 # Very easy checks for the operating system in order to be able to adjust paths
1049 # or similar very basic things which we need to be able to go at all
1050 os_early_setup
1052 # Check those tools right now that we need before including $rc
1053 msg 'Checking for basic utility set'
1054 check_tool awk "${awk:-`command -v awk`}"
1055 check_tool rm "${rm:-`command -v rm`}"
1056 check_tool tr "${tr:-`command -v tr`}"
1058 # Initialize the option set
1059 msg_nonl 'Setting up configuration options ... '
1060 option_setup
1061 msg 'done'
1063 # Include $rc, but only take from it what wasn't overwritten by the user from
1064 # within the command line or from a chosen fixed CONFIG=
1065 # Note we leave alone the values
1066 trap "exit 1" HUP INT TERM
1067 trap "${rm} -f ${tmp}" EXIT
1069 msg_nonl 'Joining in %s ... ' ${rc}
1070 option_join_rc
1071 msg 'done'
1073 # We need to know about that now, in order to provide utility overwrites etc.
1074 os_setup
1076 msg 'Checking for remaining set of utilities'
1077 check_tool grep "${grep:-`command -v grep`}"
1079 # Before we step ahead with the other utilities perform a path cleanup first.
1080 path_check PATH
1082 # awk(1) above
1083 check_tool basename "${basename:-`command -v basename`}"
1084 check_tool cat "${cat:-`command -v cat`}"
1085 check_tool chmod "${chmod:-`command -v chmod`}"
1086 check_tool cp "${cp:-`command -v cp`}"
1087 check_tool cmp "${cmp:-`command -v cmp`}"
1088 # grep(1) above
1089 check_tool mkdir "${mkdir:-`command -v mkdir`}"
1090 check_tool mv "${mv:-`command -v mv`}"
1091 # rm(1) above
1092 check_tool sed "${sed:-`command -v sed`}"
1093 check_tool sort "${sort:-`command -v sort`}"
1094 check_tool tee "${tee:-`command -v tee`}"
1096 check_tool chown "${chown:-`command -v chown`}" 1 ||
1097 check_tool chown "/sbin/chown" 1 ||
1098 check_tool chown "/usr/sbin/chown"
1100 check_tool make "${MAKE:-`command -v make`}"
1101 MAKE=${make}
1102 check_tool strip "${STRIP:-`command -v strip`}" 1 &&
1103 HAVE_STRIP=1 || HAVE_STRIP=0
1105 # For ./cc-test.sh only
1106 check_tool cksum "${cksum:-`command -v cksum`}"
1108 # Update OPT_ options now, in order to get possible inter-dependencies right
1109 option_update
1111 # (No functions since some shells loose non-exported variables in traps)
1112 trap "trap \"\" HUP INT TERM; exit 1" HUP INT TERM
1113 trap "trap \"\" HUP INT TERM EXIT;\
1114 ${rm} -rf ${newlst} ${tmp0}.* ${tmp0}* ${newmk} ${newev} ${newh}" EXIT
1116 # Our configuration options may at this point still contain shell snippets,
1117 # we need to evaluate them in order to get them expanded, and we need those
1118 # evaluated values not only in our new configuration file, but also at hand..
1119 msg_nonl 'Evaluating all configuration items ... '
1120 option_evaluate
1121 msg 'done'
1123 # Add the known utility and some other variables
1124 printf "#define VAL_UAGENT \"${VAL_SID}${VAL_MAILX}\"\n" >> ${newh}
1125 printf "VAL_UAGENT = ${VAL_SID}${VAL_MAILX}\n" >> ${newmk}
1127 printf "#define VAL_PRIVSEP \"${VAL_SID}${VAL_MAILX}-privsep\"\n" >> ${newh}
1128 printf "VAL_PRIVSEP = \$(VAL_UAGENT)-privsep\n" >> ${newmk}
1129 if feat_yes DOTLOCK; then
1130 printf "OPTIONAL_PRIVSEP = \$(VAL_PRIVSEP)\n" >> ${newmk}
1131 else
1132 printf "OPTIONAL_PRIVSEP =\n" >> ${newmk}
1135 for i in \
1136 SRCDIR \
1137 awk basename cat chmod chown cp cmp grep mkdir mv rm sed sort tee tr \
1138 MAKE MAKEFLAGS make SHELL strip \
1139 cksum; do
1140 eval j=\$${i}
1141 printf "${i} = ${j}\n" >> ${newmk}
1142 printf "${i}=${j}\n" >> ${newlst}
1143 printf "${i}=\"${j}\";export ${i}; " >> ${newev}
1144 done
1145 printf "\n" >> ${newev}
1147 # Build a basic set of INCS and LIBS according to user environment.
1148 C_INCLUDE_PATH="./:${SRCDIR}:${C_INCLUDE_PATH}"
1149 path_check C_INCLUDE_PATH -I _INCS
1150 INCS="${INCS} ${_INCS}"
1151 path_check LD_LIBRARY_PATH -L _LIBS
1152 LIBS="${LIBS} ${_LIBS}"
1153 unset _INCS _LIBS
1154 export C_INCLUDE_PATH LD_LIBRARY_PATH
1156 # Some environments need runtime path flags to be able to go at all
1157 ld_runtime_flags
1159 ## Detect CC, whether we can use it, and possibly which CFLAGS we can use
1161 cc_setup
1163 ${cat} > ${tmp}.c << \!
1164 #include <stdio.h>
1165 #include <string.h>
1166 static void doit(char const *s);
1168 main(int argc, char **argv){
1169 (void)argc;
1170 (void)argv;
1171 doit("Hello world");
1172 return 0;
1174 static void
1175 doit(char const *s){
1176 char buf[12];
1177 memcpy(buf, s, strlen(s) +1);
1178 puts(s);
1182 if "${CC}" ${INCS} ${CFLAGS} ${EXTRA_CFLAGS} ${LDFLAGS} ${EXTRA_LDFLAGS} \
1183 -o ${tmp2} ${tmp}.c ${LIBS}; then
1185 else
1186 msg 'ERROR: i cannot compile a "Hello world" via'
1187 msg ' %s' \
1188 "${CC} ${INCS} ${CFLAGS} ${EXTRA_CFLAGS} ${LDFLAGS} ${EXTRA_LDFLAGS} ${LIBS}"
1189 msg 'ERROR: Please read INSTALL, rerun'
1190 config_exit 1
1193 # This may also update ld_runtime_flags() (again)
1194 cc_flags
1196 for i in \
1197 INCS LIBS \
1198 ; do
1199 eval j=\$${i}
1200 printf -- "${i}=${j}\n" >> ${newlst}
1201 done
1202 for i in \
1203 CC \
1204 CFLAGS \
1205 LDFLAGS \
1206 PATH C_INCLUDE_PATH LD_LIBRARY_PATH \
1207 OSFULLSPEC \
1208 ; do
1209 eval j=\$${i}
1210 printf -- "${i} = ${j}\n" >> ${newmk}
1211 printf -- "${i}=${j}\n" >> ${newlst}
1212 done
1214 # Now finally check whether we already have a configuration and if so, whether
1215 # all those parameters are still the same.. or something has actually changed
1216 if [ -f ${lst} ] && ${cmp} ${newlst} ${lst} >/dev/null 2>&1; then
1217 echo 'Configuration is up-to-date'
1218 exit 0
1219 elif [ -f ${lst} ]; then
1220 echo 'Configuration has been updated..'
1221 ( eval "${MAKE} -f ./mk-config.mk clean" )
1222 echo
1223 else
1224 echo 'Shiny configuration..'
1227 # Time to redefine helper 1
1228 config_exit() {
1229 ${rm} -f ${lst} ${h} ${mk}
1230 exit ${1}
1233 ${mv} -f ${newlst} ${lst}
1234 ${mv} -f ${newev} ${ev}
1235 ${mv} -f ${newh} ${h}
1236 ${mv} -f ${newmk} ${mk}
1238 if [ -z "${VERBOSE}" ]; then
1239 printf -- "ECHO_CC = @echo ' 'CC \$(@);\n" >> ${mk}
1240 printf -- "ECHO_LINK = @echo ' 'LINK \$(@);\n" >> ${mk}
1241 printf -- "ECHO_GEN = @echo ' 'GEN \$(@);\n" >> ${mk}
1242 printf -- "ECHO_TEST = @\n" >> ${mk}
1243 printf -- "ECHO_CMD = @echo ' CMD';\n" >> ${mk}
1244 printf -- "ECHO_BLOCK_BEGIN = @( \n" >> ${mk}
1245 printf -- "ECHO_BLOCK_END = ) >/dev/null\n" >> ${mk}
1248 ## Compile and link checking
1250 tmp3=./${tmp0}3$$
1251 log=./mk-config.log
1252 lib=./mk-config.lib
1253 inc=./mk-config.inc
1254 makefile=./${tmp0}.mk
1256 # (No function since some shells loose non-exported variables in traps)
1257 trap "trap \"\" HUP INT TERM;\
1258 ${rm} -f ${lst} ${h} ${mk} ${lib} ${inc}; exit 1" HUP INT TERM
1259 trap "trap \"\" HUP INT TERM EXIT;\
1260 ${rm} -rf ${tmp0}.* ${tmp0}*" EXIT
1262 # Time to redefine helper 2
1263 msg() {
1264 fmt=${1}
1265 shift
1266 printf "*** ${fmt}\\n" "${@}"
1267 printf -- "${fmt}\\n" "${@}" >&5
1269 msg_nonl() {
1270 fmt=${1}
1271 shift
1272 printf "*** ${fmt}\\n" "${@}"
1273 printf -- "${fmt}" "${@}" >&5
1276 # !!
1277 exec 5>&2 > ${log} 2>&1
1279 echo "${LIBS}" > ${lib}
1280 echo "${INCS}" > ${inc}
1281 ${cat} > ${makefile} << \!
1282 .SUFFIXES: .o .c .x .y
1283 .c.o:
1284 $(CC) -I./ $(XINCS) $(CFLAGS) -c $(<)
1285 .c.x:
1286 $(CC) -I./ $(XINCS) -E $(<) > $(@)
1288 $(CC) -I./ $(XINCS) $(CFLAGS) $(LDFLAGS) -o $(@) $(<) $(XLIBS)
1291 ## Generics
1293 # May be multiline..
1294 echo >> ${h}
1295 [ -n "${OS_DEFINES}" ] && printf -- "${OS_DEFINES}" >> ${h}
1296 echo '#define VAL_BUILD_OS "'"${OS}"'"' >> ${h}
1297 echo '#define VAL_BUILD_OSENV "'"${OSENV}"'"' >> ${h}
1299 # Generate n_err_number OS mappings
1301 feat_yes DEVEL && NV= || NV=noverbose
1302 SRCDIR="${SRCDIR}" TARGET="${h}" awk="${awk}" \
1303 ${SHELL} "${SRCDIR}"make-errors.sh ${NV} config
1305 xrun_check oserrno 'OS error mapping table generated' || config_exit 1
1307 feat_def ALWAYS_UNICODE_LOCALE
1308 feat_def AMALGAMATION
1309 feat_def CROSS_BUILD
1310 feat_def DOCSTRINGS
1311 feat_def ERRORS
1313 feat_def ASAN_ADDRESS
1314 feat_def ASAN_MEMORY
1315 feat_def DEBUG
1316 feat_def DEVEL
1317 feat_def NYD2
1318 feat_def NOMEMDBG
1320 if xrun_check inline 'inline functions' \
1321 '#define HAVE_INLINE
1322 #define n_INLINE static inline' << \!
1323 static inline int ilf(int i){return ++i;}
1324 int main(void){return ilf(-1);}
1326 then
1328 elif xrun_check inline 'inline functions (via __inline)' \
1329 '#define HAVE_INLINE
1330 #define n_INLINE static __inline' << \!
1331 static __inline int ilf(int i){return ++i;}
1332 int main(void){return ilf(-1);}
1334 then
1338 ## Test for "basic" system-calls / functionality that is used by all parts
1339 ## of our program. Once this is done fork away BASE_LIBS and other BASE_*
1340 ## macros to be used by only the subprograms (potentially).
1342 if run_check clock_gettime 'clock_gettime(2)' \
1343 '#define HAVE_CLOCK_GETTIME' << \!
1344 #include <time.h>
1345 # include <errno.h>
1346 int main(void){
1347 struct timespec ts;
1349 if(!clock_gettime(CLOCK_REALTIME, &ts) || errno != ENOSYS)
1350 return 0;
1351 return 1;
1354 then
1356 elif run_check clock_gettime 'clock_gettime(2) (via -lrt)' \
1357 '#define HAVE_CLOCK_GETTIME' '-lrt' << \!
1358 #include <time.h>
1359 # include <errno.h>
1360 int main(void){
1361 struct timespec ts;
1363 if(!clock_gettime(CLOCK_REALTIME, &ts) || errno != ENOSYS)
1364 return 0;
1365 return 1;
1368 then
1370 elif run_check gettimeofday 'gettimeofday(2)' \
1371 '#define HAVE_GETTIMEOFDAY' << \!
1372 #include <stdio.h> /* For C89 NULL */
1373 #include <sys/time.h>
1374 # include <errno.h>
1375 int main(void){
1376 struct timeval tv;
1378 if(!gettimeofday(&tv, NULL) || errno != ENOSYS)
1379 return 0;
1380 return 1;
1383 then
1385 else
1386 have_no_subsecond_time=1
1389 if run_check nanosleep 'nanosleep(2)' \
1390 '#define HAVE_NANOSLEEP' << \!
1391 #include <time.h>
1392 # include <errno.h>
1393 int main(void){
1394 struct timespec ts;
1396 ts.tv_sec = 1;
1397 ts.tv_nsec = 100000;
1398 if(!nanosleep(&ts, NULL) || errno != ENOSYS)
1399 return 0;
1400 return 1;
1403 then
1405 elif run_check nanosleep 'nanosleep(2) (via -lrt)' \
1406 '#define HAVE_NANOSLEEP' '-lrt' << \!
1407 #include <time.h>
1408 # include <errno.h>
1409 int main(void){
1410 struct timespec ts;
1412 ts.tv_sec = 1;
1413 ts.tv_nsec = 100000;
1414 if(!nanosleep(&ts, NULL) || errno != ENOSYS)
1415 return 0;
1416 return 1;
1419 then
1421 # link_check is enough for this, that function is so old, trust the proto
1422 elif link_check sleep 'sleep(3)' \
1423 '#define HAVE_SLEEP' << \!
1424 #include <unistd.h>
1425 # include <errno.h>
1426 int main(void){
1427 if(!sleep(1) || errno != ENOSYS)
1428 return 0;
1429 return 1;
1432 then
1434 else
1435 msg 'ERROR: we require one of nanosleep(2) and sleep(3).'
1436 config_exit 1
1439 if run_check userdb 'gete?[gu]id(2), getpwuid(3), getpwnam(3)' << \!
1440 #include <pwd.h>
1441 #include <unistd.h>
1442 # include <errno.h>
1443 int main(void){
1444 struct passwd *pw;
1445 gid_t gid;
1446 uid_t uid;
1448 if((gid = getgid()) != 0)
1449 gid = getegid();
1450 if((uid = getuid()) != 0)
1451 uid = geteuid();
1452 if((pw = getpwuid(uid)) == NULL && errno == ENOSYS)
1453 return 1;
1454 if((pw = getpwnam("root")) == NULL && errno == ENOSYS)
1455 return 1;
1456 return 0;
1459 then
1461 else
1462 msg 'ERROR: we require user and group info / database searches.'
1463 msg 'That much Unix we indulge ourselfs.'
1464 config_exit 1
1467 if link_check ftruncate 'ftruncate(2)' \
1468 '#define HAVE_FTRUNCATE' << \!
1469 #include <unistd.h>
1470 #include <sys/types.h>
1471 int main(void){
1472 return (ftruncate(0, 0) != 0);
1475 then
1477 else
1478 msg 'ERROR: we require the ftruncate(2) system call.'
1479 config_exit 1
1482 if run_check sa_restart 'SA_RESTART (for sigaction(2))' << \!
1483 #include <signal.h>
1484 # include <errno.h>
1485 int main(void){
1486 struct sigaction nact, oact;
1488 nact.sa_handler = SIG_DFL;
1489 sigemptyset(&nact.sa_mask);
1490 nact.sa_flags = SA_RESTART;
1491 return !(!sigaction(SIGCHLD, &nact, &oact) || errno != ENOSYS);
1494 then
1496 else
1497 msg 'ERROR: we (yet) require the SA_RESTART flag for sigaction(2).'
1498 config_exit 1
1501 if link_check snprintf 'snprintf(3)' << \!
1502 #include <stdio.h>
1503 int main(void){
1504 char b[20];
1506 snprintf(b, sizeof b, "%s", "string");
1507 return 0;
1510 then
1512 else
1513 msg 'ERROR: we require the snprintf(3) function.'
1514 config_exit 1
1517 if link_check environ 'environ(3)' << \!
1518 #include <stdio.h> /* For C89 NULL */
1519 int main(void){
1520 extern char **environ;
1522 return environ[0] == NULL;
1525 then
1527 else
1528 msg 'ERROR: we require the environ(3) array for subprocess control.'
1529 config_exit 1
1532 if link_check setenv '(un)?setenv(3)' '#define HAVE_SETENV' << \!
1533 #include <stdlib.h>
1534 int main(void){
1535 setenv("s-mailx", "i want to see it cute!", 1);
1536 unsetenv("s-mailx");
1537 return 0;
1540 then
1542 elif link_check setenv 'putenv(3)' '#define HAVE_PUTENV' << \!
1543 #include <stdlib.h>
1544 int main(void){
1545 putenv("s-mailx=i want to see it cute!");
1546 return 0;
1549 then
1551 else
1552 msg 'ERROR: we require either the setenv(3) or putenv(3) functions.'
1553 config_exit 1
1556 if link_check termios 'termios.h and tc*(3) family' << \!
1557 #include <termios.h>
1558 int main(void){
1559 struct termios tios;
1561 tcgetattr(0, &tios);
1562 tcsetattr(0, TCSANOW | TCSADRAIN | TCSAFLUSH, &tios);
1563 return 0;
1566 then
1568 else
1569 msg 'ERROR: we require termios.h and the tc*() family of functions.'
1570 msg 'That much Unix we indulge ourselfs.'
1571 config_exit 1
1574 ## optional stuff
1576 if link_check vsnprintf 'vsnprintf(3)' << \!
1577 #include <stdarg.h>
1578 #include <stdio.h>
1579 static void dome(char *buf, size_t blen, ...){
1580 va_list ap;
1582 va_start(ap, blen);
1583 vsnprintf(buf, blen, "%s", ap);
1584 va_end(ap);
1586 int main(void){
1587 char b[20];
1589 dome(b, sizeof b, "string");
1590 return 0;
1593 then
1595 else
1596 feat_bail_required ERRORS
1599 if [ "${have_vsnprintf}" = yes ]; then
1600 __va_copy() {
1601 link_check va_copy "va_copy(3) (as ${2})" \
1602 "#define HAVE_N_VA_COPY
1603 #define n_va_copy ${2}" <<_EOT
1604 #include <stdarg.h>
1605 #include <stdio.h>
1606 #if ${1}
1607 # if defined __va_copy && !defined va_copy
1608 # define va_copy __va_copy
1609 # endif
1610 #endif
1611 static void dome2(char *buf, size_t blen, va_list src){
1612 va_list ap;
1614 va_copy(ap, src);
1615 vsnprintf(buf, blen, "%s", ap);
1616 va_end(ap);
1618 static void dome(char *buf, size_t blen, ...){
1619 va_list ap;
1621 va_start(ap, blen);
1622 dome2(buf, blen, ap);
1623 va_end(ap);
1625 int main(void){
1626 char b[20];
1628 dome(b, sizeof b, "string");
1629 return 0;
1631 _EOT
1633 __va_copy 0 va_copy || __va_copy 1 __va_copy
1636 run_check pathconf 'f?pathconf(2)' '#define HAVE_PATHCONF' << \!
1637 #include <unistd.h>
1638 #include <errno.h>
1639 int main(void){
1640 int rv = 0;
1642 errno = 0;
1643 rv |= !(pathconf(".", _PC_NAME_MAX) >= 0 || errno == 0 || errno != ENOSYS);
1644 errno = 0;
1645 rv |= !(pathconf(".", _PC_PATH_MAX) >= 0 || errno == 0 || errno != ENOSYS);
1647 /* Only link check */
1648 fpathconf(0, _PC_NAME_MAX);
1650 return rv;
1654 run_check pipe2 'pipe2(2)' '#define HAVE_PIPE2' << \!
1655 #include <fcntl.h>
1656 #include <unistd.h>
1657 # include <errno.h>
1658 int main(void){
1659 int fds[2];
1661 if(!pipe2(fds, O_CLOEXEC) || errno != ENOSYS)
1662 return 0;
1663 return 1;
1667 # We use this only then for now (need NOW+1)
1668 run_check utimensat 'utimensat(2)' '#define HAVE_UTIMENSAT' << \!
1669 #include <fcntl.h> /* For AT_* */
1670 #include <sys/stat.h>
1671 # include <errno.h>
1672 int main(void){
1673 struct timespec ts[2];
1675 ts[0].tv_nsec = UTIME_NOW;
1676 ts[1].tv_nsec = UTIME_OMIT;
1677 if(!utimensat(AT_FDCWD, "", ts, 0) || errno != ENOSYS)
1678 return 0;
1679 return 1;
1685 # XXX Add POSIX check once standardized
1686 if link_check posix_random 'arc4random(3)' '#define HAVE_POSIX_RANDOM 0' << \!
1687 #include <stdlib.h>
1688 int main(void){
1689 arc4random();
1690 return 0;
1693 then
1695 elif link_check getrandom 'getrandom(2) (in sys/random.h)' \
1696 '#define HAVE_GETRANDOM(B,S) getrandom(B, S, 0)
1697 #define HAVE_GETRANDOM_HEADER <sys/random.h>' <<\!
1698 #include <sys/random.h>
1699 int main(void){
1700 char buf[256];
1701 getrandom(buf, sizeof buf, 0);
1702 return 0;
1705 then
1707 elif link_check getrandom 'getrandom(2) (via syscall(2))' \
1708 '#define HAVE_GETRANDOM(B,S) syscall(SYS_getrandom, B, S, 0)
1709 #define HAVE_GETRANDOM_HEADER <sys/syscall.h>' <<\!
1710 #include <sys/syscall.h>
1711 int main(void){
1712 char buf[256];
1713 syscall(SYS_getrandom, buf, sizeof buf, 0);
1714 return 0;
1717 then
1719 elif [ -n "${have_no_subsecond_time}" ]; then
1720 msg 'ERROR: %s %s' 'without a native random' \
1721 'one of clock_gettime(2) and gettimeofday(2) is required.'
1722 config_exit 1
1726 link_check putc_unlocked 'putc_unlocked(3)' '#define HAVE_PUTC_UNLOCKED' <<\!
1727 #include <stdio.h>
1728 int main(void){
1729 putc_unlocked('@', stdout);
1730 return 0;
1734 link_check fchdir 'fchdir(3)' '#define HAVE_FCHDIR' << \!
1735 #include <unistd.h>
1736 int main(void){
1737 fchdir(0);
1738 return 0;
1742 if run_check realpath 'realpath(3)' '#define HAVE_REALPATH' << \!
1743 #include <stdlib.h>
1744 int main(void){
1745 char x_buf[4096], *x = realpath(".", x_buf);
1747 return (x != NULL) ? 0 : 1;
1750 then
1751 if run_check realpath_malloc 'realpath(3) takes NULL' \
1752 '#define HAVE_REALPATH_NULL' << \!
1753 #include <stdlib.h>
1754 int main(void){
1755 char *x = realpath(".", NULL);
1757 if(x != NULL)
1758 free(x);
1759 return (x != NULL) ? 0 : 1;
1762 then
1767 ## optional and selectable
1769 if feat_yes DOTLOCK; then
1770 if run_check readlink 'readlink(2)' << \!
1771 #include <unistd.h>
1772 # include <errno.h>
1773 int main(void){
1774 char buf[128];
1776 if(!readlink("here", buf, sizeof buf) || errno != ENOSYS)
1777 return 0;
1778 return 1;
1781 then
1783 else
1784 feat_bail_required DOTLOCK
1788 if feat_yes DOTLOCK; then
1789 if run_check fchown 'fchown(2)' << \!
1790 #include <unistd.h>
1791 # include <errno.h>
1792 int main(void){
1793 if(!fchown(0, 0, 0) || errno != ENOSYS)
1794 return 0;
1795 return 1;
1798 then
1800 else
1801 feat_bail_required DOTLOCK
1805 ## Now it is the time to fork away the BASE_ series
1807 ${rm} -f ${tmp}
1808 squeeze_em ${inc} ${tmp}
1809 ${mv} ${tmp} ${inc}
1810 squeeze_em ${lib} ${tmp}
1811 ${mv} ${tmp} ${lib}
1813 echo "BASE_LIBS = `${cat} ${lib}`" >> ${mk}
1814 echo "BASE_INCS = `${cat} ${inc}`" >> ${mk}
1816 ## The remains are expected to be used only by the main MUA binary!
1818 OPT_LOCALES=0
1819 link_check setlocale 'setlocale(3)' '#define HAVE_SETLOCALE' << \!
1820 #include <locale.h>
1821 int main(void){
1822 setlocale(LC_ALL, "");
1823 return 0;
1826 [ -n "${have_setlocale}" ] && OPT_LOCALES=1
1828 OPT_MULTIBYTE_CHARSETS=0
1829 OPT_WIDE_GLYPHS=0
1830 OPT_TERMINAL_CHARSET=0
1831 if [ -n "${have_setlocale}" ]; then
1832 link_check c90amend1 'ISO/IEC 9899:1990/Amendment 1:1995' \
1833 '#define HAVE_C90AMEND1' << \!
1834 #include <limits.h>
1835 #include <stdlib.h>
1836 #include <wchar.h>
1837 #include <wctype.h>
1838 int main(void){
1839 char mbb[MB_LEN_MAX + 1];
1840 wchar_t wc;
1842 iswprint(L'c');
1843 towupper(L'c');
1844 mbtowc(&wc, "x", 1);
1845 mbrtowc(&wc, "x", 1, NULL);
1846 wctomb(mbb, wc);
1847 return (mblen("\0", 1) == 0);
1850 [ -n "${have_c90amend1}" ] && OPT_MULTIBYTE_CHARSETS=1
1852 if [ -n "${have_c90amend1}" ]; then
1853 link_check wcwidth 'wcwidth(3)' '#define HAVE_WCWIDTH' << \!
1854 #include <wchar.h>
1855 int main(void){
1856 wcwidth(L'c');
1857 return 0;
1860 [ -n "${have_wcwidth}" ] && OPT_WIDE_GLYPHS=1
1863 link_check nl_langinfo 'nl_langinfo(3)' '#define HAVE_NL_LANGINFO' << \!
1864 #include <langinfo.h>
1865 #include <stdlib.h>
1866 int main(void){
1867 nl_langinfo(DAY_1);
1868 return (nl_langinfo(CODESET) == NULL);
1871 [ -n "${have_nl_langinfo}" ] && OPT_TERMINAL_CHARSET=1
1872 fi # have_setlocale
1874 link_check fnmatch 'fnmatch(3)' '#define HAVE_FNMATCH' << \!
1875 #include <fnmatch.h>
1876 int main(void){
1877 return (fnmatch("*", ".", FNM_PATHNAME | FNM_PERIOD) == FNM_NOMATCH);
1881 link_check dirent_d_type 'struct dirent.d_type' '#define HAVE_DIRENT_TYPE' << \!
1882 #include <dirent.h>
1883 int main(void){
1884 struct dirent de;
1885 return !(de.d_type == DT_UNKNOWN ||
1886 de.d_type == DT_DIR || de.d_type == DT_LNK);
1890 ## optional and selectable
1892 if feat_yes ICONV; then
1893 ${cat} > ${tmp2}.c << \!
1894 #include <stdio.h> /* For C89 NULL */
1895 #include <iconv.h>
1896 int main(void){
1897 iconv_t id;
1899 id = iconv_open("foo", "bar");
1900 iconv(id, NULL, NULL, NULL, NULL);
1901 iconv_close(id);
1902 return 0;
1905 < ${tmp2}.c link_check iconv 'iconv(3) functionality' \
1906 '#define HAVE_ICONV' ||
1907 < ${tmp2}.c link_check iconv 'iconv(3) functionality (via -liconv)' \
1908 '#define HAVE_ICONV' '-liconv' ||
1909 feat_bail_required ICONV
1910 else
1911 echo '/* OPT_ICONV=0 */' >> ${h}
1912 fi # feat_yes ICONV
1914 if feat_yes SOCKETS || feat_yes SPAM_SPAMD; then
1915 ${cat} > ${tmp2}.c << \!
1916 #include <sys/types.h>
1917 #include <sys/socket.h>
1918 #include <sys/un.h>
1919 # include <errno.h>
1920 int main(void){
1921 struct sockaddr_un soun;
1923 if(socket(AF_UNIX, SOCK_STREAM, 0) == -1 && errno == ENOSYS)
1924 return 1;
1925 if(connect(0, (struct sockaddr*)&soun, 0) == -1 && errno == ENOSYS)
1926 return 1;
1927 if(shutdown(0, SHUT_RD | SHUT_WR | SHUT_RDWR) == -1 && errno == ENOSYS)
1928 return 1;
1929 return 0;
1933 < ${tmp2}.c run_check af_unix 'AF_UNIX sockets' \
1934 '#define HAVE_UNIX_SOCKETS' ||
1935 < ${tmp2}.c run_check af_unix 'AF_UNIX sockets (via -lnsl)' \
1936 '#define HAVE_UNIX_SOCKETS' '-lnsl' ||
1937 < ${tmp2}.c run_check af_unix 'AF_UNIX sockets (via -lsocket -lnsl)' \
1938 '#define HAVE_UNIX_SOCKETS' '-lsocket -lnsl'
1941 if feat_yes SOCKETS; then
1942 ${cat} > ${tmp2}.c << \!
1943 #include <sys/types.h>
1944 #include <sys/socket.h>
1945 #include <netinet/in.h>
1946 # include <errno.h>
1947 int main(void){
1948 struct sockaddr s;
1950 if(socket(AF_INET, SOCK_STREAM, 0) == -1 && errno == ENOSYS)
1951 return 1;
1952 if(connect(0, &s, 0) == -1 && errno == ENOSYS)
1953 return 1;
1954 return 0;
1958 < ${tmp2}.c run_check sockets 'sockets' \
1959 '#define HAVE_SOCKETS' ||
1960 < ${tmp2}.c run_check sockets 'sockets (via -lnsl)' \
1961 '#define HAVE_SOCKETS' '-lnsl' ||
1962 < ${tmp2}.c run_check sockets 'sockets (via -lsocket -lnsl)' \
1963 '#define HAVE_SOCKETS' '-lsocket -lnsl' ||
1964 feat_bail_required SOCKETS
1965 else
1966 echo '/* OPT_SOCKETS=0 */' >> ${h}
1967 fi # feat_yes SOCKETS
1969 if feat_yes SOCKETS; then
1970 link_check getaddrinfo 'getaddrinfo(3)' \
1971 '#define HAVE_GETADDRINFO' << \!
1972 #include <sys/types.h>
1973 #include <sys/socket.h>
1974 #include <stdio.h>
1975 #include <netdb.h>
1976 int main(void){
1977 struct addrinfo a, *ap;
1978 int lrv;
1980 switch((lrv = getaddrinfo("foo", "0", &a, &ap))){
1981 case EAI_NONAME:
1982 case EAI_SERVICE:
1983 default:
1984 fprintf(stderr, "%s\n", gai_strerror(lrv));
1985 case 0:
1986 break;
1988 return 0;
1993 if feat_yes SOCKETS && [ -z "${have_getaddrinfo}" ]; then
1994 compile_check arpa_inet_h '<arpa/inet.h>' \
1995 '#define HAVE_ARPA_INET_H' << \!
1996 #include <sys/types.h>
1997 #include <sys/socket.h>
1998 #include <netdb.h>
1999 #include <netinet/in.h>
2000 #include <arpa/inet.h>
2003 ${cat} > ${tmp2}.c << \!
2004 #include <sys/types.h>
2005 #include <sys/socket.h>
2006 #include <stdio.h>
2007 #include <string.h>
2008 #include <netdb.h>
2009 #include <netinet/in.h>
2010 #ifdef HAVE_ARPA_INET_H
2011 #include <arpa/inet.h>
2012 #endif
2013 int main(void){
2014 struct sockaddr_in servaddr;
2015 unsigned short portno;
2016 struct servent *ep;
2017 struct hostent *hp;
2018 struct in_addr **pptr;
2020 portno = 0;
2021 if((ep = getservbyname("POPPY-PORT", "tcp")) != NULL)
2022 portno = (unsigned short)ep->s_port;
2024 if((hp = gethostbyname("POPPY-HOST")) != NULL){
2025 pptr = (struct in_addr**)hp->h_addr_list;
2026 if(hp->h_addrtype != AF_INET)
2027 fprintf(stderr, "au\n");
2028 }else{
2029 switch(h_errno){
2030 case HOST_NOT_FOUND:
2031 case TRY_AGAIN:
2032 case NO_RECOVERY:
2033 case NO_DATA:
2034 break;
2035 default:
2036 fprintf(stderr, "au\n");
2037 break;
2041 memset(&servaddr, 0, sizeof servaddr);
2042 servaddr.sin_family = AF_INET;
2043 servaddr.sin_port = htons(portno);
2044 memcpy(&servaddr.sin_addr, *pptr, sizeof(struct in_addr));
2045 fprintf(stderr, "Would connect to %s:%d ...\n",
2046 inet_ntoa(**pptr), (int)portno);
2047 return 0;
2051 < ${tmp2}.c link_check gethostbyname 'get(serv|host)byname(3)' ||
2052 < ${tmp2}.c link_check gethostbyname \
2053 'get(serv|host)byname(3) (via -nsl)' '' '-lnsl' ||
2054 < ${tmp2}.c link_check gethostbyname \
2055 'get(serv|host)byname(3) (via -lsocket -nsl)' \
2056 '' '-lsocket -lnsl' ||
2057 feat_bail_required SOCKETS
2060 feat_yes SOCKETS &&
2061 run_check setsockopt 'setsockopt(2)' '#define HAVE_SETSOCKOPT' << \!
2062 #include <sys/socket.h>
2063 #include <stdlib.h>
2064 # include <errno.h>
2065 int main(void){
2066 int sockfd = 3;
2068 if(setsockopt(sockfd, SOL_SOCKET, SO_KEEPALIVE, NULL, 0) == -1 &&
2069 errno == ENOSYS)
2070 return 1;
2071 return 0;
2075 feat_yes SOCKETS && [ -n "${have_setsockopt}" ] &&
2076 link_check so_sndtimeo 'SO_SNDTIMEO' '#define HAVE_SO_SNDTIMEO' << \!
2077 #include <sys/socket.h>
2078 #include <stdlib.h>
2079 int main(void){
2080 struct timeval tv;
2081 int sockfd = 3;
2083 tv.tv_sec = 42;
2084 tv.tv_usec = 21;
2085 setsockopt(sockfd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof tv);
2086 setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof tv);
2087 return 0;
2091 feat_yes SOCKETS && [ -n "${have_setsockopt}" ] &&
2092 link_check so_linger 'SO_LINGER' '#define HAVE_SO_LINGER' << \!
2093 #include <sys/socket.h>
2094 #include <stdlib.h>
2095 int main(void){
2096 struct linger li;
2097 int sockfd = 3;
2099 li.l_onoff = 1;
2100 li.l_linger = 42;
2101 setsockopt(sockfd, SOL_SOCKET, SO_LINGER, &li, sizeof li);
2102 return 0;
2106 if feat_yes SSL; then # {{{
2107 # {{{ LibreSSL decided to define OPENSSL_VERSION_NUMBER with a useless value
2108 # instead of keeping it at the one that corresponds to the OpenSSL at fork
2109 # time: we need to test it first in order to get things right
2110 if compile_check _xssl 'TLS/SSL (LibreSSL)' \
2111 '#define HAVE_SSL
2112 #define HAVE_XSSL
2113 #define HAVE_XSSL_RESSL
2114 #define HAVE_XSSL_OPENSSL 0' << \!
2115 #include <openssl/opensslv.h>
2116 #ifdef LIBRESSL_VERSION_NUMBER
2117 #else
2118 # error nope
2119 #endif
2121 then
2122 ossl_v1_1=
2123 # TODO OPENSSL_IS_BORINGSSL, but never tried that one!
2124 elif compile_check _xssl 'TLS/SSL (OpenSSL >= v1.1.0)' \
2125 '#define HAVE_SSL
2126 #define HAVE_XSSL
2127 #define HAVE_XSSL_OPENSSL 0x10100' << \!
2128 #include <openssl/opensslv.h>
2129 #if OPENSSL_VERSION_NUMBER + 0 >= 0x10100000L
2130 #else
2131 # error nope
2132 #endif
2134 then
2135 ossl_v1_1=1
2136 elif compile_check _xssl 'TLS/SSL (OpenSSL)' \
2137 '#define HAVE_SSL
2138 #define HAVE_XSSL
2139 #define HAVE_XSSL_OPENSSL 0x10000' << \!
2140 #include <openssl/opensslv.h>
2141 #ifdef OPENSSL_VERSION_NUMBER
2142 #else
2143 # error nope
2144 #endif
2146 then
2147 ossl_v1_1=
2148 else
2149 feat_bail_required SSL
2150 fi # }}}
2152 if feat_yes SSL; then # {{{
2153 if [ -n "${ossl_v1_1}" ]; then
2154 without_check yes xssl 'TLS/SSL (new style *_client_method(3ssl))' \
2155 '#define n_XSSL_CLIENT_METHOD TLS_client_method' \
2156 '-lssl -lcrypto'
2157 elif link_check xssl 'TLS/SSL (new style *_client_method(3ssl))' \
2158 '#define n_XSSL_CLIENT_METHOD TLS_client_method' \
2159 '-lssl -lcrypto' << \!
2160 #include <openssl/ssl.h>
2161 #include <openssl/err.h>
2162 #include <openssl/x509v3.h>
2163 #include <openssl/x509.h>
2164 #include <openssl/rand.h>
2165 #ifdef OPENSSL_NO_TLS1 /* TODO only deduced from OPENSSL_NO_SSL[23]! */
2166 # error We need TLSv1.
2167 #endif
2168 int main(void){
2169 SSL_CTX *ctx = SSL_CTX_new(TLS_client_method());
2171 SSL_CTX_free(ctx);
2172 PEM_read_PrivateKey(0, 0, 0, 0);
2173 return 0;
2176 then
2178 elif link_check xssl 'TLS/SSL (old style *_client_method(3ssl))' \
2179 '#define n_XSSL_CLIENT_METHOD SSLv23_client_method' \
2180 '-lssl -lcrypto' << \!
2181 #include <openssl/ssl.h>
2182 #include <openssl/err.h>
2183 #include <openssl/x509v3.h>
2184 #include <openssl/x509.h>
2185 #include <openssl/rand.h>
2186 #if defined OPENSSL_NO_SSL3 &&\
2187 defined OPENSSL_NO_TLS1 /* TODO only deduced from OPENSSL_NO_SSL[23]! */
2188 # error We need one of SSLv3 and TLSv1.
2189 #endif
2190 int main(void){
2191 SSL_CTX *ctx = SSL_CTX_new(SSLv23_client_method());
2193 SSL_CTX_free(ctx);
2194 PEM_read_PrivateKey(0, 0, 0, 0);
2195 return 0;
2198 then
2200 else
2201 feat_bail_required SSL
2203 fi # }}}
2205 if feat_yes SSL; then # {{{
2206 if [ -n "${ossl_v1_1}" ]; then
2207 without_check yes xssl_stack_of 'TLS/SSL STACK_OF()' \
2208 '#define HAVE_XSSL_STACK_OF'
2209 elif compile_check xssl_stack_of 'TLS/SSL STACK_OF()' \
2210 '#define HAVE_XSSL_STACK_OF' << \!
2211 #include <stdio.h> /* For C89 NULL */
2212 #include <openssl/ssl.h>
2213 #include <openssl/err.h>
2214 #include <openssl/x509v3.h>
2215 #include <openssl/x509.h>
2216 #include <openssl/rand.h>
2217 int main(void){
2218 STACK_OF(GENERAL_NAME) *gens = NULL;
2220 printf("%p", gens); /* to use it */
2221 return 0;
2224 then
2228 if [ -n "${ossl_v1_1}" ]; then
2229 without_check yes xssl_conf 'TLS/SSL OpenSSL_modules_load_file()' \
2230 '#define HAVE_XSSL_CONFIG'
2231 elif link_check xssl_conf 'TLS/SSL OpenSSL_modules_load_file() support' \
2232 '#define HAVE_XSSL_CONFIG' << \!
2233 #include <stdio.h> /* For C89 NULL */
2234 #include <openssl/conf.h>
2235 int main(void){
2236 CONF_modules_load_file(NULL, NULL, CONF_MFLAGS_IGNORE_MISSING_FILE);
2237 CONF_modules_free();
2238 return 0;
2241 then
2245 if [ -n "${ossl_v1_1}" ]; then
2246 without_check yes xssl_conf_ctx 'TLS/SSL SSL_CONF_CTX support' \
2247 '#define HAVE_XSSL_CONF_CTX'
2248 elif link_check xssl_conf_ctx 'TLS/SSL SSL_CONF_CTX support' \
2249 '#define HAVE_XSSL_CONF_CTX' << \!
2250 #include <openssl/ssl.h>
2251 #include <openssl/err.h>
2252 int main(void){
2253 SSL_CTX *ctx = SSL_CTX_new(n_XSSL_CLIENT_METHOD());
2254 SSL_CONF_CTX *cctx = SSL_CONF_CTX_new();
2256 SSL_CONF_CTX_set_flags(cctx,
2257 SSL_CONF_FLAG_FILE | SSL_CONF_FLAG_CLIENT |
2258 SSL_CONF_FLAG_CERTIFICATE | SSL_CONF_FLAG_SHOW_ERRORS);
2259 SSL_CONF_CTX_set_ssl_ctx(cctx, ctx);
2260 SSL_CONF_cmd(cctx, "Protocol", "ALL");
2261 SSL_CONF_CTX_finish(cctx);
2262 SSL_CONF_CTX_free(cctx);
2263 SSL_CTX_free(ctx);
2264 return 0;
2267 then
2271 if [ -n "${ossl_v1_1}" ]; then
2272 without_check no xssl_rand_egd 'TLS/SSL RAND_egd(3ssl)' \
2273 '#define HAVE_XSSL_RAND_EGD'
2274 elif link_check xssl_rand_egd 'TLS/SSL RAND_egd(3ssl)' \
2275 '#define HAVE_XSSL_RAND_EGD' << \!
2276 #include <openssl/rand.h>
2277 int main(void){
2278 return RAND_egd("some.where") > 0;
2281 then
2285 if feat_yes SSL_ALL_ALGORITHMS; then
2286 if [ -n "${ossl_v1_1}" ]; then
2287 without_check yes ssl_all_algo 'TLS/SSL all-algorithms support' \
2288 '#define HAVE_SSL_ALL_ALGORITHMS'
2289 elif link_check ssl_all_algo 'TLS/SSL all-algorithms support' \
2290 '#define HAVE_SSL_ALL_ALGORITHMS' << \!
2291 #include <openssl/evp.h>
2292 int main(void){
2293 OpenSSL_add_all_algorithms();
2294 EVP_get_cipherbyname("two cents i never exist");
2295 EVP_cleanup();
2296 return 0;
2299 then
2301 else
2302 feat_bail_required SSL_ALL_ALGORITHMS
2305 fi # feat_yes SSL }}}
2307 if feat_yes SSL && feat_yes MD5 && feat_no NOEXTMD5; then # {{{
2308 run_check ssl_md5 'MD5 digest in the used crypto library' \
2309 '#define HAVE_XSSL_MD5' << \!
2310 #include <stdlib.h>
2311 #include <string.h>
2312 #include <openssl/md5.h>
2313 int main(void){
2314 char const dat[] = "abrakadabrafidibus";
2315 char dig[16], hex[16 * 2];
2316 MD5_CTX ctx;
2317 size_t i, j;
2319 memset(dig, 0, sizeof(dig));
2320 memset(hex, 0, sizeof(hex));
2321 MD5_Init(&ctx);
2322 MD5_Update(&ctx, dat, sizeof(dat) - 1);
2323 MD5_Final(dig, &ctx);
2325 #define hexchar(n) ((n) > 9 ? (n) - 10 + 'a' : (n) + '0')
2326 for(i = 0; i < sizeof(hex) / 2; i++){
2327 j = i << 1;
2328 hex[j] = hexchar((dig[i] & 0xf0) >> 4);
2329 hex[++j] = hexchar(dig[i] & 0x0f);
2331 return !!memcmp("6d7d0a3d949da2e96f2aa010f65d8326", hex, sizeof(hex));
2334 fi # }}}
2335 else
2336 echo '/* OPT_SSL=0 */' >> ${h}
2337 fi # }}} feat_yes SSL
2339 if [ "${have_xssl}" = yes ]; then
2340 OPT_SMIME=1
2341 else
2342 OPT_SMIME=0
2344 feat_def SMIME
2346 feat_def SMTP
2347 feat_def POP3
2348 feat_def IMAP
2350 if feat_yes GSSAPI; then
2351 ${cat} > ${tmp2}.c << \!
2352 #include <gssapi/gssapi.h>
2353 int main(void){
2354 gss_import_name(0, 0, GSS_C_NT_HOSTBASED_SERVICE, 0);
2355 gss_init_sec_context(0,0,0,0,0,0,0,0,0,0,0,0,0);
2356 return 0;
2359 ${sed} -e '1s/gssapi\///' < ${tmp2}.c > ${tmp3}.c
2361 if command -v krb5-config >/dev/null 2>&1; then
2362 i=`command -v krb5-config`
2363 GSS_LIBS="`CFLAGS= ${i} --libs gssapi`"
2364 GSS_INCS="`CFLAGS= ${i} --cflags`"
2365 i='GSS-API via krb5-config(1)'
2366 else
2367 GSS_LIBS='-lgssapi'
2368 GSS_INCS=
2369 i='GSS-API in gssapi/gssapi.h, libgssapi'
2371 if < ${tmp2}.c link_check gss \
2372 "${i}" '#define HAVE_GSSAPI' "${GSS_LIBS}" "${GSS_INCS}" ||\
2373 < ${tmp3}.c link_check gss \
2374 'GSS-API in gssapi.h, libgssapi' \
2375 '#define HAVE_GSSAPI
2376 #define GSSAPI_REG_INCLUDE' \
2377 '-lgssapi' ||\
2378 < ${tmp2}.c link_check gss 'GSS-API in libgssapi_krb5' \
2379 '#define HAVE_GSSAPI' \
2380 '-lgssapi_krb5' ||\
2381 < ${tmp3}.c link_check gss \
2382 'GSS-API in libgssapi, OpenBSD-style (pre 5.3)' \
2383 '#define HAVE_GSSAPI
2384 #define GSS_REG_INCLUDE' \
2385 '-lgssapi -lkrb5 -lcrypto' \
2386 '-I/usr/include/kerberosV' ||\
2387 < ${tmp2}.c link_check gss 'GSS-API in libgss' \
2388 '#define HAVE_GSSAPI' \
2389 '-lgss' ||\
2390 link_check gss 'GSS-API in libgssapi_krb5, old-style' \
2391 '#define HAVE_GSSAPI
2392 #define GSSAPI_OLD_STYLE' \
2393 '-lgssapi_krb5' << \!
2394 #include <gssapi/gssapi.h>
2395 #include <gssapi/gssapi_generic.h>
2396 int main(void){
2397 gss_import_name(0, 0, gss_nt_service_name, 0);
2398 gss_init_sec_context(0,0,0,0,0,0,0,0,0,0,0,0,0);
2399 return 0;
2402 then
2404 else
2405 feat_bail_required GSSAPI
2407 else
2408 echo '/* OPT_GSSAPI=0 */' >> ${h}
2409 fi # feat_yes GSSAPI
2411 feat_def NETRC
2412 feat_def AGENT
2414 if feat_yes IDNA; then
2415 if link_check idna 'GNU Libidn' '#define HAVE_IDNA HAVE_IDNA_LIBIDNA' \
2416 '-lidn' << \!
2417 #include <idna.h>
2418 #include <idn-free.h>
2419 #include <stringprep.h>
2420 int main(void){
2421 char *utf8, *idna_ascii, *idna_utf8;
2423 utf8 = stringprep_locale_to_utf8("does.this.work");
2424 if (idna_to_ascii_8z(utf8, &idna_ascii, IDNA_USE_STD3_ASCII_RULES)
2425 != IDNA_SUCCESS)
2426 return 1;
2427 idn_free(idna_ascii);
2428 /* (Rather link check only here) */
2429 idna_utf8 = stringprep_convert(idna_ascii, "UTF-8", "de_DE");
2430 return 0;
2433 then
2435 elif link_check idna 'idnkit' '#define HAVE_IDNA HAVE_IDNA_IDNKIT' \
2436 '-lidnkit' << \!
2437 #include <stdio.h>
2438 #include <idn/api.h>
2439 #include <idn/result.h>
2440 int main(void){
2441 idn_result_t r;
2442 char ace_name[256];
2443 char local_name[256];
2445 r = idn_encodename(IDN_ENCODE_APP, "does.this.work", ace_name,
2446 sizeof(ace_name));
2447 if (r != idn_success) {
2448 fprintf(stderr, "idn_encodename failed: %s\n", idn_result_tostring(r));
2449 return 1;
2451 r = idn_decodename(IDN_DECODE_APP, ace_name, local_name, sizeof(local_name));
2452 if (r != idn_success) {
2453 fprintf(stderr, "idn_decodename failed: %s\n", idn_result_tostring(r));
2454 return 1;
2456 return 0;
2459 then
2461 else
2462 feat_bail_required IDNA
2465 if [ -n "${have_idna}" ]; then
2466 echo '#define HAVE_IDNA_LIBIDNA 0' >> ${h}
2467 echo '#define HAVE_IDNA_IDNKIT 1' >> ${h}
2469 else
2470 echo '/* OPT_IDNA=0 */' >> ${h}
2473 feat_def IMAP_SEARCH
2475 if feat_yes REGEX; then
2476 if link_check regex 'regular expressions' '#define HAVE_REGEX' << \!
2477 #include <regex.h>
2478 #include <stdlib.h>
2479 int main(void){
2480 size_t xret;
2481 int status;
2482 regex_t re;
2484 status = regcomp(&re, ".*bsd", REG_EXTENDED | REG_ICASE | REG_NOSUB);
2485 xret = regerror(status, &re, NULL, 0);
2486 status = regexec(&re, "plan9", 0,NULL, 0);
2487 regfree(&re);
2488 return !(status == REG_NOMATCH);
2491 then
2493 else
2494 feat_bail_required REGEX
2496 else
2497 echo '/* OPT_REGEX=0 */' >> ${h}
2500 if feat_yes MLE && [ -n "${have_c90amend1}" ]; then
2501 have_mle=1
2502 echo '#define HAVE_MLE' >> ${h}
2503 else
2504 feat_bail_required MLE
2505 echo '/* OPT_MLE=0 */' >> ${h}
2508 # Generic have-a-line-editor switch for those who need it below
2509 if [ -n "${have_mle}" ]; then
2510 have_cle=1
2513 if [ -n "${have_cle}" ] && feat_yes HISTORY; then
2514 echo '#define HAVE_HISTORY' >> ${h}
2515 else
2516 echo '/* OPT_HISTORY=0 */' >> ${h}
2519 if [ -n "${have_mle}" ] && feat_yes KEY_BINDINGS; then
2520 echo '#define HAVE_KEY_BINDINGS' >> ${h}
2521 else
2522 echo '/* OPT_KEY_BINDINGS=0 */' >> ${h}
2525 if feat_yes TERMCAP; then
2526 __termcaplib() {
2527 link_check termcap "termcap(5) (via ${4})" \
2528 "#define HAVE_TERMCAP${3}" "${1}" << _EOT
2529 #include <stdio.h>
2530 #include <stdlib.h>
2531 ${2}
2532 #include <term.h>
2533 #define UNCONST(P) ((void*)(unsigned long)(void const*)(P))
2534 static int my_putc(int c){return putchar(c);}
2535 int main(void){
2536 char buf[1024+512], cmdbuf[2048], *cpb, *r1;
2537 int r2 = OK, r3 = ERR;
2539 tgetent(buf, getenv("TERM"));
2540 cpb = cmdbuf;
2541 r1 = tgetstr(UNCONST("cm"), &cpb);
2542 tgoto(r1, 1, 1);
2543 r2 = tgetnum(UNCONST("Co"));
2544 r3 = tgetflag(UNCONST("ut"));
2545 tputs("cr", 1, &my_putc);
2546 return (r1 == NULL || r2 == -1 || r3 == 0);
2548 _EOT
2551 __terminfolib() {
2552 link_check terminfo "terminfo(5) (via ${2})" \
2553 '#define HAVE_TERMCAP
2554 #define HAVE_TERMCAP_CURSES
2555 #define HAVE_TERMINFO' "${1}" << _EOT
2556 #include <stdio.h>
2557 #include <curses.h>
2558 #include <term.h>
2559 #define UNCONST(P) ((void*)(unsigned long)(void const*)(P))
2560 static int my_putc(int c){return putchar(c);}
2561 int main(void){
2562 int er, r0, r1, r2;
2563 char *r3, *tp;
2565 er = OK;
2566 r0 = setupterm(NULL, 1, &er);
2567 r1 = tigetflag(UNCONST("bce"));
2568 r2 = tigetnum(UNCONST("colors"));
2569 r3 = tigetstr(UNCONST("cr"));
2570 tp = tparm(r3, NULL, NULL, 0,0,0,0,0,0,0);
2571 tputs(tp, 1, &my_putc);
2572 return (r0 == ERR || r1 == -1 || r2 == -2 || r2 == -1 ||
2573 r3 == (char*)-1 || r3 == NULL);
2575 _EOT
2578 if feat_yes TERMCAP_VIA_TERMINFO; then
2579 __terminfolib -ltinfo -ltinfo ||
2580 __terminfolib -lcurses -lcurses ||
2581 __terminfolib -lcursesw -lcursesw ||
2582 feat_bail_required TERMCAP_VIA_TERMINFO
2585 if [ -z "${have_terminfo}" ]; then
2586 __termcaplib -ltermcap '' '' '-ltermcap' ||
2587 __termcaplib -ltermcap '#include <curses.h>' '
2588 #define HAVE_TERMCAP_CURSES' \
2589 'curses.h / -ltermcap' ||
2590 __termcaplib -lcurses '#include <curses.h>' '
2591 #define HAVE_TERMCAP_CURSES' \
2592 'curses.h / -lcurses' ||
2593 __termcaplib -lcursesw '#include <curses.h>' '
2594 #define HAVE_TERMCAP_CURSES' \
2595 'curses.h / -lcursesw' ||
2596 feat_bail_required TERMCAP
2598 if [ -n "${have_termcap}" ]; then
2599 run_check tgetent_null \
2600 "tgetent(3) of termcap(5) takes NULL buffer" \
2601 "#define HAVE_TGETENT_NULL_BUF" << _EOT
2602 #include <stdio.h> /* For C89 NULL */
2603 #include <stdlib.h>
2604 #ifdef HAVE_TERMCAP_CURSES
2605 # include <curses.h>
2606 #endif
2607 #include <term.h>
2608 int main(void){
2609 tgetent(NULL, getenv("TERM"));
2610 return 0;
2612 _EOT
2615 else
2616 echo '/* OPT_TERMCAP=0 */' >> ${h}
2617 echo '/* OPT_TERMCAP_VIA_TERMINFO=0 */' >> ${h}
2620 if feat_def SPAM_SPAMC; then
2621 if command -v spamc >/dev/null 2>&1; then
2622 echo "#define SPAM_SPAMC_PATH \"`command -v spamc`\"" >> ${h}
2626 if feat_yes SPAM_SPAMD && [ -n "${have_af_unix}" ]; then
2627 echo '#define HAVE_SPAM_SPAMD' >> ${h}
2628 else
2629 feat_bail_required SPAM_SPAMD
2630 echo '/* OPT_SPAM_SPAMD=0 */' >> ${h}
2633 feat_def SPAM_FILTER
2635 if feat_yes SPAM_SPAMC || feat_yes SPAM_SPAMD || feat_yes SPAM_FILTER; then
2636 echo '#define HAVE_SPAM' >> ${h}
2637 else
2638 echo '/* HAVE_SPAM */' >> ${h}
2641 if feat_yes QUOTE_FOLD &&\
2642 [ -n "${have_c90amend1}" ] && [ -n "${have_wcwidth}" ]; then
2643 echo '#define HAVE_QUOTE_FOLD' >> ${h}
2644 else
2645 feat_bail_required QUOTE_FOLD
2646 echo '/* OPT_QUOTE_FOLD=0 */' >> ${h}
2649 feat_def FILTER_HTML_TAGSOUP
2650 feat_def COLOUR
2651 feat_def DOTLOCK
2652 feat_def MD5
2653 feat_def NOMEMDBG
2655 ## Summarizing
2657 ${rm} -f ${tmp}
2658 squeeze_em ${inc} ${tmp}
2659 ${mv} ${tmp} ${inc}
2660 squeeze_em ${lib} ${tmp}
2661 ${mv} ${tmp} ${lib}
2663 # mk-config.h
2664 ${mv} ${h} ${tmp}
2665 printf '#ifndef n_MK_CONFIG_H\n# define n_MK_CONFIG_H 1\n' > ${h}
2666 ${cat} ${tmp} >> ${h}
2667 ${rm} -f ${tmp}
2668 printf '\n' >> ${h}
2670 # Create the string that is used by *features* and `version'.
2671 # Take this nice opportunity and generate a visual listing of included and
2672 # non-included features for the person who runs the configuration
2673 msg '\nThe following features are included (+) or not (-):'
2674 set -- ${OPTIONS_DETECT} ${OPTIONS} ${OPTIONS_XTRA}
2675 printf '/* The "feature string" */\n' >> ${h}
2676 # Because + is expanded by *folder* if first in "echo $features", put something
2677 printf '#define VAL_FEATURES_CNT '${#}'\n#define VAL_FEATURES "#' >> ${h}
2678 sep=
2679 for opt
2681 sdoc=`option_doc_of ${opt}`
2682 [ -z "${sdoc}" ] && continue
2683 sopt="`echo ${opt} | ${tr} '[A-Z]_' '[a-z]-'`"
2684 feat_yes ${opt} && sign=+ || sign=-
2685 printf -- "${sep}${sign}${sopt}" >> ${h}
2686 sep=','
2687 msg " %s %s: %s" ${sign} ${sopt} "${sdoc}"
2688 done
2689 # TODO instead of using sh+tr+awk+printf, use awk, drop option_doc_of, inc here
2690 #exec 5>&1 >>${h}
2691 #${awk} -v opts="${OPTIONS_DETECT} ${OPTIONS} ${OPTIONS_XTRA}" \
2692 # -v xopts="${XOPTIONS_DETECT} ${XOPTIONS} ${XOPTIONS_XTRA}" \
2693 printf '"\n' >> ${h}
2695 # Create the real mk-config.mk
2696 # Note we cannout use explicit ./ filename prefix for source and object
2697 # pathnames because of a bug in bmake(1)
2698 ${rm} -rf ${tmp0}.* ${tmp0}*
2699 srclist= objlist=
2700 if feat_no AMALGAMATION; then
2701 for i in `printf '%s\n' "${SRCDIR}"*.c | ${sort}`; do
2702 i=`basename "${i}" .c`
2703 if [ "${i}" = privsep ]; then
2704 continue
2706 objlist="${objlist} ${i}.o"
2707 srclist="${srclist} \$(SRCDIR)${i}.c"
2708 printf '%s: %s\n\t$(ECHO_CC)$(CC) $(CFLAGS) $(INCS) -c %s\n' \
2709 "${i}.o" "\$(SRCDIR)${i}.c" "\$(SRCDIR)${i}.c" >> ${mk}
2710 done
2711 printf '\nAMALGAM_TARGET =\nAMALGAM_DEP =\n' >> ${mk}
2712 else
2713 printf '%s:\n\t$(ECHO_CC)$(CC) $(CFLAGS) $(INCS) -c $(SRCDIR)%s\n' \
2714 "main.o" "main.c" >> ${mk}
2715 srclist=main.c objlist=main.o
2716 printf '\nAMALGAM_TARGET = main.o\nAMALGAM_DEP = ' >> ${mk}
2718 printf '\n/* HAVE_AMALGAMATION: include sources */\n' >> ${h}
2719 printf '#elif n_MK_CONFIG_H + 0 == 1\n' >> ${h}
2720 printf '# undef n_MK_CONFIG_H\n' >> ${h}
2721 printf '# define n_MK_CONFIG_H 2\n' >> ${h}
2722 for i in `printf '%s\n' "${SRCDIR}"*.c | ${sort}`; do
2723 i=`basename "${i}"`
2724 if [ "${i}" = main.c ] ||
2725 [ "${i}" = privsep.c ]; then
2726 continue
2728 printf '$(SRCDIR)%s ' "${i}" >> ${mk}
2729 printf '# include "%s%s"\n' "${SRCDIR}" "${i}" >> ${h}
2730 done
2731 echo >> ${mk}
2733 printf 'OBJ_SRC = %s\nOBJ = %s\n' "${srclist}" "${objlist}" >> "${mk}"
2735 printf '#endif /* n_MK_CONFIG_H */\n' >> ${h}
2737 echo "LIBS = `${cat} ${lib}`" >> ${mk}
2738 echo "INCS = `${cat} ${inc}`" >> ${mk}
2739 echo >> ${mk}
2740 ${cat} "${SRCDIR}"make-config.in >> ${mk}
2742 ## Finished!
2744 msg '\nSetup:'
2745 msg ' . System-wide resource file: %s/%s' "${VAL_SYSCONFDIR}" "${VAL_SYSCONFRC}"
2746 msg ' . bindir: %s' "${VAL_BINDIR}"
2747 if feat_yes DOTLOCK; then
2748 msg ' . libexecdir: %s' "${VAL_LIBEXECDIR}"
2750 msg ' . mandir: %s' "${VAL_MANDIR}"
2751 msg ' . M(ail)T(ransfer)A(gent): %s (argv0 %s)' "${VAL_MTA}" "${VAL_MTA_ARGV0}"
2752 msg ' . $MAIL spool directory: %s' "${VAL_MAIL}"
2753 msg ''
2755 if [ -n "${have_fnmatch}" ] && [ -n "${have_fchdir}" ]; then
2756 exit 0
2758 msg 'Remarks:'
2759 if [ -z "${have_fnmatch}" ]; then
2760 msg ' . The function fnmatch(3) could not be found.'
2761 msg ' Filename patterns like wildcard are not supported on your system'
2763 if [ -z "${have_fchdir}" ]; then
2764 msg ' . The function fchdir(2) could not be found.'
2765 msg ' We will use chdir(2) instead.'
2766 msg ' This is a problem only if the current working directory is changed'
2767 msg ' while this program is inside of it'
2769 msg ''
2771 # s-it-mode