Restore historical behaviour of *askb?cc* (Norman Ramsey)
[s-mailx.git] / make-config.sh
blob450a3926e503832038001fcefe5d3e413b5361ec
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 # E.g., valgrind does not work well with high optimization
459 if [ ${cc_maxopt} -gt 1 ] && feat_yes NOMEMDBG &&
460 feat_no ASAN_ADDRESS && feat_no ASAN_MEMORY; then
461 msg 'OP_NOMEMDBG, setting cc_maxopt=1 (-O1)'
462 cc_maxopt=1
464 # Check -g first since some others may rely upon -g / optim. level
465 if feat_yes DEBUG; then
466 cc_check -O
467 cc_check -g
468 elif [ ${cc_maxopt} -gt 2 ] && cc_check -O3; then
470 elif [ ${cc_maxopt} -gt 1 ] && cc_check -O2; then
472 elif [ ${cc_maxopt} -gt 0 ] && cc_check -O1; then
474 else
475 cc_check -O
478 if feat_yes AMALGAMATION; then
479 cc_check -pipe
482 #if feat_yes DEVEL && cc_check -Weverything; then
484 #else
485 cc_check -Wall
486 cc_check -Wextra
487 cc_check -Wbad-function-cast
488 cc_check -Wcast-align
489 cc_check -Wcast-qual
490 cc_check -Winit-self
491 cc_check -Wmissing-prototypes
492 cc_check -Wshadow
493 cc_check -Wunused
494 cc_check -Wwrite-strings
495 cc_check -Wno-long-long
497 cc_check -pedantic
499 if feat_yes AMALGAMATION && feat_no DEVEL; then
500 cc_check -Wno-unused-function
502 feat_no DEVEL && cc_check -Wno-unused-result # XXX do right way (pragma too)
504 cc_check -fno-unwind-tables
505 cc_check -fno-asynchronous-unwind-tables
506 cc_check -fstrict-aliasing
507 if cc_check -fstrict-overflow && feat_yes DEVEL; then
508 cc_check -Wstrict-overflow=5
511 if feat_yes DEBUG || feat_yes FORCED_STACKPROT; then
512 if [ -z "${force_no_stackprot}" ]; then
513 if cc_check -fstack-protector-strong ||
514 cc_check -fstack-protector-all; then
515 cc_check -D_FORTIFY_SOURCE=2
517 else
518 msg 'Not checking for -fstack-protector compiler option,'
519 msg 'since that caused errors in a "similar" configuration.'
520 msg 'You may turn off OPT_AUTOCC and use your own settings, rerun'
524 # LD (+ dependend CC)
526 if feat_yes ASAN_ADDRESS; then
527 _ccfg=${_CFLAGS}
528 if cc_check -fsanitize=address &&
529 ld_check -fsanitize=address; then
531 else
532 feat_bail_required ASAN_ADDRESS
533 _CFLAGS=${_ccfg}
537 if feat_yes ASAN_MEMORY; then
538 _ccfg=${_CFLAGS}
539 if cc_check -fsanitize=memory &&
540 ld_check -fsanitize=memory &&
541 cc_check -fsanitize-memory-track-origins=2 &&
542 ld_check -fsanitize-memory-track-origins=2; then
544 else
545 feat_bail_required ASAN_MEMORY
546 _CFLAGS=${_ccfg}
550 ld_check -Wl,-z,relro
551 ld_check -Wl,-z,now
552 ld_check -Wl,-z,noexecstack
553 if ld_check -Wl,-rpath =./ no; then
554 need_R_ldflags=-Wl,-rpath=
555 # Choose DT_RUNPATH (after $LD_LIBRARY_PATH) over DT_RPATH (before)
556 ld_check -Wl,--enable-new-dtags
557 ld_runtime_flags # update!
558 elif ld_check -Wl,-R ./ no; then
559 need_R_ldflags=-Wl,-R
560 ld_check -Wl,--enable-new-dtags
561 ld_runtime_flags # update!
564 # Address randomization
565 _ccfg=${_CFLAGS}
566 if cc_check -fPIE || cc_check -fpie; then
567 ld_check -pie || _CFLAGS=${_ccfg}
569 unset _ccfg
571 _CFLAGS="${_CFLAGS} ${__cflags}" _LDFLAGS="${_LDFLAGS} ${__ldflags}"
572 unset __cflags __ldflags
575 ## -- >8 - <<OS/CC | SUPPORT FUNS>> - 8< -- ##
577 ## Notes:
578 ## - Heirloom sh(1) (and same origin) have _sometimes_ problems with ': >'
579 ## redirection, so use "printf '' >" instead
581 ## Very first: we undergo several states regarding I/O redirection etc.,
582 ## but need to deal with option updates from within all. Since all the
583 ## option stuff should be above the scissor line, define utility functions
584 ## and redefine them as necessary.
585 ## And, since we have those functions, simply use them for whatever
587 config_exit() {
588 exit ${1}
591 msg() {
592 fmt=${1}
593 shift
594 printf >&2 -- "${fmt}\\n" "${@}"
597 msg_nonl() {
598 fmt=${1}
599 shift
600 printf >&2 -- "${fmt}" "${@}"
603 t1=ten10one1ten10one1
604 if ( [ ${t1##*ten10} = one1 ] && [ ${t1#*ten10} = one1ten10one1 ] &&
605 [ ${t1%%one1*} = ten10 ] && [ ${t1%one1*} = ten10one1ten10 ]
606 ) > /dev/null 2>&1; then
607 good_shell=1
608 else
609 unset good_shell
611 unset t1
613 # We need some standard utilities
614 unset -f command
615 check_tool() {
616 n=${1} i=${2} opt=${3:-0}
617 # Evaluate, just in case user comes in with shell snippets (..well..)
618 eval i="${i}"
619 if type "${i}" >/dev/null 2>&1; then # XXX why have i type not command -v?
620 [ -n "${VERBOSE}" ] && msg ' . ${%s} ... %s' "${n}" "${i}"
621 eval ${n}=${i}
622 return 0
624 if [ ${opt} -eq 0 ]; then
625 msg 'ERROR: no trace of utility %s' "${n}"
626 config_exit 1
628 return 1
631 # Our feature check environment
632 feat_val_no() {
633 [ "x${1}" = x0 ] || [ "x${1}" = xn ] ||
634 [ "x${1}" = xfalse ] || [ "x${1}" = xno ] || [ "x${1}" = xoff ]
637 feat_val_yes() {
638 [ "x${1}" = x1 ] || [ "x${1}" = xy ] ||
639 [ "x${1}" = xtrue ] || [ "x${1}" = xyes ] || [ "x${1}" = xon ] ||
640 [ "x${1}" = xrequire ]
643 feat_val_require() {
644 [ "x${1}" = xrequire ]
647 _feat_check() {
648 eval i=\$OPT_${1}
649 i="`echo ${i} | ${tr} '[A-Z]' '[a-z]'`"
650 if feat_val_no "${i}"; then
651 return 1
652 elif feat_val_yes "${i}"; then
653 return 0
654 else
655 msg "ERROR: %s: 0/n/false/no/off or 1/y/true/yes/on/require, got: %s" \
656 "${1}" "${i}"
657 config_exit 11
661 feat_yes() {
662 _feat_check ${1}
665 feat_no() {
666 _feat_check ${1} && return 1
667 return 0
670 feat_require() {
671 eval i=\$OPT_${1}
672 i="`echo ${i} | ${tr} '[A-Z]' '[a-z]'`"
673 [ "x${i}" = xrequire ] || [ "x${i}" = xrequired ]
676 feat_bail_required() {
677 if feat_require ${1}; then
678 msg 'ERROR: feature OPT_%s is required but not available' "${1}"
679 config_exit 13
681 eval OPT_${1}=0
682 option_update # XXX this is rather useless here (dependency chain..)
685 option_parse() {
686 # Parse one of our XOPTIONS* in $2 and assign the sh(1) compatible list of
687 # options, without documentation, to $1
688 j=\'
689 i="`${awk} -v input=\"${2}\" '
690 BEGIN{
691 for(i = 0;;){
692 voff = match(input, /[[:alnum:]_]+(='${j}'[^'${j}']+)?/)
693 if(voff == 0)
694 break
695 v = substr(input, voff, RLENGTH)
696 input = substr(input, voff + RLENGTH)
697 doff = index(v, "=")
698 if(doff > 0){
699 d = substr(v, doff + 2, length(v) - doff - 1)
700 v = substr(v, 1, doff - 1)
702 print v
706 eval ${1}=\"${i}\"
709 option_doc_of() {
710 # Return the "documentation string" for option $1, itself if none such
711 j=\'
712 ${awk} -v want="${1}" \
713 -v input="${XOPTIONS_DETECT}${XOPTIONS}${XOPTIONS_XTRA}" '
714 BEGIN{
715 for(;;){
716 voff = match(input, /[[:alnum:]_]+(='${j}'[^'${j}']+)?/)
717 if(voff == 0)
718 break
719 v = substr(input, voff, RLENGTH)
720 input = substr(input, voff + RLENGTH)
721 doff = index(v, "=")
722 if(doff > 0){
723 d = substr(v, doff + 2, length(v) - doff - 1)
724 v = substr(v, 1, doff - 1)
725 }else
726 d = v
727 if(v == want){
728 if(d != "-")
729 print d
730 exit
737 option_join_rc() {
738 # Join the values from make.rc into what currently is defined, not
739 # overwriting yet existing settings
740 ${rm} -f ${tmp}
741 # We want read(1) to perform reverse solidus escaping in order to be able to
742 # use multiline values in make.rc; the resulting sh(1)/sed(1) code was very
743 # slow in VMs (see [fa2e248]), Aharon Robbins suggested the following
744 < ${rc} ${awk} 'BEGIN{line = ""}{
745 gsub(/^[[:space:]]+/, "", $0)
746 gsub(/[[:space:]]+$/, "", $0)
747 if(gsub(/\\$/, "", $0)){
748 line = line $0
749 next
750 }else
751 line = line $0
752 if(index(line, "#") == 1){
753 line = ""
754 }else if(length(line)){
755 print line
756 line = ""
758 }' |
759 while read line; do
760 if [ -n "${good_shell}" ]; then
761 i=${line%%=*}
762 else
763 i=`${awk} -v LINE="${line}" 'BEGIN{
764 gsub(/=.*$/, "", LINE)
765 print LINE
768 if [ "${i}" = "${line}" ]; then
769 msg 'ERROR: invalid syntax in: %s' "${line}"
770 continue
773 eval j="\$${i}" jx="\${${i}+x}"
774 if [ -n "${j}" ] || [ "${jx}" = x ]; then
775 : # Yet present
776 else
777 j=`${awk} -v LINE="${line}" 'BEGIN{
778 gsub(/^[^=]*=/, "", LINE)
779 gsub(/^\"*/, "", LINE)
780 gsub(/\"*$/, "", LINE)
781 print LINE
784 [ "${i}" = "DESTDIR" ] && continue
785 echo "${i}=\"${j}\""
786 done > ${tmp}
787 # Reread the mixed version right now
788 . ./${tmp}
791 option_evaluate() {
792 # Expand the option values, which may contain shell snippets
793 ${rm} -f ${newlst} ${newmk} ${newh}
794 exec 5<&0 6>&1 <${tmp} >${newlst}
795 while read line; do
797 if [ -n "${good_shell}" ]; then
798 i=${line%%=*}
799 [ "${i}" != "${i#OPT_}" ] && z=1
800 else
801 i=`${awk} -v LINE="${line}" 'BEGIN{
802 gsub(/=.*$/, "", LINE);\
803 print LINE
805 if echo "${i}" | ${grep} '^OPT_' >/dev/null 2>&1; then
810 eval j=\$${i}
811 if [ -n "${z}" ]; then
812 j="`echo ${j} | ${tr} '[A-Z]' '[a-z]'`"
813 if [ -z "${j}" ] || feat_val_no "${j}"; then
815 printf " /* #undef ${i} */\n" >> ${newh}
816 elif feat_val_yes "${j}"; then
817 if feat_val_require "${j}"; then
818 j=require
819 else
822 printf " /* #define ${i} */\n" >> ${newh}
823 else
824 msg 'ERROR: cannot parse <%s>' "${line}"
825 config_exit 1
827 else
828 printf "#define ${i} \"${j}\"\n" >> ${newh}
830 printf "${i} = ${j}\n" >> ${newmk}
831 printf "${i}=${j}\n"
832 eval "${i}=\"${j}\""
833 done
834 exec 0<&5 1>&6 5<&- 6<&-
837 path_check() {
838 # "path_check VARNAME" or "path_check VARNAME FLAG VARNAME"
839 varname=${1} addflag=${2} flagvarname=${3}
840 j=${IFS}
841 IFS=:
842 eval "set -- \$${1}"
843 IFS=${j}
844 j= k= y= z=
845 for i
847 [ -z "${i}" ] && continue
848 [ -d "${i}" ] || continue
849 if [ -n "${j}" ]; then
850 if { z=${y}; echo "${z}"; } | ${grep} ":${i}:" >/dev/null 2>&1; then
852 else
853 y="${y} :${i}:"
854 j="${j}:${i}"
855 # But do not link any fakeroot path into our binaries!
856 if [ -n "${addflag}" ]; then
857 case "${i}" in *fakeroot*) continue;; esac
858 k="${k} ${addflag}${i}"
861 else
862 y=" :${i}:"
863 j="${i}"
864 # But do not link any fakeroot path into our binaries!
865 if [ -n "${addflag}" ]; then
866 case "${i}" in *fakeroot*) continue;; esac
867 k="${k} ${addflag}${i}"
870 done
871 eval "${varname}=\"${j}\""
872 [ -n "${addflag}" ] && eval "${flagvarname}=\"${k}\""
873 unset varname
876 ld_runtime_flags() {
877 if [ -n "${need_R_ldflags}" ]; then
878 i=${IFS}
879 IFS=:
880 set -- ${LD_LIBRARY_PATH}
881 IFS=${i}
882 for i
884 # But do not link any fakeroot path into our binaries!
885 case "${i}" in *fakeroot*) continue;; esac
886 LDFLAGS="${LDFLAGS} ${need_R_ldflags}${i}"
887 _LDFLAGS="${_LDFLAGS} ${need_R_ldflags}${i}"
888 done
889 export LDFLAGS
891 # Disable it for a possible second run.
892 need_R_ldflags=
895 cc_check() {
896 [ -n "${cc_check_silent}" ] || msg_nonl ' . CC %s .. ' "${1}"
897 if "${CC}" ${INCS} \
898 ${_CFLAGS} ${1} ${EXTRA_CFLAGS} ${_LDFLAGS} ${EXTRA_LDFLAGS} \
899 -o ${tmp2} ${tmp}.c ${LIBS} >/dev/null 2>&1; then
900 _CFLAGS="${_CFLAGS} ${1}"
901 [ -n "${cc_check_silent}" ] || msg 'yes'
902 return 0
904 [ -n "${cc_check_silent}" ] || msg 'no'
905 return 1
908 ld_check() {
909 # $1=option [$2=option argument] [$3=if set, shall NOT be added to _LDFLAGS]
910 [ -n "${cc_check_silent}" ] || msg_nonl ' . LD %s .. ' "${1}"
911 if "${CC}" ${INCS} ${_CFLAGS} ${_LDFLAGS} ${1}${2} ${EXTRA_LDFLAGS} \
912 -o ${tmp2} ${tmp}.c ${LIBS} >/dev/null 2>&1; then
913 [ -n "${3}" ] || _LDFLAGS="${_LDFLAGS} ${1}"
914 [ -n "${cc_check_silent}" ] || msg 'yes'
915 return 0
917 [ -n "${cc_check_silent}" ] || msg 'no'
918 return 1
921 _check_preface() {
922 variable=$1 topic=$2 define=$3
924 echo '**********'
925 msg_nonl ' . %s ... ' "${topic}"
926 echo "/* checked ${topic} */" >> ${h}
927 ${rm} -f ${tmp} ${tmp}.o
928 echo '*** test program is'
929 { echo '#include <'"${h_name}"'>'; cat; } | ${tee} ${tmp}.c
930 #echo '*** the preprocessor generates'
931 #${make} -f ${makefile} ${tmp}.x
932 #${cat} ${tmp}.x
933 echo '*** results are'
936 without_check() {
937 yesno=$1 variable=$2 topic=$3 define=$4 libs=$5 incs=$6
939 echo '**********'
940 msg_nonl ' . %s ... ' "${topic}"
942 echo '*** enforced unchecked results are'
943 if feat_val_yes ${yesno}; then
944 if [ -n "${incs}" ] || [ -n "${libs}" ]; then
945 echo "*** adding INCS<${incs}> LIBS<${libs}>"
946 LIBS="${LIBS} ${libs}"
947 echo "${libs}" >> ${lib}
948 INCS="${INCS} ${incs}"
949 echo "${incs}" >> ${inc}
951 msg 'yes (deduced)'
952 echo "${define}" >> ${h}
953 eval have_${variable}=yes
954 return 0
955 else
956 echo "/* ${define} */" >> ${h}
957 msg 'no (deduced)'
958 eval unset have_${variable}
959 return 1
963 compile_check() {
964 variable=$1 topic=$2 define=$3
966 _check_preface "${variable}" "${topic}" "${define}"
968 if ${make} -f ${makefile} XINCS="${INCS}" \
969 CFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}" \
970 ./${tmp}.o &&
971 [ -f ./${tmp}.o ]; then
972 msg 'yes'
973 echo "${define}" >> ${h}
974 eval have_${variable}=yes
975 return 0
976 else
977 echo "/* ${define} */" >> ${h}
978 msg 'no'
979 eval unset have_${variable}
980 return 1
984 _link_mayrun() {
985 run=$1 variable=$2 topic=$3 define=$4 libs=$5 incs=$6
987 _check_preface "${variable}" "${topic}" "${define}"
989 if feat_yes CROSS_BUILD; then
990 if [ ${run} = 1 ]; then
991 run=0
995 if ${make} -f ${makefile} XINCS="${INCS} ${incs}" \
996 CFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}" \
997 XLIBS="${LIBS} ${libs}" \
998 ./${tmp} &&
999 [ -f ./${tmp} ] &&
1000 { [ ${run} -eq 0 ] || ./${tmp}; }; then
1001 echo "*** adding INCS<${incs}> LIBS<${libs}>; executed: ${run}"
1002 msg 'yes'
1003 echo "${define}" >> ${h}
1004 LIBS="${LIBS} ${libs}"
1005 echo "${libs}" >> ${lib}
1006 INCS="${INCS} ${incs}"
1007 echo "${incs}" >> ${inc}
1008 eval have_${variable}=yes
1009 return 0
1010 else
1011 msg 'no'
1012 echo "/* ${define} */" >> ${h}
1013 eval unset have_${variable}
1014 return 1
1018 link_check() {
1019 _link_mayrun 0 "${1}" "${2}" "${3}" "${4}" "${5}"
1022 run_check() {
1023 _link_mayrun 1 "${1}" "${2}" "${3}" "${4}" "${5}"
1026 xrun_check() {
1027 _link_mayrun 2 "${1}" "${2}" "${3}" "${4}" "${5}"
1030 feat_def() {
1031 if feat_yes ${1}; then
1032 echo '#define HAVE_'${1}'' >> ${h}
1033 return 0
1034 else
1035 echo '/* OPT_'${1}'=0 */' >> ${h}
1036 return 1
1040 squeeze_em() {
1041 < "${1}" > "${2}" ${awk} \
1042 'BEGIN {ORS = " "} /^[^#]/ {print} {next} END {ORS = ""; print "\n"}'
1045 ## -- >8 - <<SUPPORT FUNS | RUNNING>> - 8< -- ##
1047 # First of all, create new configuration and check whether it changed
1049 # Very easy checks for the operating system in order to be able to adjust paths
1050 # or similar very basic things which we need to be able to go at all
1051 os_early_setup
1053 # Check those tools right now that we need before including $rc
1054 msg 'Checking for basic utility set'
1055 check_tool awk "${awk:-`command -v awk`}"
1056 check_tool rm "${rm:-`command -v rm`}"
1057 check_tool tr "${tr:-`command -v tr`}"
1059 # Initialize the option set
1060 msg_nonl 'Setting up configuration options ... '
1061 option_setup
1062 msg 'done'
1064 # Include $rc, but only take from it what wasn't overwritten by the user from
1065 # within the command line or from a chosen fixed CONFIG=
1066 # Note we leave alone the values
1067 trap "exit 1" HUP INT TERM
1068 trap "${rm} -f ${tmp}" EXIT
1070 msg_nonl 'Joining in %s ... ' ${rc}
1071 option_join_rc
1072 msg 'done'
1074 # We need to know about that now, in order to provide utility overwrites etc.
1075 os_setup
1077 msg 'Checking for remaining set of utilities'
1078 check_tool grep "${grep:-`command -v grep`}"
1080 # Before we step ahead with the other utilities perform a path cleanup first.
1081 path_check PATH
1083 # awk(1) above
1084 check_tool basename "${basename:-`command -v basename`}"
1085 check_tool cat "${cat:-`command -v cat`}"
1086 check_tool chmod "${chmod:-`command -v chmod`}"
1087 check_tool cp "${cp:-`command -v cp`}"
1088 check_tool cmp "${cmp:-`command -v cmp`}"
1089 # grep(1) above
1090 check_tool mkdir "${mkdir:-`command -v mkdir`}"
1091 check_tool mv "${mv:-`command -v mv`}"
1092 # rm(1) above
1093 check_tool sed "${sed:-`command -v sed`}"
1094 check_tool sort "${sort:-`command -v sort`}"
1095 check_tool tee "${tee:-`command -v tee`}"
1097 check_tool chown "${chown:-`command -v chown`}" 1 ||
1098 check_tool chown "/sbin/chown" 1 ||
1099 check_tool chown "/usr/sbin/chown"
1101 check_tool make "${MAKE:-`command -v make`}"
1102 MAKE=${make}
1103 check_tool strip "${STRIP:-`command -v strip`}" 1 &&
1104 HAVE_STRIP=1 || HAVE_STRIP=0
1106 # For ./cc-test.sh only
1107 check_tool cksum "${cksum:-`command -v cksum`}"
1109 # Update OPT_ options now, in order to get possible inter-dependencies right
1110 option_update
1112 # (No functions since some shells loose non-exported variables in traps)
1113 trap "trap \"\" HUP INT TERM; exit 1" HUP INT TERM
1114 trap "trap \"\" HUP INT TERM EXIT;\
1115 ${rm} -rf ${newlst} ${tmp0}.* ${tmp0}* ${newmk} ${newev} ${newh}" EXIT
1117 # Our configuration options may at this point still contain shell snippets,
1118 # we need to evaluate them in order to get them expanded, and we need those
1119 # evaluated values not only in our new configuration file, but also at hand..
1120 msg_nonl 'Evaluating all configuration items ... '
1121 option_evaluate
1122 msg 'done'
1124 # Add the known utility and some other variables
1125 printf "#define VAL_UAGENT \"${VAL_SID}${VAL_MAILX}\"\n" >> ${newh}
1126 printf "VAL_UAGENT = ${VAL_SID}${VAL_MAILX}\n" >> ${newmk}
1128 printf "#define VAL_PRIVSEP \"${VAL_SID}${VAL_MAILX}-privsep\"\n" >> ${newh}
1129 printf "VAL_PRIVSEP = \$(VAL_UAGENT)-privsep\n" >> ${newmk}
1130 if feat_yes DOTLOCK; then
1131 printf "OPTIONAL_PRIVSEP = \$(VAL_PRIVSEP)\n" >> ${newmk}
1132 else
1133 printf "OPTIONAL_PRIVSEP =\n" >> ${newmk}
1136 for i in \
1137 SRCDIR \
1138 awk basename cat chmod chown cp cmp grep mkdir mv rm sed sort tee tr \
1139 MAKE MAKEFLAGS make SHELL strip \
1140 cksum; do
1141 eval j=\$${i}
1142 printf "${i} = ${j}\n" >> ${newmk}
1143 printf "${i}=${j}\n" >> ${newlst}
1144 printf "${i}=\"${j}\";export ${i}; " >> ${newev}
1145 done
1146 printf "\n" >> ${newev}
1148 # Build a basic set of INCS and LIBS according to user environment.
1149 C_INCLUDE_PATH="./:${SRCDIR}:${C_INCLUDE_PATH}"
1150 path_check C_INCLUDE_PATH -I _INCS
1151 INCS="${INCS} ${_INCS}"
1152 path_check LD_LIBRARY_PATH -L _LIBS
1153 LIBS="${LIBS} ${_LIBS}"
1154 unset _INCS _LIBS
1155 export C_INCLUDE_PATH LD_LIBRARY_PATH
1157 # Some environments need runtime path flags to be able to go at all
1158 ld_runtime_flags
1160 ## Detect CC, whether we can use it, and possibly which CFLAGS we can use
1162 cc_setup
1164 ${cat} > ${tmp}.c << \!
1165 #include <stdio.h>
1166 #include <string.h>
1167 static void doit(char const *s);
1169 main(int argc, char **argv){
1170 (void)argc;
1171 (void)argv;
1172 doit("Hello world");
1173 return 0;
1175 static void
1176 doit(char const *s){
1177 char buf[12];
1178 memcpy(buf, s, strlen(s) +1);
1179 puts(s);
1183 if "${CC}" ${INCS} ${CFLAGS} ${EXTRA_CFLAGS} ${LDFLAGS} ${EXTRA_LDFLAGS} \
1184 -o ${tmp2} ${tmp}.c ${LIBS}; then
1186 else
1187 msg 'ERROR: i cannot compile a "Hello world" via'
1188 msg ' %s' \
1189 "${CC} ${INCS} ${CFLAGS} ${EXTRA_CFLAGS} ${LDFLAGS} ${EXTRA_LDFLAGS} ${LIBS}"
1190 msg 'ERROR: Please read INSTALL, rerun'
1191 config_exit 1
1194 # This may also update ld_runtime_flags() (again)
1195 cc_flags
1197 for i in \
1198 INCS LIBS \
1199 ; do
1200 eval j=\$${i}
1201 printf -- "${i}=${j}\n" >> ${newlst}
1202 done
1203 for i in \
1204 CC \
1205 CFLAGS \
1206 LDFLAGS \
1207 PATH C_INCLUDE_PATH LD_LIBRARY_PATH \
1208 OSFULLSPEC \
1209 ; do
1210 eval j=\$${i}
1211 printf -- "${i} = ${j}\n" >> ${newmk}
1212 printf -- "${i}=${j}\n" >> ${newlst}
1213 done
1215 # Now finally check whether we already have a configuration and if so, whether
1216 # all those parameters are still the same.. or something has actually changed
1217 if [ -f ${lst} ] && ${cmp} ${newlst} ${lst} >/dev/null 2>&1; then
1218 echo 'Configuration is up-to-date'
1219 exit 0
1220 elif [ -f ${lst} ]; then
1221 echo 'Configuration has been updated..'
1222 ( eval "${MAKE} -f ./mk-config.mk clean" )
1223 echo
1224 else
1225 echo 'Shiny configuration..'
1228 # Time to redefine helper 1
1229 config_exit() {
1230 ${rm} -f ${lst} ${h} ${mk}
1231 exit ${1}
1234 ${mv} -f ${newlst} ${lst}
1235 ${mv} -f ${newev} ${ev}
1236 ${mv} -f ${newh} ${h}
1237 ${mv} -f ${newmk} ${mk}
1239 if [ -z "${VERBOSE}" ]; then
1240 printf -- "ECHO_CC = @echo ' 'CC \$(@);\n" >> ${mk}
1241 printf -- "ECHO_LINK = @echo ' 'LINK \$(@);\n" >> ${mk}
1242 printf -- "ECHO_GEN = @echo ' 'GEN \$(@);\n" >> ${mk}
1243 printf -- "ECHO_TEST = @\n" >> ${mk}
1244 printf -- "ECHO_CMD = @echo ' CMD';\n" >> ${mk}
1245 printf -- "ECHO_BLOCK_BEGIN = @( \n" >> ${mk}
1246 printf -- "ECHO_BLOCK_END = ) >/dev/null\n" >> ${mk}
1249 ## Compile and link checking
1251 tmp3=./${tmp0}3$$
1252 log=./mk-config.log
1253 lib=./mk-config.lib
1254 inc=./mk-config.inc
1255 makefile=./${tmp0}.mk
1257 # (No function since some shells loose non-exported variables in traps)
1258 trap "trap \"\" HUP INT TERM;\
1259 ${rm} -f ${lst} ${h} ${mk} ${lib} ${inc}; exit 1" HUP INT TERM
1260 trap "trap \"\" HUP INT TERM EXIT;\
1261 ${rm} -rf ${tmp0}.* ${tmp0}*" EXIT
1263 # Time to redefine helper 2
1264 msg() {
1265 fmt=${1}
1266 shift
1267 printf "*** ${fmt}\\n" "${@}"
1268 printf -- "${fmt}\\n" "${@}" >&5
1270 msg_nonl() {
1271 fmt=${1}
1272 shift
1273 printf "*** ${fmt}\\n" "${@}"
1274 printf -- "${fmt}" "${@}" >&5
1277 # !!
1278 exec 5>&2 > ${log} 2>&1
1280 echo "${LIBS}" > ${lib}
1281 echo "${INCS}" > ${inc}
1282 ${cat} > ${makefile} << \!
1283 .SUFFIXES: .o .c .x .y
1284 .c.o:
1285 $(CC) -I./ $(XINCS) $(CFLAGS) -c $(<)
1286 .c.x:
1287 $(CC) -I./ $(XINCS) -E $(<) > $(@)
1289 $(CC) -I./ $(XINCS) $(CFLAGS) $(LDFLAGS) -o $(@) $(<) $(XLIBS)
1292 ## Generics
1294 # May be multiline..
1295 echo >> ${h}
1296 [ -n "${OS_DEFINES}" ] && printf -- "${OS_DEFINES}" >> ${h}
1297 echo '#define VAL_BUILD_OS "'"${OS}"'"' >> ${h}
1298 echo '#define VAL_BUILD_OSENV "'"${OSENV}"'"' >> ${h}
1300 # Generate n_err_number OS mappings
1302 feat_yes DEVEL && NV= || NV=noverbose
1303 SRCDIR="${SRCDIR}" TARGET="${h}" awk="${awk}" \
1304 ${SHELL} "${SRCDIR}"make-errors.sh ${NV} config
1306 xrun_check oserrno 'OS error mapping table generated' || config_exit 1
1308 feat_def ALWAYS_UNICODE_LOCALE
1309 feat_def AMALGAMATION
1310 feat_def CROSS_BUILD
1311 feat_def DOCSTRINGS
1312 feat_def ERRORS
1314 feat_def ASAN_ADDRESS
1315 feat_def ASAN_MEMORY
1316 feat_def DEBUG
1317 feat_def DEVEL
1318 feat_def NYD2
1319 feat_def NOMEMDBG
1321 if xrun_check inline 'inline functions' \
1322 '#define HAVE_INLINE
1323 #define n_INLINE static inline' << \!
1324 static inline int ilf(int i){return ++i;}
1325 int main(void){return ilf(-1);}
1327 then
1329 elif xrun_check inline 'inline functions (via __inline)' \
1330 '#define HAVE_INLINE
1331 #define n_INLINE static __inline' << \!
1332 static __inline int ilf(int i){return ++i;}
1333 int main(void){return ilf(-1);}
1335 then
1339 ## Test for "basic" system-calls / functionality that is used by all parts
1340 ## of our program. Once this is done fork away BASE_LIBS and other BASE_*
1341 ## macros to be used by only the subprograms (potentially).
1343 if run_check clock_gettime 'clock_gettime(2)' \
1344 '#define HAVE_CLOCK_GETTIME' << \!
1345 #include <time.h>
1346 # include <errno.h>
1347 int main(void){
1348 struct timespec ts;
1350 if(!clock_gettime(CLOCK_REALTIME, &ts) || errno != ENOSYS)
1351 return 0;
1352 return 1;
1355 then
1357 elif run_check clock_gettime 'clock_gettime(2) (via -lrt)' \
1358 '#define HAVE_CLOCK_GETTIME' '-lrt' << \!
1359 #include <time.h>
1360 # include <errno.h>
1361 int main(void){
1362 struct timespec ts;
1364 if(!clock_gettime(CLOCK_REALTIME, &ts) || errno != ENOSYS)
1365 return 0;
1366 return 1;
1369 then
1371 elif run_check gettimeofday 'gettimeofday(2)' \
1372 '#define HAVE_GETTIMEOFDAY' << \!
1373 #include <stdio.h> /* For C89 NULL */
1374 #include <sys/time.h>
1375 # include <errno.h>
1376 int main(void){
1377 struct timeval tv;
1379 if(!gettimeofday(&tv, NULL) || errno != ENOSYS)
1380 return 0;
1381 return 1;
1384 then
1386 else
1387 have_no_subsecond_time=1
1390 if run_check nanosleep 'nanosleep(2)' \
1391 '#define HAVE_NANOSLEEP' << \!
1392 #include <time.h>
1393 # include <errno.h>
1394 int main(void){
1395 struct timespec ts;
1397 ts.tv_sec = 1;
1398 ts.tv_nsec = 100000;
1399 if(!nanosleep(&ts, NULL) || errno != ENOSYS)
1400 return 0;
1401 return 1;
1404 then
1406 elif run_check nanosleep 'nanosleep(2) (via -lrt)' \
1407 '#define HAVE_NANOSLEEP' '-lrt' << \!
1408 #include <time.h>
1409 # include <errno.h>
1410 int main(void){
1411 struct timespec ts;
1413 ts.tv_sec = 1;
1414 ts.tv_nsec = 100000;
1415 if(!nanosleep(&ts, NULL) || errno != ENOSYS)
1416 return 0;
1417 return 1;
1420 then
1422 # link_check is enough for this, that function is so old, trust the proto
1423 elif link_check sleep 'sleep(3)' \
1424 '#define HAVE_SLEEP' << \!
1425 #include <unistd.h>
1426 # include <errno.h>
1427 int main(void){
1428 if(!sleep(1) || errno != ENOSYS)
1429 return 0;
1430 return 1;
1433 then
1435 else
1436 msg 'ERROR: we require one of nanosleep(2) and sleep(3).'
1437 config_exit 1
1440 if run_check userdb 'gete?[gu]id(2), getpwuid(3), getpwnam(3)' << \!
1441 #include <pwd.h>
1442 #include <unistd.h>
1443 # include <errno.h>
1444 int main(void){
1445 struct passwd *pw;
1446 gid_t gid;
1447 uid_t uid;
1449 if((gid = getgid()) != 0)
1450 gid = getegid();
1451 if((uid = getuid()) != 0)
1452 uid = geteuid();
1453 if((pw = getpwuid(uid)) == NULL && errno == ENOSYS)
1454 return 1;
1455 if((pw = getpwnam("root")) == NULL && errno == ENOSYS)
1456 return 1;
1457 return 0;
1460 then
1462 else
1463 msg 'ERROR: we require user and group info / database searches.'
1464 msg 'That much Unix we indulge ourselfs.'
1465 config_exit 1
1468 if link_check ftruncate 'ftruncate(2)' \
1469 '#define HAVE_FTRUNCATE' << \!
1470 #include <unistd.h>
1471 #include <sys/types.h>
1472 int main(void){
1473 return (ftruncate(0, 0) != 0);
1476 then
1478 else
1479 msg 'ERROR: we require the ftruncate(2) system call.'
1480 config_exit 1
1483 if run_check sa_restart 'SA_RESTART (for sigaction(2))' << \!
1484 #include <signal.h>
1485 # include <errno.h>
1486 int main(void){
1487 struct sigaction nact, oact;
1489 nact.sa_handler = SIG_DFL;
1490 sigemptyset(&nact.sa_mask);
1491 nact.sa_flags = SA_RESTART;
1492 return !(!sigaction(SIGCHLD, &nact, &oact) || errno != ENOSYS);
1495 then
1497 else
1498 msg 'ERROR: we (yet) require the SA_RESTART flag for sigaction(2).'
1499 config_exit 1
1502 if link_check snprintf 'snprintf(3)' << \!
1503 #include <stdio.h>
1504 int main(void){
1505 char b[20];
1507 snprintf(b, sizeof b, "%s", "string");
1508 return 0;
1511 then
1513 else
1514 msg 'ERROR: we require the snprintf(3) function.'
1515 config_exit 1
1518 if link_check environ 'environ(3)' << \!
1519 #include <stdio.h> /* For C89 NULL */
1520 int main(void){
1521 extern char **environ;
1523 return environ[0] == NULL;
1526 then
1528 else
1529 msg 'ERROR: we require the environ(3) array for subprocess control.'
1530 config_exit 1
1533 if link_check setenv '(un)?setenv(3)' '#define HAVE_SETENV' << \!
1534 #include <stdlib.h>
1535 int main(void){
1536 setenv("s-mailx", "i want to see it cute!", 1);
1537 unsetenv("s-mailx");
1538 return 0;
1541 then
1543 elif link_check setenv 'putenv(3)' '#define HAVE_PUTENV' << \!
1544 #include <stdlib.h>
1545 int main(void){
1546 putenv("s-mailx=i want to see it cute!");
1547 return 0;
1550 then
1552 else
1553 msg 'ERROR: we require either the setenv(3) or putenv(3) functions.'
1554 config_exit 1
1557 if link_check termios 'termios.h and tc*(3) family' << \!
1558 #include <termios.h>
1559 int main(void){
1560 struct termios tios;
1562 tcgetattr(0, &tios);
1563 tcsetattr(0, TCSANOW | TCSADRAIN | TCSAFLUSH, &tios);
1564 return 0;
1567 then
1569 else
1570 msg 'ERROR: we require termios.h and the tc*() family of functions.'
1571 msg 'That much Unix we indulge ourselfs.'
1572 config_exit 1
1575 ## optional stuff
1577 if link_check vsnprintf 'vsnprintf(3)' << \!
1578 #include <stdarg.h>
1579 #include <stdio.h>
1580 static void dome(char *buf, size_t blen, ...){
1581 va_list ap;
1583 va_start(ap, blen);
1584 vsnprintf(buf, blen, "%s", ap);
1585 va_end(ap);
1587 int main(void){
1588 char b[20];
1590 dome(b, sizeof b, "string");
1591 return 0;
1594 then
1596 else
1597 feat_bail_required ERRORS
1600 if [ "${have_vsnprintf}" = yes ]; then
1601 __va_copy() {
1602 link_check va_copy "va_copy(3) (as ${2})" \
1603 "#define HAVE_N_VA_COPY
1604 #define n_va_copy ${2}" <<_EOT
1605 #include <stdarg.h>
1606 #include <stdio.h>
1607 #if ${1}
1608 # if defined __va_copy && !defined va_copy
1609 # define va_copy __va_copy
1610 # endif
1611 #endif
1612 static void dome2(char *buf, size_t blen, va_list src){
1613 va_list ap;
1615 va_copy(ap, src);
1616 vsnprintf(buf, blen, "%s", ap);
1617 va_end(ap);
1619 static void dome(char *buf, size_t blen, ...){
1620 va_list ap;
1622 va_start(ap, blen);
1623 dome2(buf, blen, ap);
1624 va_end(ap);
1626 int main(void){
1627 char b[20];
1629 dome(b, sizeof b, "string");
1630 return 0;
1632 _EOT
1634 __va_copy 0 va_copy || __va_copy 1 __va_copy
1637 run_check pathconf 'f?pathconf(2)' '#define HAVE_PATHCONF' << \!
1638 #include <unistd.h>
1639 #include <errno.h>
1640 int main(void){
1641 int rv = 0;
1643 errno = 0;
1644 rv |= !(pathconf(".", _PC_NAME_MAX) >= 0 || errno == 0 || errno != ENOSYS);
1645 errno = 0;
1646 rv |= !(pathconf(".", _PC_PATH_MAX) >= 0 || errno == 0 || errno != ENOSYS);
1648 /* Only link check */
1649 fpathconf(0, _PC_NAME_MAX);
1651 return rv;
1655 run_check pipe2 'pipe2(2)' '#define HAVE_PIPE2' << \!
1656 #include <fcntl.h>
1657 #include <unistd.h>
1658 # include <errno.h>
1659 int main(void){
1660 int fds[2];
1662 if(!pipe2(fds, O_CLOEXEC) || errno != ENOSYS)
1663 return 0;
1664 return 1;
1668 # We use this only then for now (need NOW+1)
1669 run_check utimensat 'utimensat(2)' '#define HAVE_UTIMENSAT' << \!
1670 #include <fcntl.h> /* For AT_* */
1671 #include <sys/stat.h>
1672 # include <errno.h>
1673 int main(void){
1674 struct timespec ts[2];
1676 ts[0].tv_nsec = UTIME_NOW;
1677 ts[1].tv_nsec = UTIME_OMIT;
1678 if(!utimensat(AT_FDCWD, "", ts, 0) || errno != ENOSYS)
1679 return 0;
1680 return 1;
1686 # XXX Add POSIX check once standardized
1687 if link_check posix_random 'arc4random(3)' '#define HAVE_POSIX_RANDOM 0' << \!
1688 #include <stdlib.h>
1689 int main(void){
1690 arc4random();
1691 return 0;
1694 then
1696 elif link_check getrandom 'getrandom(2) (in sys/random.h)' \
1697 '#define HAVE_GETRANDOM(B,S) getrandom(B, S, 0)
1698 #define HAVE_GETRANDOM_HEADER <sys/random.h>' <<\!
1699 #include <sys/random.h>
1700 int main(void){
1701 char buf[256];
1702 getrandom(buf, sizeof buf, 0);
1703 return 0;
1706 then
1708 elif link_check getrandom 'getrandom(2) (via syscall(2))' \
1709 '#define HAVE_GETRANDOM(B,S) syscall(SYS_getrandom, B, S, 0)
1710 #define HAVE_GETRANDOM_HEADER <sys/syscall.h>' <<\!
1711 #include <sys/syscall.h>
1712 int main(void){
1713 char buf[256];
1714 syscall(SYS_getrandom, buf, sizeof buf, 0);
1715 return 0;
1718 then
1720 elif [ -n "${have_no_subsecond_time}" ]; then
1721 msg 'ERROR: %s %s' 'without a native random' \
1722 'one of clock_gettime(2) and gettimeofday(2) is required.'
1723 config_exit 1
1727 link_check putc_unlocked 'putc_unlocked(3)' '#define HAVE_PUTC_UNLOCKED' <<\!
1728 #include <stdio.h>
1729 int main(void){
1730 putc_unlocked('@', stdout);
1731 return 0;
1735 link_check fchdir 'fchdir(3)' '#define HAVE_FCHDIR' << \!
1736 #include <unistd.h>
1737 int main(void){
1738 fchdir(0);
1739 return 0;
1743 if run_check realpath 'realpath(3)' '#define HAVE_REALPATH' << \!
1744 #include <stdlib.h>
1745 int main(void){
1746 char x_buf[4096], *x = realpath(".", x_buf);
1748 return (x != NULL) ? 0 : 1;
1751 then
1752 if run_check realpath_malloc 'realpath(3) takes NULL' \
1753 '#define HAVE_REALPATH_NULL' << \!
1754 #include <stdlib.h>
1755 int main(void){
1756 char *x = realpath(".", NULL);
1758 if(x != NULL)
1759 free(x);
1760 return (x != NULL) ? 0 : 1;
1763 then
1768 ## optional and selectable
1770 if feat_yes DOTLOCK; then
1771 if run_check readlink 'readlink(2)' << \!
1772 #include <unistd.h>
1773 # include <errno.h>
1774 int main(void){
1775 char buf[128];
1777 if(!readlink("here", buf, sizeof buf) || errno != ENOSYS)
1778 return 0;
1779 return 1;
1782 then
1784 else
1785 feat_bail_required DOTLOCK
1789 if feat_yes DOTLOCK; then
1790 if run_check fchown 'fchown(2)' << \!
1791 #include <unistd.h>
1792 # include <errno.h>
1793 int main(void){
1794 if(!fchown(0, 0, 0) || errno != ENOSYS)
1795 return 0;
1796 return 1;
1799 then
1801 else
1802 feat_bail_required DOTLOCK
1806 ## Now it is the time to fork away the BASE_ series
1808 ${rm} -f ${tmp}
1809 squeeze_em ${inc} ${tmp}
1810 ${mv} ${tmp} ${inc}
1811 squeeze_em ${lib} ${tmp}
1812 ${mv} ${tmp} ${lib}
1814 echo "BASE_LIBS = `${cat} ${lib}`" >> ${mk}
1815 echo "BASE_INCS = `${cat} ${inc}`" >> ${mk}
1817 ## The remains are expected to be used only by the main MUA binary!
1819 OPT_LOCALES=0
1820 link_check setlocale 'setlocale(3)' '#define HAVE_SETLOCALE' << \!
1821 #include <locale.h>
1822 int main(void){
1823 setlocale(LC_ALL, "");
1824 return 0;
1827 [ -n "${have_setlocale}" ] && OPT_LOCALES=1
1829 OPT_MULTIBYTE_CHARSETS=0
1830 OPT_WIDE_GLYPHS=0
1831 OPT_TERMINAL_CHARSET=0
1832 if [ -n "${have_setlocale}" ]; then
1833 link_check c90amend1 'ISO/IEC 9899:1990/Amendment 1:1995' \
1834 '#define HAVE_C90AMEND1' << \!
1835 #include <limits.h>
1836 #include <stdlib.h>
1837 #include <wchar.h>
1838 #include <wctype.h>
1839 int main(void){
1840 char mbb[MB_LEN_MAX + 1];
1841 wchar_t wc;
1843 iswprint(L'c');
1844 towupper(L'c');
1845 mbtowc(&wc, "x", 1);
1846 mbrtowc(&wc, "x", 1, NULL);
1847 wctomb(mbb, wc);
1848 return (mblen("\0", 1) == 0);
1851 [ -n "${have_c90amend1}" ] && OPT_MULTIBYTE_CHARSETS=1
1853 if [ -n "${have_c90amend1}" ]; then
1854 link_check wcwidth 'wcwidth(3)' '#define HAVE_WCWIDTH' << \!
1855 #include <wchar.h>
1856 int main(void){
1857 wcwidth(L'c');
1858 return 0;
1861 [ -n "${have_wcwidth}" ] && OPT_WIDE_GLYPHS=1
1864 link_check nl_langinfo 'nl_langinfo(3)' '#define HAVE_NL_LANGINFO' << \!
1865 #include <langinfo.h>
1866 #include <stdlib.h>
1867 int main(void){
1868 nl_langinfo(DAY_1);
1869 return (nl_langinfo(CODESET) == NULL);
1872 [ -n "${have_nl_langinfo}" ] && OPT_TERMINAL_CHARSET=1
1873 fi # have_setlocale
1875 link_check fnmatch 'fnmatch(3)' '#define HAVE_FNMATCH' << \!
1876 #include <fnmatch.h>
1877 int main(void){
1878 return (fnmatch("*", ".", FNM_PATHNAME | FNM_PERIOD) == FNM_NOMATCH);
1882 link_check dirent_d_type 'struct dirent.d_type' '#define HAVE_DIRENT_TYPE' << \!
1883 #include <dirent.h>
1884 int main(void){
1885 struct dirent de;
1886 return !(de.d_type == DT_UNKNOWN ||
1887 de.d_type == DT_DIR || de.d_type == DT_LNK);
1891 ## optional and selectable
1893 if feat_yes ICONV; then
1894 ${cat} > ${tmp2}.c << \!
1895 #include <stdio.h> /* For C89 NULL */
1896 #include <iconv.h>
1897 int main(void){
1898 iconv_t id;
1900 id = iconv_open("foo", "bar");
1901 iconv(id, NULL, NULL, NULL, NULL);
1902 iconv_close(id);
1903 return 0;
1906 < ${tmp2}.c link_check iconv 'iconv(3) functionality' \
1907 '#define HAVE_ICONV' ||
1908 < ${tmp2}.c link_check iconv 'iconv(3) functionality (via -liconv)' \
1909 '#define HAVE_ICONV' '-liconv' ||
1910 feat_bail_required ICONV
1911 else
1912 echo '/* OPT_ICONV=0 */' >> ${h}
1913 fi # feat_yes ICONV
1915 if feat_yes SOCKETS || feat_yes SPAM_SPAMD; then
1916 ${cat} > ${tmp2}.c << \!
1917 #include <sys/types.h>
1918 #include <sys/socket.h>
1919 #include <sys/un.h>
1920 # include <errno.h>
1921 int main(void){
1922 struct sockaddr_un soun;
1924 if(socket(AF_UNIX, SOCK_STREAM, 0) == -1 && errno == ENOSYS)
1925 return 1;
1926 if(connect(0, (struct sockaddr*)&soun, 0) == -1 && errno == ENOSYS)
1927 return 1;
1928 if(shutdown(0, SHUT_RD | SHUT_WR | SHUT_RDWR) == -1 && errno == ENOSYS)
1929 return 1;
1930 return 0;
1934 < ${tmp2}.c run_check af_unix 'AF_UNIX sockets' \
1935 '#define HAVE_UNIX_SOCKETS' ||
1936 < ${tmp2}.c run_check af_unix 'AF_UNIX sockets (via -lnsl)' \
1937 '#define HAVE_UNIX_SOCKETS' '-lnsl' ||
1938 < ${tmp2}.c run_check af_unix 'AF_UNIX sockets (via -lsocket -lnsl)' \
1939 '#define HAVE_UNIX_SOCKETS' '-lsocket -lnsl'
1942 if feat_yes SOCKETS; then
1943 ${cat} > ${tmp2}.c << \!
1944 #include <sys/types.h>
1945 #include <sys/socket.h>
1946 #include <netinet/in.h>
1947 # include <errno.h>
1948 int main(void){
1949 struct sockaddr s;
1951 if(socket(AF_INET, SOCK_STREAM, 0) == -1 && errno == ENOSYS)
1952 return 1;
1953 if(connect(0, &s, 0) == -1 && errno == ENOSYS)
1954 return 1;
1955 return 0;
1959 < ${tmp2}.c run_check sockets 'sockets' \
1960 '#define HAVE_SOCKETS' ||
1961 < ${tmp2}.c run_check sockets 'sockets (via -lnsl)' \
1962 '#define HAVE_SOCKETS' '-lnsl' ||
1963 < ${tmp2}.c run_check sockets 'sockets (via -lsocket -lnsl)' \
1964 '#define HAVE_SOCKETS' '-lsocket -lnsl' ||
1965 feat_bail_required SOCKETS
1966 else
1967 echo '/* OPT_SOCKETS=0 */' >> ${h}
1968 fi # feat_yes SOCKETS
1970 if feat_yes SOCKETS; then
1971 link_check getaddrinfo 'getaddrinfo(3)' \
1972 '#define HAVE_GETADDRINFO' << \!
1973 #include <sys/types.h>
1974 #include <sys/socket.h>
1975 #include <stdio.h>
1976 #include <netdb.h>
1977 int main(void){
1978 struct addrinfo a, *ap;
1979 int lrv;
1981 switch((lrv = getaddrinfo("foo", "0", &a, &ap))){
1982 case EAI_NONAME:
1983 case EAI_SERVICE:
1984 default:
1985 fprintf(stderr, "%s\n", gai_strerror(lrv));
1986 case 0:
1987 break;
1989 return 0;
1994 if feat_yes SOCKETS && [ -z "${have_getaddrinfo}" ]; then
1995 compile_check arpa_inet_h '<arpa/inet.h>' \
1996 '#define HAVE_ARPA_INET_H' << \!
1997 #include <sys/types.h>
1998 #include <sys/socket.h>
1999 #include <netdb.h>
2000 #include <netinet/in.h>
2001 #include <arpa/inet.h>
2004 ${cat} > ${tmp2}.c << \!
2005 #include <sys/types.h>
2006 #include <sys/socket.h>
2007 #include <stdio.h>
2008 #include <string.h>
2009 #include <netdb.h>
2010 #include <netinet/in.h>
2011 #ifdef HAVE_ARPA_INET_H
2012 #include <arpa/inet.h>
2013 #endif
2014 int main(void){
2015 struct sockaddr_in servaddr;
2016 unsigned short portno;
2017 struct servent *ep;
2018 struct hostent *hp;
2019 struct in_addr **pptr;
2021 portno = 0;
2022 if((ep = getservbyname("POPPY-PORT", "tcp")) != NULL)
2023 portno = (unsigned short)ep->s_port;
2025 if((hp = gethostbyname("POPPY-HOST")) != NULL){
2026 pptr = (struct in_addr**)hp->h_addr_list;
2027 if(hp->h_addrtype != AF_INET)
2028 fprintf(stderr, "au\n");
2029 }else{
2030 switch(h_errno){
2031 case HOST_NOT_FOUND:
2032 case TRY_AGAIN:
2033 case NO_RECOVERY:
2034 case NO_DATA:
2035 break;
2036 default:
2037 fprintf(stderr, "au\n");
2038 break;
2042 memset(&servaddr, 0, sizeof servaddr);
2043 servaddr.sin_family = AF_INET;
2044 servaddr.sin_port = htons(portno);
2045 memcpy(&servaddr.sin_addr, *pptr, sizeof(struct in_addr));
2046 fprintf(stderr, "Would connect to %s:%d ...\n",
2047 inet_ntoa(**pptr), (int)portno);
2048 return 0;
2052 < ${tmp2}.c link_check gethostbyname 'get(serv|host)byname(3)' ||
2053 < ${tmp2}.c link_check gethostbyname \
2054 'get(serv|host)byname(3) (via -nsl)' '' '-lnsl' ||
2055 < ${tmp2}.c link_check gethostbyname \
2056 'get(serv|host)byname(3) (via -lsocket -nsl)' \
2057 '' '-lsocket -lnsl' ||
2058 feat_bail_required SOCKETS
2061 feat_yes SOCKETS &&
2062 run_check setsockopt 'setsockopt(2)' '#define HAVE_SETSOCKOPT' << \!
2063 #include <sys/socket.h>
2064 #include <stdlib.h>
2065 # include <errno.h>
2066 int main(void){
2067 int sockfd = 3;
2069 if(setsockopt(sockfd, SOL_SOCKET, SO_KEEPALIVE, NULL, 0) == -1 &&
2070 errno == ENOSYS)
2071 return 1;
2072 return 0;
2076 feat_yes SOCKETS && [ -n "${have_setsockopt}" ] &&
2077 link_check so_sndtimeo 'SO_SNDTIMEO' '#define HAVE_SO_SNDTIMEO' << \!
2078 #include <sys/socket.h>
2079 #include <stdlib.h>
2080 int main(void){
2081 struct timeval tv;
2082 int sockfd = 3;
2084 tv.tv_sec = 42;
2085 tv.tv_usec = 21;
2086 setsockopt(sockfd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof tv);
2087 setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof tv);
2088 return 0;
2092 feat_yes SOCKETS && [ -n "${have_setsockopt}" ] &&
2093 link_check so_linger 'SO_LINGER' '#define HAVE_SO_LINGER' << \!
2094 #include <sys/socket.h>
2095 #include <stdlib.h>
2096 int main(void){
2097 struct linger li;
2098 int sockfd = 3;
2100 li.l_onoff = 1;
2101 li.l_linger = 42;
2102 setsockopt(sockfd, SOL_SOCKET, SO_LINGER, &li, sizeof li);
2103 return 0;
2107 if feat_yes SSL; then # {{{
2108 # {{{ LibreSSL decided to define OPENSSL_VERSION_NUMBER with a useless value
2109 # instead of keeping it at the one that corresponds to the OpenSSL at fork
2110 # time: we need to test it first in order to get things right
2111 if compile_check _xssl 'TLS/SSL (LibreSSL)' \
2112 '#define HAVE_SSL
2113 #define HAVE_XSSL
2114 #define HAVE_XSSL_RESSL
2115 #define HAVE_XSSL_OPENSSL 0' << \!
2116 #include <openssl/opensslv.h>
2117 #ifdef LIBRESSL_VERSION_NUMBER
2118 #else
2119 # error nope
2120 #endif
2122 then
2123 ossl_v1_1=
2124 # TODO OPENSSL_IS_BORINGSSL, but never tried that one!
2125 elif compile_check _xssl 'TLS/SSL (OpenSSL >= v1.1.0)' \
2126 '#define HAVE_SSL
2127 #define HAVE_XSSL
2128 #define HAVE_XSSL_OPENSSL 0x10100' << \!
2129 #include <openssl/opensslv.h>
2130 #if OPENSSL_VERSION_NUMBER + 0 >= 0x10100000L
2131 #else
2132 # error nope
2133 #endif
2135 then
2136 ossl_v1_1=1
2137 elif compile_check _xssl 'TLS/SSL (OpenSSL)' \
2138 '#define HAVE_SSL
2139 #define HAVE_XSSL
2140 #define HAVE_XSSL_OPENSSL 0x10000' << \!
2141 #include <openssl/opensslv.h>
2142 #ifdef OPENSSL_VERSION_NUMBER
2143 #else
2144 # error nope
2145 #endif
2147 then
2148 ossl_v1_1=
2149 else
2150 feat_bail_required SSL
2151 fi # }}}
2153 if feat_yes SSL; then # {{{
2154 if [ -n "${ossl_v1_1}" ]; then
2155 without_check yes xssl 'TLS/SSL (new style *_client_method(3ssl))' \
2156 '#define n_XSSL_CLIENT_METHOD TLS_client_method' \
2157 '-lssl -lcrypto'
2158 elif link_check xssl 'TLS/SSL (new style *_client_method(3ssl))' \
2159 '#define n_XSSL_CLIENT_METHOD TLS_client_method' \
2160 '-lssl -lcrypto' << \!
2161 #include <openssl/ssl.h>
2162 #include <openssl/err.h>
2163 #include <openssl/x509v3.h>
2164 #include <openssl/x509.h>
2165 #include <openssl/rand.h>
2166 #ifdef OPENSSL_NO_TLS1 /* TODO only deduced from OPENSSL_NO_SSL[23]! */
2167 # error We need TLSv1.
2168 #endif
2169 int main(void){
2170 SSL_CTX *ctx = SSL_CTX_new(TLS_client_method());
2172 SSL_CTX_free(ctx);
2173 PEM_read_PrivateKey(0, 0, 0, 0);
2174 return 0;
2177 then
2179 elif link_check xssl 'TLS/SSL (old style *_client_method(3ssl))' \
2180 '#define n_XSSL_CLIENT_METHOD SSLv23_client_method' \
2181 '-lssl -lcrypto' << \!
2182 #include <openssl/ssl.h>
2183 #include <openssl/err.h>
2184 #include <openssl/x509v3.h>
2185 #include <openssl/x509.h>
2186 #include <openssl/rand.h>
2187 #if defined OPENSSL_NO_SSL3 &&\
2188 defined OPENSSL_NO_TLS1 /* TODO only deduced from OPENSSL_NO_SSL[23]! */
2189 # error We need one of SSLv3 and TLSv1.
2190 #endif
2191 int main(void){
2192 SSL_CTX *ctx = SSL_CTX_new(SSLv23_client_method());
2194 SSL_CTX_free(ctx);
2195 PEM_read_PrivateKey(0, 0, 0, 0);
2196 return 0;
2199 then
2201 else
2202 feat_bail_required SSL
2204 fi # }}}
2206 if feat_yes SSL; then # {{{
2207 if [ -n "${ossl_v1_1}" ]; then
2208 without_check yes xssl_stack_of 'TLS/SSL STACK_OF()' \
2209 '#define HAVE_XSSL_STACK_OF'
2210 elif compile_check xssl_stack_of 'TLS/SSL STACK_OF()' \
2211 '#define HAVE_XSSL_STACK_OF' << \!
2212 #include <stdio.h> /* For C89 NULL */
2213 #include <openssl/ssl.h>
2214 #include <openssl/err.h>
2215 #include <openssl/x509v3.h>
2216 #include <openssl/x509.h>
2217 #include <openssl/rand.h>
2218 int main(void){
2219 STACK_OF(GENERAL_NAME) *gens = NULL;
2221 printf("%p", gens); /* to use it */
2222 return 0;
2225 then
2229 if [ -n "${ossl_v1_1}" ]; then
2230 without_check yes xssl_conf 'TLS/SSL OpenSSL_modules_load_file()' \
2231 '#define HAVE_XSSL_CONFIG'
2232 elif link_check xssl_conf 'TLS/SSL OpenSSL_modules_load_file() support' \
2233 '#define HAVE_XSSL_CONFIG' << \!
2234 #include <stdio.h> /* For C89 NULL */
2235 #include <openssl/conf.h>
2236 int main(void){
2237 CONF_modules_load_file(NULL, NULL, CONF_MFLAGS_IGNORE_MISSING_FILE);
2238 CONF_modules_free();
2239 return 0;
2242 then
2246 if [ -n "${ossl_v1_1}" ]; then
2247 without_check yes xssl_conf_ctx 'TLS/SSL SSL_CONF_CTX support' \
2248 '#define HAVE_XSSL_CONF_CTX'
2249 elif link_check xssl_conf_ctx 'TLS/SSL SSL_CONF_CTX support' \
2250 '#define HAVE_XSSL_CONF_CTX' << \!
2251 #include <openssl/ssl.h>
2252 #include <openssl/err.h>
2253 int main(void){
2254 SSL_CTX *ctx = SSL_CTX_new(n_XSSL_CLIENT_METHOD());
2255 SSL_CONF_CTX *cctx = SSL_CONF_CTX_new();
2257 SSL_CONF_CTX_set_flags(cctx,
2258 SSL_CONF_FLAG_FILE | SSL_CONF_FLAG_CLIENT |
2259 SSL_CONF_FLAG_CERTIFICATE | SSL_CONF_FLAG_SHOW_ERRORS);
2260 SSL_CONF_CTX_set_ssl_ctx(cctx, ctx);
2261 SSL_CONF_cmd(cctx, "Protocol", "ALL");
2262 SSL_CONF_CTX_finish(cctx);
2263 SSL_CONF_CTX_free(cctx);
2264 SSL_CTX_free(ctx);
2265 return 0;
2268 then
2272 if [ -n "${ossl_v1_1}" ]; then
2273 without_check no xssl_rand_egd 'TLS/SSL RAND_egd(3ssl)' \
2274 '#define HAVE_XSSL_RAND_EGD'
2275 elif link_check xssl_rand_egd 'TLS/SSL RAND_egd(3ssl)' \
2276 '#define HAVE_XSSL_RAND_EGD' << \!
2277 #include <openssl/rand.h>
2278 int main(void){
2279 return RAND_egd("some.where") > 0;
2282 then
2286 if feat_yes SSL_ALL_ALGORITHMS; then
2287 if [ -n "${ossl_v1_1}" ]; then
2288 without_check yes ssl_all_algo 'TLS/SSL all-algorithms support' \
2289 '#define HAVE_SSL_ALL_ALGORITHMS'
2290 elif link_check ssl_all_algo 'TLS/SSL all-algorithms support' \
2291 '#define HAVE_SSL_ALL_ALGORITHMS' << \!
2292 #include <openssl/evp.h>
2293 int main(void){
2294 OpenSSL_add_all_algorithms();
2295 EVP_get_cipherbyname("two cents i never exist");
2296 EVP_cleanup();
2297 return 0;
2300 then
2302 else
2303 feat_bail_required SSL_ALL_ALGORITHMS
2306 fi # feat_yes SSL }}}
2308 if feat_yes SSL && feat_yes MD5 && feat_no NOEXTMD5; then # {{{
2309 run_check ssl_md5 'MD5 digest in the used crypto library' \
2310 '#define HAVE_XSSL_MD5' << \!
2311 #include <stdlib.h>
2312 #include <string.h>
2313 #include <openssl/md5.h>
2314 int main(void){
2315 char const dat[] = "abrakadabrafidibus";
2316 char dig[16], hex[16 * 2];
2317 MD5_CTX ctx;
2318 size_t i, j;
2320 memset(dig, 0, sizeof(dig));
2321 memset(hex, 0, sizeof(hex));
2322 MD5_Init(&ctx);
2323 MD5_Update(&ctx, dat, sizeof(dat) - 1);
2324 MD5_Final(dig, &ctx);
2326 #define hexchar(n) ((n) > 9 ? (n) - 10 + 'a' : (n) + '0')
2327 for(i = 0; i < sizeof(hex) / 2; i++){
2328 j = i << 1;
2329 hex[j] = hexchar((dig[i] & 0xf0) >> 4);
2330 hex[++j] = hexchar(dig[i] & 0x0f);
2332 return !!memcmp("6d7d0a3d949da2e96f2aa010f65d8326", hex, sizeof(hex));
2335 fi # }}}
2336 else
2337 echo '/* OPT_SSL=0 */' >> ${h}
2338 fi # }}} feat_yes SSL
2340 if [ "${have_xssl}" = yes ]; then
2341 OPT_SMIME=1
2342 else
2343 OPT_SMIME=0
2345 feat_def SMIME
2347 feat_def SMTP
2348 feat_def POP3
2349 feat_def IMAP
2351 if feat_yes GSSAPI; then
2352 ${cat} > ${tmp2}.c << \!
2353 #include <gssapi/gssapi.h>
2354 int main(void){
2355 gss_import_name(0, 0, GSS_C_NT_HOSTBASED_SERVICE, 0);
2356 gss_init_sec_context(0,0,0,0,0,0,0,0,0,0,0,0,0);
2357 return 0;
2360 ${sed} -e '1s/gssapi\///' < ${tmp2}.c > ${tmp3}.c
2362 if command -v krb5-config >/dev/null 2>&1; then
2363 i=`command -v krb5-config`
2364 GSS_LIBS="`CFLAGS= ${i} --libs gssapi`"
2365 GSS_INCS="`CFLAGS= ${i} --cflags`"
2366 i='GSS-API via krb5-config(1)'
2367 else
2368 GSS_LIBS='-lgssapi'
2369 GSS_INCS=
2370 i='GSS-API in gssapi/gssapi.h, libgssapi'
2372 if < ${tmp2}.c link_check gss \
2373 "${i}" '#define HAVE_GSSAPI' "${GSS_LIBS}" "${GSS_INCS}" ||\
2374 < ${tmp3}.c link_check gss \
2375 'GSS-API in gssapi.h, libgssapi' \
2376 '#define HAVE_GSSAPI
2377 #define GSSAPI_REG_INCLUDE' \
2378 '-lgssapi' ||\
2379 < ${tmp2}.c link_check gss 'GSS-API in libgssapi_krb5' \
2380 '#define HAVE_GSSAPI' \
2381 '-lgssapi_krb5' ||\
2382 < ${tmp3}.c link_check gss \
2383 'GSS-API in libgssapi, OpenBSD-style (pre 5.3)' \
2384 '#define HAVE_GSSAPI
2385 #define GSS_REG_INCLUDE' \
2386 '-lgssapi -lkrb5 -lcrypto' \
2387 '-I/usr/include/kerberosV' ||\
2388 < ${tmp2}.c link_check gss 'GSS-API in libgss' \
2389 '#define HAVE_GSSAPI' \
2390 '-lgss' ||\
2391 link_check gss 'GSS-API in libgssapi_krb5, old-style' \
2392 '#define HAVE_GSSAPI
2393 #define GSSAPI_OLD_STYLE' \
2394 '-lgssapi_krb5' << \!
2395 #include <gssapi/gssapi.h>
2396 #include <gssapi/gssapi_generic.h>
2397 int main(void){
2398 gss_import_name(0, 0, gss_nt_service_name, 0);
2399 gss_init_sec_context(0,0,0,0,0,0,0,0,0,0,0,0,0);
2400 return 0;
2403 then
2405 else
2406 feat_bail_required GSSAPI
2408 else
2409 echo '/* OPT_GSSAPI=0 */' >> ${h}
2410 fi # feat_yes GSSAPI
2412 feat_def NETRC
2413 feat_def AGENT
2415 if feat_yes IDNA; then
2416 if link_check idna 'GNU Libidn' '#define HAVE_IDNA HAVE_IDNA_LIBIDNA' \
2417 '-lidn' << \!
2418 #include <idna.h>
2419 #include <idn-free.h>
2420 #include <stringprep.h>
2421 int main(void){
2422 char *utf8, *idna_ascii, *idna_utf8;
2424 utf8 = stringprep_locale_to_utf8("does.this.work");
2425 if (idna_to_ascii_8z(utf8, &idna_ascii, IDNA_USE_STD3_ASCII_RULES)
2426 != IDNA_SUCCESS)
2427 return 1;
2428 idn_free(idna_ascii);
2429 /* (Rather link check only here) */
2430 idna_utf8 = stringprep_convert(idna_ascii, "UTF-8", "de_DE");
2431 return 0;
2434 then
2436 elif link_check idna 'idnkit' '#define HAVE_IDNA HAVE_IDNA_IDNKIT' \
2437 '-lidnkit' << \!
2438 #include <stdio.h>
2439 #include <idn/api.h>
2440 #include <idn/result.h>
2441 int main(void){
2442 idn_result_t r;
2443 char ace_name[256];
2444 char local_name[256];
2446 r = idn_encodename(IDN_ENCODE_APP, "does.this.work", ace_name,
2447 sizeof(ace_name));
2448 if (r != idn_success) {
2449 fprintf(stderr, "idn_encodename failed: %s\n", idn_result_tostring(r));
2450 return 1;
2452 r = idn_decodename(IDN_DECODE_APP, ace_name, local_name, sizeof(local_name));
2453 if (r != idn_success) {
2454 fprintf(stderr, "idn_decodename failed: %s\n", idn_result_tostring(r));
2455 return 1;
2457 return 0;
2460 then
2462 else
2463 feat_bail_required IDNA
2466 if [ -n "${have_idna}" ]; then
2467 echo '#define HAVE_IDNA_LIBIDNA 0' >> ${h}
2468 echo '#define HAVE_IDNA_IDNKIT 1' >> ${h}
2470 else
2471 echo '/* OPT_IDNA=0 */' >> ${h}
2474 feat_def IMAP_SEARCH
2476 if feat_yes REGEX; then
2477 if link_check regex 'regular expressions' '#define HAVE_REGEX' << \!
2478 #include <regex.h>
2479 #include <stdlib.h>
2480 int main(void){
2481 size_t xret;
2482 int status;
2483 regex_t re;
2485 status = regcomp(&re, ".*bsd", REG_EXTENDED | REG_ICASE | REG_NOSUB);
2486 xret = regerror(status, &re, NULL, 0);
2487 status = regexec(&re, "plan9", 0,NULL, 0);
2488 regfree(&re);
2489 return !(status == REG_NOMATCH);
2492 then
2494 else
2495 feat_bail_required REGEX
2497 else
2498 echo '/* OPT_REGEX=0 */' >> ${h}
2501 if feat_yes MLE && [ -n "${have_c90amend1}" ]; then
2502 have_mle=1
2503 echo '#define HAVE_MLE' >> ${h}
2504 else
2505 feat_bail_required MLE
2506 echo '/* OPT_MLE=0 */' >> ${h}
2509 # Generic have-a-line-editor switch for those who need it below
2510 if [ -n "${have_mle}" ]; then
2511 have_cle=1
2514 if [ -n "${have_cle}" ] && feat_yes HISTORY; then
2515 echo '#define HAVE_HISTORY' >> ${h}
2516 else
2517 echo '/* OPT_HISTORY=0 */' >> ${h}
2520 if [ -n "${have_mle}" ] && feat_yes KEY_BINDINGS; then
2521 echo '#define HAVE_KEY_BINDINGS' >> ${h}
2522 else
2523 echo '/* OPT_KEY_BINDINGS=0 */' >> ${h}
2526 if feat_yes TERMCAP; then
2527 __termcaplib() {
2528 link_check termcap "termcap(5) (via ${4})" \
2529 "#define HAVE_TERMCAP${3}" "${1}" << _EOT
2530 #include <stdio.h>
2531 #include <stdlib.h>
2532 ${2}
2533 #include <term.h>
2534 #define UNCONST(P) ((void*)(unsigned long)(void const*)(P))
2535 static int my_putc(int c){return putchar(c);}
2536 int main(void){
2537 char buf[1024+512], cmdbuf[2048], *cpb, *r1;
2538 int r2 = OK, r3 = ERR;
2540 tgetent(buf, getenv("TERM"));
2541 cpb = cmdbuf;
2542 r1 = tgetstr(UNCONST("cm"), &cpb);
2543 tgoto(r1, 1, 1);
2544 r2 = tgetnum(UNCONST("Co"));
2545 r3 = tgetflag(UNCONST("ut"));
2546 tputs("cr", 1, &my_putc);
2547 return (r1 == NULL || r2 == -1 || r3 == 0);
2549 _EOT
2552 __terminfolib() {
2553 link_check terminfo "terminfo(5) (via ${2})" \
2554 '#define HAVE_TERMCAP
2555 #define HAVE_TERMCAP_CURSES
2556 #define HAVE_TERMINFO' "${1}" << _EOT
2557 #include <stdio.h>
2558 #include <curses.h>
2559 #include <term.h>
2560 #define UNCONST(P) ((void*)(unsigned long)(void const*)(P))
2561 static int my_putc(int c){return putchar(c);}
2562 int main(void){
2563 int er, r0, r1, r2;
2564 char *r3, *tp;
2566 er = OK;
2567 r0 = setupterm(NULL, 1, &er);
2568 r1 = tigetflag(UNCONST("bce"));
2569 r2 = tigetnum(UNCONST("colors"));
2570 r3 = tigetstr(UNCONST("cr"));
2571 tp = tparm(r3, NULL, NULL, 0,0,0,0,0,0,0);
2572 tputs(tp, 1, &my_putc);
2573 return (r0 == ERR || r1 == -1 || r2 == -2 || r2 == -1 ||
2574 r3 == (char*)-1 || r3 == NULL);
2576 _EOT
2579 if feat_yes TERMCAP_VIA_TERMINFO; then
2580 __terminfolib -ltinfo -ltinfo ||
2581 __terminfolib -lcurses -lcurses ||
2582 __terminfolib -lcursesw -lcursesw ||
2583 feat_bail_required TERMCAP_VIA_TERMINFO
2586 if [ -z "${have_terminfo}" ]; then
2587 __termcaplib -ltermcap '' '' '-ltermcap' ||
2588 __termcaplib -ltermcap '#include <curses.h>' '
2589 #define HAVE_TERMCAP_CURSES' \
2590 'curses.h / -ltermcap' ||
2591 __termcaplib -lcurses '#include <curses.h>' '
2592 #define HAVE_TERMCAP_CURSES' \
2593 'curses.h / -lcurses' ||
2594 __termcaplib -lcursesw '#include <curses.h>' '
2595 #define HAVE_TERMCAP_CURSES' \
2596 'curses.h / -lcursesw' ||
2597 feat_bail_required TERMCAP
2599 if [ -n "${have_termcap}" ]; then
2600 run_check tgetent_null \
2601 "tgetent(3) of termcap(5) takes NULL buffer" \
2602 "#define HAVE_TGETENT_NULL_BUF" << _EOT
2603 #include <stdio.h> /* For C89 NULL */
2604 #include <stdlib.h>
2605 #ifdef HAVE_TERMCAP_CURSES
2606 # include <curses.h>
2607 #endif
2608 #include <term.h>
2609 int main(void){
2610 tgetent(NULL, getenv("TERM"));
2611 return 0;
2613 _EOT
2616 else
2617 echo '/* OPT_TERMCAP=0 */' >> ${h}
2618 echo '/* OPT_TERMCAP_VIA_TERMINFO=0 */' >> ${h}
2621 if feat_def SPAM_SPAMC; then
2622 if command -v spamc >/dev/null 2>&1; then
2623 echo "#define SPAM_SPAMC_PATH \"`command -v spamc`\"" >> ${h}
2627 if feat_yes SPAM_SPAMD && [ -n "${have_af_unix}" ]; then
2628 echo '#define HAVE_SPAM_SPAMD' >> ${h}
2629 else
2630 feat_bail_required SPAM_SPAMD
2631 echo '/* OPT_SPAM_SPAMD=0 */' >> ${h}
2634 feat_def SPAM_FILTER
2636 if feat_yes SPAM_SPAMC || feat_yes SPAM_SPAMD || feat_yes SPAM_FILTER; then
2637 echo '#define HAVE_SPAM' >> ${h}
2638 else
2639 echo '/* HAVE_SPAM */' >> ${h}
2642 if feat_yes QUOTE_FOLD &&\
2643 [ -n "${have_c90amend1}" ] && [ -n "${have_wcwidth}" ]; then
2644 echo '#define HAVE_QUOTE_FOLD' >> ${h}
2645 else
2646 feat_bail_required QUOTE_FOLD
2647 echo '/* OPT_QUOTE_FOLD=0 */' >> ${h}
2650 feat_def FILTER_HTML_TAGSOUP
2651 feat_def COLOUR
2652 feat_def DOTLOCK
2653 feat_def MD5
2654 feat_def NOMEMDBG
2656 ## Summarizing
2658 ${rm} -f ${tmp}
2659 squeeze_em ${inc} ${tmp}
2660 ${mv} ${tmp} ${inc}
2661 squeeze_em ${lib} ${tmp}
2662 ${mv} ${tmp} ${lib}
2664 # mk-config.h
2665 ${mv} ${h} ${tmp}
2666 printf '#ifndef n_MK_CONFIG_H\n# define n_MK_CONFIG_H 1\n' > ${h}
2667 ${cat} ${tmp} >> ${h}
2668 ${rm} -f ${tmp}
2669 printf '\n' >> ${h}
2671 # Create the string that is used by *features* and `version'.
2672 # Take this nice opportunity and generate a visual listing of included and
2673 # non-included features for the person who runs the configuration
2674 msg '\nThe following features are included (+) or not (-):'
2675 set -- ${OPTIONS_DETECT} ${OPTIONS} ${OPTIONS_XTRA}
2676 printf '/* The "feature string" */\n' >> ${h}
2677 # Because + is expanded by *folder* if first in "echo $features", put something
2678 printf '#define VAL_FEATURES_CNT '${#}'\n#define VAL_FEATURES "#' >> ${h}
2679 sep=
2680 for opt
2682 sdoc=`option_doc_of ${opt}`
2683 [ -z "${sdoc}" ] && continue
2684 sopt="`echo ${opt} | ${tr} '[A-Z]_' '[a-z]-'`"
2685 feat_yes ${opt} && sign=+ || sign=-
2686 printf -- "${sep}${sign}${sopt}" >> ${h}
2687 sep=','
2688 msg " %s %s: %s" ${sign} ${sopt} "${sdoc}"
2689 done
2690 # TODO instead of using sh+tr+awk+printf, use awk, drop option_doc_of, inc here
2691 #exec 5>&1 >>${h}
2692 #${awk} -v opts="${OPTIONS_DETECT} ${OPTIONS} ${OPTIONS_XTRA}" \
2693 # -v xopts="${XOPTIONS_DETECT} ${XOPTIONS} ${XOPTIONS_XTRA}" \
2694 printf '"\n' >> ${h}
2696 # Create the real mk-config.mk
2697 # Note we cannout use explicit ./ filename prefix for source and object
2698 # pathnames because of a bug in bmake(1)
2699 ${rm} -rf ${tmp0}.* ${tmp0}*
2700 srclist= objlist=
2701 if feat_no AMALGAMATION; then
2702 for i in `printf '%s\n' "${SRCDIR}"*.c | ${sort}`; do
2703 i=`basename "${i}" .c`
2704 if [ "${i}" = privsep ]; then
2705 continue
2707 objlist="${objlist} ${i}.o"
2708 srclist="${srclist} \$(SRCDIR)${i}.c"
2709 printf '%s: %s\n\t$(ECHO_CC)$(CC) $(CFLAGS) $(INCS) -c %s\n' \
2710 "${i}.o" "\$(SRCDIR)${i}.c" "\$(SRCDIR)${i}.c" >> ${mk}
2711 done
2712 printf '\nAMALGAM_TARGET =\nAMALGAM_DEP =\n' >> ${mk}
2713 else
2714 printf '%s:\n\t$(ECHO_CC)$(CC) $(CFLAGS) $(INCS) -c $(SRCDIR)%s\n' \
2715 "main.o" "main.c" >> ${mk}
2716 srclist=main.c objlist=main.o
2717 printf '\nAMALGAM_TARGET = main.o\nAMALGAM_DEP = ' >> ${mk}
2719 printf '\n/* HAVE_AMALGAMATION: include sources */\n' >> ${h}
2720 printf '#elif n_MK_CONFIG_H + 0 == 1\n' >> ${h}
2721 printf '# undef n_MK_CONFIG_H\n' >> ${h}
2722 printf '# define n_MK_CONFIG_H 2\n' >> ${h}
2723 for i in `printf '%s\n' "${SRCDIR}"*.c | ${sort}`; do
2724 i=`basename "${i}"`
2725 if [ "${i}" = main.c ] ||
2726 [ "${i}" = privsep.c ]; then
2727 continue
2729 printf '$(SRCDIR)%s ' "${i}" >> ${mk}
2730 printf '# include "%s%s"\n' "${SRCDIR}" "${i}" >> ${h}
2731 done
2732 echo >> ${mk}
2734 printf 'OBJ_SRC = %s\nOBJ = %s\n' "${srclist}" "${objlist}" >> "${mk}"
2736 printf '#endif /* n_MK_CONFIG_H */\n' >> ${h}
2738 echo "LIBS = `${cat} ${lib}`" >> ${mk}
2739 echo "INCS = `${cat} ${inc}`" >> ${mk}
2740 echo >> ${mk}
2741 ${cat} "${SRCDIR}"make-config.in >> ${mk}
2743 ## Finished!
2745 msg '\nSetup:'
2746 msg ' . System-wide resource file: %s/%s' "${VAL_SYSCONFDIR}" "${VAL_SYSCONFRC}"
2747 msg ' . bindir: %s' "${VAL_BINDIR}"
2748 if feat_yes DOTLOCK; then
2749 msg ' . libexecdir: %s' "${VAL_LIBEXECDIR}"
2751 msg ' . mandir: %s' "${VAL_MANDIR}"
2752 msg ' . M(ail)T(ransfer)A(gent): %s (argv0 %s)' "${VAL_MTA}" "${VAL_MTA_ARGV0}"
2753 msg ' . $MAIL spool directory: %s' "${VAL_MAIL}"
2754 msg ''
2756 if [ -n "${have_fnmatch}" ] && [ -n "${have_fchdir}" ]; then
2757 exit 0
2759 msg 'Remarks:'
2760 if [ -z "${have_fnmatch}" ]; then
2761 msg ' . The function fnmatch(3) could not be found.'
2762 msg ' Filename patterns like wildcard are not supported on your system'
2764 if [ -z "${have_fchdir}" ]; then
2765 msg ' . The function fchdir(2) could not be found.'
2766 msg ' We will use chdir(2) instead.'
2767 msg ' This is a problem only if the current working directory is changed'
2768 msg ' while this program is inside of it'
2770 msg ''
2772 # s-it-mode