n_child_wait(): !n_SIGSUSPEND_NOT_WAITPID: be super safe
[s-mailx.git] / make-config.sh
blobef0521b354e9a6ac072893d2e3652a6d87d351da
1 #!/bin/sh -
2 #@ Please see INSTALL and make.rc instead.
4 LC_ALL=C
5 export LC_ALL
7 # For heaven's sake auto-redirect on SunOS/Solaris
8 if [ "x${SHELL}" = x ] || [ "${SHELL}" = /bin/sh ] && \
9 [ -f /usr/xpg4/bin/sh ] && [ -x /usr/xpg4/bin/sh ]; then
10 SHELL=/usr/xpg4/bin/sh
11 export SHELL
12 exec /usr/xpg4/bin/sh "${0}" "${@}"
14 [ -n "${SHELL}" ] || SHELL=/bin/sh
15 export SHELL
17 # The feature set, to be kept in sync with make.rc
18 # If no documentation given, the option is used as such; if doc is a hyphen,
19 # entry is suppressed when configuration overview is printed, and also in the
20 # *features* string: most likely for obsolete features etc.
21 XOPTIONS="\
22 ICONV='Character set conversion using iconv(3)' \
23 SOCKETS='Network support' \
24 SSL='SSL/TLS (OpenSSL / LibreSSL)' \
25 SSL_ALL_ALGORITHMS='Support of all digest and cipher algorithms' \
26 SMTP='Simple Mail Transfer Protocol client' \
27 POP3='Post Office Protocol Version 3 client' \
28 IMAP='IMAP v4r1 client' \
29 GSSAPI='Generic Security Service authentication' \
30 NETRC='.netrc file support' \
31 AGENT='-' \
32 MD5='MD5 message digest (APOP, CRAM-MD5)' \
33 IDNA='Internationalized Domain Names for Applications (encode only)' \
34 IMAP_SEARCH='IMAP-style search expressions' \
35 REGEX='Regular expressions' \
36 MLE='Mailx Line Editor' \
37 HISTORY='Line editor history management' \
38 KEY_BINDINGS='Configurable key bindings' \
39 TERMCAP='Terminal capability queries (termcap(5))' \
40 TERMCAP_VIA_TERMINFO='Terminal capability queries use terminfo(5)' \
41 ERRORS='Log message ring' \
42 SPAM_SPAMC='Spam management via spamc(1) of spamassassin(1)' \
43 SPAM_SPAMD='-' \
44 SPAM_FILTER='Freely configurable *spam-filter-..*s' \
45 DOCSTRINGS='Command documentation help strings' \
46 UISTRINGS='User interface and error message strings' \
47 QUOTE_FOLD='Extended *quote-fold*ing' \
48 FILTER_HTML_TAGSOUP='Simple built-in HTML-to-text display filter' \
49 COLOUR='Coloured message display' \
50 DOTLOCK='Dotlock files and privilege-separated dotlock program' \
53 # Options which are automatically deduced from host environment, i.e., these
54 # need special treatment all around here to warp from/to OPT_ stuff
55 # setlocale, C90AMEND1, NL_LANGINFO, wcwidth
56 XOPTIONS_DETECT="\
57 LOCALES='Locale support - printable characters etc. depend on environment' \
58 MULTIBYTE_CHARSETS='Multibyte character sets' \
59 TERMINAL_CHARSET='Automatic detection of terminal character set' \
60 WIDE_GLYPHS='Wide glyph support' \
63 # Rather special options, for custom building, or which always exist.
64 # Mostly for generating the visual overview and the *features* string
65 XOPTIONS_XTRA="\
66 MIME='Multipurpose Internet Mail Extensions' \
67 SMIME='S/MIME message signing, verification, en- and decryption' \
68 CROSS_BUILD='Cross-compilation: trust any detected environment' \
69 DEBUG='Debug enabled binary, not for end-users: THANKS!' \
70 DEVEL='Computers do not blunder' \
73 # To avoid too many recompilations we use a two-stage "configuration changed"
74 # detection, the first uses mk-config.lst, which only goes for actual user
75 # config settings etc. the second uses mk-config.h, which thus includes the
76 # things we have truly detected. This does not work well for multiple choice
77 # values of which only one will be really used, so those user wishes may not be
78 # placed in the header, only the really detected one (but that has to!).
79 # Used for grep(1), for portability assume fixed matching only.
80 H_BLACKLIST='-e VAL_RANDOM -e VAL_IDNA'
82 # The problem is that we don't have any tools we can use right now, so
83 # encapsulate stuff in functions which get called in right order later on
85 option_reset() {
86 set -- ${OPTIONS}
87 for i
89 eval OPT_${i}=0
90 done
93 option_maximal() {
94 set -- ${OPTIONS}
95 for i
97 eval OPT_${i}=1
98 done
99 OPT_DOTLOCK=require OPT_ICONV=require OPT_REGEX=require
102 option_setup() {
103 option_parse OPTIONS_DETECT "${XOPTIONS_DETECT}"
104 option_parse OPTIONS "${XOPTIONS}"
105 option_parse OPTIONS_XTRA "${XOPTIONS_XTRA}"
106 OPT_MIME=1
108 # Predefined CONFIG= urations take precedence over anything else
109 if [ -n "${CONFIG}" ]; then
110 option_reset
111 case "${CONFIG}" in
112 [nN][uU][lL][lL])
114 [nN][uU][lL][lL][iI])
115 OPT_ICONV=require
116 OPT_UISTRINGS=1
118 [mM][iI][nN][iI][mM][aA][lL])
119 OPT_DOTLOCK=require OPT_ICONV=require OPT_REGEX=require
120 OPT_COLOUR=1
121 OPT_DOCSTRINGS=1
122 OPT_UISTRINGS=1
123 OPT_ERRORS=1
124 OPT_IDNA=1
125 OPT_MLE=1
126 OPT_HISTORY=1 OPT_KEY_BINDINGS=1
127 OPT_SPAM_FILTER=1
129 [nN][eE][tT][sS][eE][nN][dD])
130 OPT_DOTLOCK=require OPT_ICONV=require OPT_REGEX=require
131 OPT_SOCKETS=require
132 OPT_SSL=require
133 OPT_SMTP=require
134 OPT_GSSAPI=1 OPT_NETRC=1
135 OPT_AGENT=1
136 OPT_COLOUR=1
137 OPT_DOCSTRINGS=1
138 OPT_UISTRINGS=1
139 OPT_ERRORS=1
140 OPT_IDNA=1
141 OPT_MLE=1
142 OPT_HISTORY=1 OPT_KEY_BINDINGS=1
143 OPT_SPAM_FILTER=1
145 [mM][aA][xX][iI][mM][aA][lL])
146 option_maximal
148 [dD][eE][vV][eE][lL])
149 option_maximal
150 OPT_DEVEL=1 OPT_DEBUG=1 OPT_NYD2=1
152 [oO][dD][eE][vV][eE][lL])
153 option_maximal
154 OPT_DEVEL=1
157 echo >&2 "Unknown CONFIG= setting: ${CONFIG}"
158 echo >&2 ' NULL, NULLI, MINIMAL, NETSEND, MAXIMAL'
159 exit 1
161 esac
162 msg_nonl "CONFIG=${CONFIG} ... "
166 # Inter-relationships XXX sort this!
167 option_update() {
168 if feat_no SSL; then
169 OPT_SSL_ALL_ALGORITHMS=0
172 if feat_no SMTP && feat_no POP3 && feat_no IMAP; then
173 OPT_SOCKETS=0
175 if feat_no SOCKETS; then
176 if feat_require SMTP; then
177 msg 'ERROR: need SOCKETS for required feature SMTP'
178 config_exit 13
180 if feat_require POP3; then
181 msg 'ERROR: need SOCKETS for required feature POP3'
182 config_exit 13
184 if feat_require IMAP; then
185 msg 'ERROR: need SOCKETS for required feature IMAP'
186 config_exit 13
188 OPT_SSL=0 OPT_SSL_ALL_ALGORITHMS=0
189 OPT_SMTP=0 OPT_POP3=0 OPT_IMAP=0
190 OPT_GSSAPI=0 OPT_NETRC=0 OPT_AGENT=0
192 if feat_no SMTP && feat_no IMAP; then
193 OPT_GSSAPI=0
196 if feat_no ICONV; then
197 if feat_yes IMAP; then
198 if feat_yes ALWAYS_UNICODE_LOCALE; then
199 msg 'WARN: no ICONV, keeping IMAP due to ALWAYS_UNICODE_LOCALE!'
200 elif feat_require IMAP; then
201 msg 'ERROR: need ICONV for required feature IMAP'
202 config_exit 13
203 else
204 msg 'ERROR: disabling IMAP due to missing ICONV'
205 OPT_IMAP=0
209 if feat_yes IDNA; then
210 if feat_require IDNA; then
211 msg 'ERROR: need ICONV for required feature IDNA'
212 config_exit 13
214 msg 'ERROR: disabling IDNA due to missing ICONV'
215 OPT_IDNA=0
219 if feat_no MLE; then
220 OPT_HISTORY=0 OPT_KEY_BINDINGS=0
223 # If we don't need MD5 leave it alone
224 if feat_no SOCKETS; then
225 OPT_MD5=0
228 if feat_no TERMCAP; then
229 OPT_TERMCAP_VIA_TERMINFO=0
232 if feat_yes DEVEL; then
233 OPT_DEBUG=1
237 rc=./make.rc
238 lst=.obj/mk-config.lst
239 ev=.obj/mk-config.ev
240 h=.obj/mk-config.h h_name=mk-config.h
241 mk=.obj/mk-config.mk
243 newlst=.obj/mk-nconfig.lst
244 newmk=.obj/mk-nconfig.mk
245 oldmk=.obj/mk-oconfig.mk
246 newev=.obj/mk-nconfig.ev
247 newh=.obj/mk-nconfig.h
248 oldh=.obj/mk-oconfig.h
249 tmp0=.obj/___tmp
250 tmp=${tmp0}1$$
251 tmp2=${tmp0}2$$
253 ## -- >8 - << OPTIONS | OS/CC >> - 8< -- ##
255 # Note that potential duplicates in PATH, C_INCLUDE_PATH etc. will be cleaned
256 # via path_check() later on once possible
258 # TODO cc_maxopt is brute simple, we should compile test program and dig real
259 # compiler versions for known compilers, then be more specific
260 [ -n "${cc_maxopt}" ] || cc_maxopt=100
261 #cc_force_no_stackprot=
262 #ld_need_R_flags=
263 #ld_no_bind_now=
264 #ld_rpath_not_runpath=
266 _CFLAGS= _LDFLAGS=
268 os_early_setup() {
269 # We don't "have any utility" (see make.rc)
270 [ -n "${OS}" ] && [ -n "${OSENV}" ] && [ -n "${OSFULLSPEC}" ] ||
271 thecmd_testandset_fail uname uname
273 [ -n "${OS}" ] || OS=`${uname} -s`
274 export OS
276 if [ ${OS} = SunOS ]; then
277 # According to standards(5), this is what we need to do
278 if [ -d /usr/xpg4 ]; then :; else
279 msg 'ERROR: On SunOS / Solaris we need /usr/xpg4 environment! Sorry.'
280 config_exit 1
282 PATH="/usr/xpg4/bin:/usr/ccs/bin:/usr/bin:${PATH}"
283 [ -d /usr/xpg6 ] && PATH="/usr/xpg6/bin:${PATH}"
284 export PATH
288 os_setup() {
289 OS=`echo ${OS} | ${tr} '[A-Z]' '[a-z]'`
290 msg 'Operating system is %s' "${OS}"
292 # OSENV ends up in *build-osenv*
293 # OSFULLSPEC is used to recognize changes (i.e., machine type, updates
294 # etc.), it is not baked into the binary
295 [ -n "${OSENV}" ] || OSENV=`${uname} -sm`
296 [ -n "${OSFULLSPEC}" ] || OSFULLSPEC=`${uname} -a`
298 if [ ${OS} = darwin ]; then
299 msg ' . have special Darwin environmental addons...'
300 LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${DYLD_LIBRARY_PATH}
301 elif [ ${OS} = sunos ]; then
302 msg ' . have special SunOS / Solaris "setup" rules ...'
303 _os_setup_sunos
304 elif [ ${OS} = unixware ]; then
305 if feat_yes AUTOCC && acmd_set CC cc; then
306 msg ' . have special UnixWare environmental rules ...'
307 feat_yes DEBUG && _CFLAGS='-v -Xa -g' || _CFLAGS='-Xa -O'
309 CFLAGS="${_CFLAGS} ${EXTRA_CFLAGS}"
310 LDFLAGS="${_LDFLAGS} ${EXTRA_LDFLAGS}"
311 export CC CFLAGS LDFLAGS
312 OPT_AUTOCC=0 ld_need_R_flags=-R
314 elif [ -n "${VERBOSE}" ]; then
315 msg ' . no special treatment for this system necessary or known'
318 # Sledgehammer: better set _GNU_SOURCE
319 # And in general: oh, boy!
320 OS_DEFINES="${OS_DEFINES}#define _GNU_SOURCE\n"
321 #OS_DEFINES="${OS_DEFINES}#define _POSIX_C_SOURCE 200809L\n"
322 #OS_DEFINES="${OS_DEFINES}#define _XOPEN_SOURCE 700\n"
323 #[ ${OS} = darwin ] && OS_DEFINES="${OS_DEFINES}#define _DARWIN_C_SOURCE\n"
325 # On pkgsrc(7) systems automatically add /usr/pkg/*
326 if [ -d /usr/pkg ] && feat_yes USE_PKGSYS; then
327 msg ' . found pkgsrc(7), merging C_INCLUDE_PATH and LD_LIBRARY_PATH'
328 C_INCLUDE_PATH=/usr/pkg/include:${C_INCLUDE_PATH}
329 LD_LIBRARY_PATH=/usr/pkg/lib:${LD_LIBRARY_PATH}
330 ld_rpath_not_runpath=1
334 _os_setup_sunos() {
335 C_INCLUDE_PATH=/usr/xpg4/include:${C_INCLUDE_PATH}
336 LD_LIBRARY_PATH=/usr/xpg4/lib:${LD_LIBRARY_PATH}
338 # Include packages
339 if [ -d /opt/csw ] && feat_yes USE_PKGSYS; then
340 msg ' . found OpenCSW PKGSYS, merging C_INCLUDE_PATH and LD_LIBRARY_PATH'
341 C_INCLUDE_PATH=/opt/csw/include:${C_INCLUDE_PATH}
342 LD_LIBRARY_PATH=/opt/csw/lib:${LD_LIBRARY_PATH}
343 ld_no_bind_now=1 ld_rpath_not_runpath=1
345 if [ -d /opt/schily ] && feat_yes USE_PKGSYS; then
346 msg ' . found Schily PKGSYS, merging C_INCLUDE_PATH and LD_LIBRARY_PATH'
347 C_INCLUDE_PATH=/opt/schily/include:${C_INCLUDE_PATH}
348 LD_LIBRARY_PATH=/opt/schily/lib:${LD_LIBRARY_PATH}
349 ld_no_bind_now=1 ld_rpath_not_runpath=1
352 OS_DEFINES="${OS_DEFINES}#define __EXTENSIONS__\n"
353 #OS_DEFINES="${OS_DEFINES}#define _POSIX_C_SOURCE 200112L\n"
355 [ -n "${cksum}" ] || cksum=/opt/csw/gnu/cksum
356 if [ -x "${cksum}" ]; then :; else
357 msg 'ERROR: Not an executable program: %s' "${cksum}"
358 msg 'ERROR: We need a CRC-32 cksum(1), as specified in POSIX.'
359 msg 'ERROR: However, we do so only for tests.'
360 msg 'ERROR: If that is ok, set "cksum=/usr/bin/true", then rerun'
361 config_exit 1
364 if feat_yes AUTOCC; then
365 if acmd_set CC cc; then
366 feat_yes DEBUG && _CFLAGS="-v -Xa -g" || _CFLAGS="-Xa -O"
368 CFLAGS="${_CFLAGS} ${EXTRA_CFLAGS}"
369 LDFLAGS="${_LDFLAGS} ${EXTRA_LDFLAGS}"
370 export CC CFLAGS LDFLAGS
371 OPT_AUTOCC=0 ld_need_R_flags=-R
372 else
373 cc_maxopt=2 cc_force_no_stackprot=1
378 # Check out compiler ($CC) and -flags ($CFLAGS)
379 cc_setup() {
380 # Even though it belongs into cc_flags we will try to compile and link
381 # something, so ensure we have a clean state regarding CFLAGS/LDFLAGS or
382 # EXTRA_CFLAGS/EXTRA_LDFLAGS
383 if feat_no AUTOCC; then
384 _cc_default
385 # Ensure those don't do any harm
386 EXTRA_CFLAGS= EXTRA_LDFLAGS=
387 export EXTRA_CFLAGS EXTRA_LDFLAGS
388 return
389 else
390 CFLAGS= LDFLAGS=
391 export CFLAGS LDFLAGS
394 [ -n "${CC}" ] && { _cc_default; return; }
396 msg_nonl 'Searching for a usable C compiler .. $CC='
397 if acmd_set CC clang || acmd_set CC gcc ||
398 acmd_set CC tcc || acmd_set CC pcc ||
399 acmd_set CC c89 || acmd_set CC c99; then
401 else
402 msg 'boing booom tschak'
403 msg 'ERROR: I cannot find a compiler!'
404 msg ' Neither of clang(1), gcc(1), tcc(1), pcc(1), c89(1) and c99(1).'
405 msg ' Please set ${CC} environment variable, maybe ${CFLAGS}, rerun.'
406 config_exit 1
408 msg '%s' "${CC}"
409 export CC
412 _cc_default() {
413 if [ -z "${CC}" ]; then
414 msg 'To go on like you have chosen, please set $CC, rerun.'
415 config_exit 1
418 if [ -z "${VERBOSE}" ] && [ -f ${lst} ] && feat_no DEBUG; then
420 else
421 msg 'Using C compiler ${CC}=%s' "${CC}"
425 cc_flags() {
426 if feat_yes AUTOCC; then
427 if [ -f ${lst} ] && feat_no DEBUG && [ -z "${VERBOSE}" ]; then
428 cc_check_silent=1
429 msg 'Detecting ${CFLAGS}/${LDFLAGS} for ${CC}=%s, just a second..' \
430 "${CC}"
431 else
432 cc_check_silent=
433 msg 'Testing usable ${CFLAGS}/${LDFLAGS} for ${CC}=%s' "${CC}"
436 i=`echo "${CC}" | ${awk} 'BEGIN{FS="/"}{print $NF}'`
437 if { echo "${i}" | ${grep} tcc; } >/dev/null 2>&1; then
438 msg ' . have special tcc(1) environmental rules ...'
439 _cc_flags_tcc
440 else
441 # As of pcc CVS 2016-04-02, stack protection support is announced but
442 # will break if used on Linux
443 if { echo "${i}" | ${grep} pcc; } >/dev/null 2>&1; then
444 cc_force_no_stackprot=1
446 _cc_flags_generic
449 feat_no DEBUG && _CFLAGS="-DNDEBUG ${_CFLAGS}"
450 CFLAGS="${_CFLAGS} ${EXTRA_CFLAGS}"
451 LDFLAGS="${_LDFLAGS} ${EXTRA_LDFLAGS}"
452 else
453 if feat_no DEBUG; then
454 CFLAGS="-DNDEBUG ${CFLAGS}"
457 export CFLAGS LDFLAGS
460 _cc_flags_tcc() {
461 __cflags=${_CFLAGS} __ldflags=${_LDFLAGS}
462 _CFLAGS= _LDFLAGS=
464 cc_check -W
465 cc_check -Wall
466 cc_check -Wextra
467 cc_check -pedantic
469 if feat_yes DEBUG; then
470 # May have problems to find libtcc cc_check -b
471 cc_check -g
474 if ld_check -Wl,-rpath =./ no; then
475 ld_need_R_flags=-Wl,-rpath=
476 if [ -z "${ld_rpath_not_runpath}" ]; then
477 ld_check -Wl,--enable-new-dtags
478 else
479 msg ' ! $LD_LIBRARY_PATH adjusted, not trying --enable-new-dtags'
481 ld_runtime_flags # update!
484 _CFLAGS="${_CFLAGS} ${__cflags}" _LDFLAGS="${_LDFLAGS} ${__ldflags}"
485 unset __cflags __ldflags
488 _cc_flags_generic() {
489 __cflags=${_CFLAGS} __ldflags=${_LDFLAGS}
490 _CFLAGS= _LDFLAGS=
491 feat_yes DEVEL && cc_check -std=c89 || cc_check -std=c99
493 # E.g., valgrind does not work well with high optimization
494 if [ ${cc_maxopt} -gt 1 ] && feat_yes NOMEMDBG &&
495 feat_no ASAN_ADDRESS && feat_no ASAN_MEMORY; then
496 msg ' ! OPT_NOMEMDBG, setting cc_maxopt=1 (-O1)'
497 cc_maxopt=1
499 # Check -g first since some others may rely upon -g / optim. level
500 if feat_yes DEBUG; then
501 cc_check -O
502 cc_check -g
503 elif [ ${cc_maxopt} -gt 2 ] && cc_check -O3; then
505 elif [ ${cc_maxopt} -gt 1 ] && cc_check -O2; then
507 elif [ ${cc_maxopt} -gt 0 ] && cc_check -O1; then
509 else
510 cc_check -O
513 if feat_yes AMALGAMATION; then
514 cc_check -pipe
517 #if feat_yes DEVEL && cc_check -Weverything; then
519 #else
520 cc_check -W
521 cc_check -Wall
522 cc_check -Wextra
523 cc_check -Wbad-function-cast
524 cc_check -Wcast-align
525 cc_check -Wcast-qual
526 cc_check -Winit-self
527 cc_check -Wmissing-prototypes
528 cc_check -Wshadow
529 cc_check -Wunused
530 cc_check -Wwrite-strings
531 cc_check -Wno-long-long
533 cc_check -pedantic
535 if feat_yes AMALGAMATION && feat_no DEVEL; then
536 cc_check -Wno-unused-function
538 feat_no DEVEL && cc_check -Wno-unused-result # XXX do right way (pragma too)
540 cc_check -fno-unwind-tables
541 cc_check -fno-asynchronous-unwind-tables
542 cc_check -fstrict-aliasing
543 if cc_check -fstrict-overflow && feat_yes DEVEL; then
544 cc_check -Wstrict-overflow=5
547 if feat_yes DEBUG || feat_yes FORCED_STACKPROT; then
548 if [ -z "${cc_force_no_stackprot}" ]; then
549 if cc_check -fstack-protector-strong ||
550 cc_check -fstack-protector-all; then
551 cc_check -D_FORTIFY_SOURCE=2
553 else
554 msg ' ! Not checking for -fstack-protector compiler option,'
555 msg ' ! since that caused errors in a "similar" configuration.'
556 msg ' ! You may turn off OPT_AUTOCC and use your own settings, rerun'
560 # LD (+ dependend CC)
562 if feat_yes ASAN_ADDRESS; then
563 _ccfg=${_CFLAGS}
564 if cc_check -fsanitize=address && ld_check -fsanitize=address; then
566 else
567 feat_bail_required ASAN_ADDRESS
568 _CFLAGS=${_ccfg}
572 if feat_yes ASAN_MEMORY; then
573 _ccfg=${_CFLAGS}
574 if cc_check -fsanitize=memory && ld_check -fsanitize=memory &&
575 cc_check -fsanitize-memory-track-origins=2 &&
576 ld_check -fsanitize-memory-track-origins=2; then
578 else
579 feat_bail_required ASAN_MEMORY
580 _CFLAGS=${_ccfg}
584 if feat_yes USAN; then
585 _ccfg=${_CFLAGS}
586 if cc_check -fsanitize=undefined && ld_check -fsanitize=undefined; then
588 else
589 feat_bail_required USAN
590 _CFLAGS=${_ccfg}
594 ld_check -Wl,-z,relro
595 if [ -z "${ld_no_bind_now}" ]; then
596 ld_check -Wl,-z,now
597 else
598 msg ' ! $LD_LIBRARY_PATH adjusted, not trying -Wl,-z,now'
600 ld_check -Wl,-z,noexecstack
601 if ld_check -Wl,-rpath =./ no; then
602 ld_need_R_flags=-Wl,-rpath=
603 # Choose DT_RUNPATH (after $LD_LIBRARY_PATH) over DT_RPATH (before)
604 if [ -z "${ld_rpath_not_runpath}" ]; then
605 ld_check -Wl,--enable-new-dtags
606 else
607 msg ' ! $LD_LIBRARY_PATH adjusted, not trying --enable-new-dtags'
609 ld_runtime_flags # update!
610 elif ld_check -Wl,-R ./ no; then
611 ld_need_R_flags=-Wl,-R
612 if [ -z "${ld_rpath_not_runpath}" ]; then
613 ld_check -Wl,--enable-new-dtags
614 else
615 msg ' ! $LD_LIBRARY_PATH adjusted, not trying --enable-new-dtags'
617 ld_runtime_flags # update!
620 # Address randomization
621 _ccfg=${_CFLAGS}
622 if cc_check -fPIE || cc_check -fpie; then
623 ld_check -pie || _CFLAGS=${_ccfg}
625 unset _ccfg
627 _CFLAGS="${_CFLAGS} ${__cflags}" _LDFLAGS="${_LDFLAGS} ${__ldflags}"
628 unset __cflags __ldflags
631 ## -- >8 - <<OS/CC | SUPPORT FUNS>> - 8< -- ##
633 ## Notes:
634 ## - Heirloom sh(1) (and same origin) have _sometimes_ problems with ': >'
635 ## redirection, so use "printf '' >" instead
637 ## Very first: we undergo several states regarding I/O redirection etc.,
638 ## but need to deal with option updates from within all. Since all the
639 ## option stuff should be above the scissor line, define utility functions
640 ## and redefine them as necessary.
641 ## And, since we have those functions, simply use them for whatever
643 t1=ten10one1ten10one1
644 if ( [ ${t1##*ten10} = one1 ] && [ ${t1#*ten10} = one1ten10one1 ] &&
645 [ ${t1%%one1*} = ten10 ] && [ ${t1%one1*} = ten10one1ten10 ]
646 ) > /dev/null 2>&1; then
647 good_shell=1
648 else
649 unset good_shell
651 unset t1
653 ( set -o noglob ) >/dev/null 2>&1 && noglob_shell=1 || unset noglob_shell
655 config_exit() {
656 exit ${1}
659 # which(1) not standardized, command(1) -v may return non-executable: unroll!
660 acmd_test() { __acmd "${1}" 1 0 0; }
661 acmd_test_fail() { __acmd "${1}" 1 1 0; }
662 acmd_set() { __acmd "${2}" 0 0 0 "${1}"; }
663 acmd_set_fail() { __acmd "${2}" 0 1 0 "${1}"; }
664 acmd_testandset() { __acmd "${2}" 1 0 0 "${1}"; }
665 acmd_testandset_fail() { __acmd "${2}" 1 1 0 "${1}"; }
666 thecmd_set() { __acmd "${2}" 0 0 1 "${1}"; }
667 thecmd_set_fail() { __acmd "${2}" 0 1 1 "${1}"; }
668 thecmd_testandset() { __acmd "${2}" 1 0 1 "${1}"; }
669 thecmd_testandset_fail() { __acmd "${2}" 1 1 1 "${1}"; }
670 __acmd() {
671 pname=${1} dotest=${2} dofail=${3} verbok=${4} varname=${5}
673 if [ "${dotest}" -ne 0 ]; then
674 eval dotest=\$${varname}
675 if [ -n "${dotest}" ]; then
676 [ -n "${VERBOSE}" ] && [ ${verbok} -ne 0 ] &&
677 msg ' . ${%s} ... %s' "${pname}" "${dotest}"
678 return 0
682 oifs=${IFS} IFS=:
683 [ -n "${noglob_shell}" ] && set -o noglob
684 set -- ${PATH}
685 [ -n "${noglob_shell}" ] && set +o noglob
686 IFS=${oifs}
687 for path
689 if [ -z "${path}" ] || [ "${path}" = . ]; then
690 if [ -d "${PWD}" ]; then
691 path=${PWD}
692 else
693 path=.
696 if [ -f "${path}/${pname}" ] && [ -x "${path}/${pname}" ]; then
697 [ -n "${VERBOSE}" ] && [ ${verbok} -ne 0 ] &&
698 msg ' . ${%s} ... %s' "${pname}" "${path}/${pname}"
699 [ -n "${varname}" ] && eval ${varname}="${path}/${pname}"
700 return 0
702 done
704 # We may have no builtin string functions, we yet have no programs we can
705 # use, try to access once from the root, assuming it is an absolute path if
706 # that finds the executable
707 if ( cd && [ -f "${pname}" ] && [ -x "${pname}" ] ); then
708 [ -n "${VERBOSE}" ] && [ ${verbok} -ne 0 ] &&
709 msg ' . ${%s} ... %s' "${pname}" "${pname}"
710 [ -n "${varname}" ] && eval ${varname}="${pname}"
711 return 0
714 [ ${dofail} -eq 0 ] && return 1
715 msg 'ERROR: no trace of utility '"${pname}"
716 exit 1
719 msg() {
720 fmt=${1}
721 shift
722 printf >&2 -- "${fmt}\\n" "${@}"
725 msg_nonl() {
726 fmt=${1}
727 shift
728 printf >&2 -- "${fmt}" "${@}"
731 # Our feature check environment
732 feat_val_no() {
733 [ "x${1}" = x0 ] || [ "x${1}" = xn ] ||
734 [ "x${1}" = xfalse ] || [ "x${1}" = xno ] || [ "x${1}" = xoff ]
737 feat_val_yes() {
738 [ "x${1}" = x1 ] || [ "x${1}" = xy ] ||
739 [ "x${1}" = xtrue ] || [ "x${1}" = xyes ] || [ "x${1}" = xon ] ||
740 [ "x${1}" = xrequire ]
743 feat_val_require() {
744 [ "x${1}" = xrequire ]
747 _feat_check() {
748 eval i=\$OPT_${1}
749 i="`echo ${i} | ${tr} '[A-Z]' '[a-z]'`"
750 if feat_val_no "${i}"; then
751 return 1
752 elif feat_val_yes "${i}"; then
753 return 0
754 else
755 msg "ERROR: %s: 0/n/false/no/off or 1/y/true/yes/on/require, got: %s" \
756 "${1}" "${i}"
757 config_exit 11
761 feat_yes() {
762 _feat_check ${1}
765 feat_no() {
766 _feat_check ${1} && return 1
767 return 0
770 feat_require() {
771 eval i=\$OPT_${1}
772 i="`echo ${i} | ${tr} '[A-Z]' '[a-z]'`"
773 [ "x${i}" = xrequire ] || [ "x${i}" = xrequired ]
776 feat_bail_required() {
777 if feat_require ${1}; then
778 msg 'ERROR: feature OPT_%s is required but not available' "${1}"
779 config_exit 13
781 feat_is_unsupported "${1}"
784 feat_is_disabled() {
785 [ ${#} -eq 1 ] && msg ' . (disabled: OPT_%s)' "${1}"
786 echo "/* OPT_${1} -> HAVE_${1} */" >> ${h}
789 feat_is_unsupported() {
790 msg ' ! NOTICE: unsupported: OPT_%s' "${1}"
791 echo "/* OPT_${1} -> HAVE_${1} */" >> ${h}
792 eval OPT_${1}=0
793 option_update # XXX this is rather useless here (dependency chain..)
796 feat_def() {
797 if feat_yes ${1}; then
798 msg ' . %s ... yes' "${1}"
799 echo '#define HAVE_'${1}'' >> ${h}
800 return 0
801 else
802 feat_is_disabled "${@}"
803 return 1
807 option_parse() {
808 # Parse one of our XOPTIONS* in $2 and assign the sh(1) compatible list of
809 # options, without documentation, to $1
810 j=\'
811 i="`${awk} -v input=\"${2}\" '
812 BEGIN{
813 for(i = 0;;){
814 voff = match(input, /[[:alnum:]_]+(='${j}'[^'${j}']+)?/)
815 if(voff == 0)
816 break
817 v = substr(input, voff, RLENGTH)
818 input = substr(input, voff + RLENGTH)
819 doff = index(v, "=")
820 if(doff > 0){
821 d = substr(v, doff + 2, length(v) - doff - 1)
822 v = substr(v, 1, doff - 1)
824 print v
828 eval ${1}=\"${i}\"
831 option_doc_of() {
832 # Return the "documentation string" for option $1, itself if none such
833 j=\'
834 ${awk} -v want="${1}" \
835 -v input="${XOPTIONS_DETECT}${XOPTIONS}${XOPTIONS_XTRA}" '
836 BEGIN{
837 for(;;){
838 voff = match(input, /[[:alnum:]_]+(='${j}'[^'${j}']+)?/)
839 if(voff == 0)
840 break
841 v = substr(input, voff, RLENGTH)
842 input = substr(input, voff + RLENGTH)
843 doff = index(v, "=")
844 if(doff > 0){
845 d = substr(v, doff + 2, length(v) - doff - 1)
846 v = substr(v, 1, doff - 1)
847 }else
848 d = v
849 if(v == want){
850 if(d != "-")
851 print d
852 exit
859 option_join_rc() {
860 # Join the values from make.rc into what currently is defined, not
861 # overwriting yet existing settings
862 ${rm} -f ${tmp}
863 # We want read(1) to perform reverse solidus escaping in order to be able to
864 # use multiline values in make.rc; the resulting sh(1)/sed(1) code was very
865 # slow in VMs (see [fa2e248]), Aharon Robbins suggested the following
866 < ${rc} ${awk} 'BEGIN{line = ""}{
867 gsub(/^[[:space:]]+/, "", $0)
868 gsub(/[[:space:]]+$/, "", $0)
869 if(gsub(/\\$/, "", $0)){
870 line = line $0
871 next
872 }else
873 line = line $0
874 if(index(line, "#") == 1){
875 line = ""
876 }else if(length(line)){
877 print line
878 line = ""
880 }' |
881 while read line; do
882 if [ -n "${good_shell}" ]; then
883 i=${line%%=*}
884 else
885 i=`${awk} -v LINE="${line}" 'BEGIN{
886 gsub(/=.*$/, "", LINE)
887 print LINE
890 if [ "${i}" = "${line}" ]; then
891 msg 'ERROR: invalid syntax in: %s' "${line}"
892 continue
895 eval j="\$${i}" jx="\${${i}+x}"
896 if [ -n "${j}" ] || [ "${jx}" = x ]; then
897 : # Yet present
898 else
899 j=`${awk} -v LINE="${line}" 'BEGIN{
900 gsub(/^[^=]*=/, "", LINE)
901 gsub(/^\"*/, "", LINE)
902 gsub(/\"*$/, "", LINE)
903 print LINE
906 [ "${i}" = "DESTDIR" ] && continue
907 echo "${i}=\"${j}\""
908 done > ${tmp}
909 # Reread the mixed version right now
910 . ./${tmp}
913 option_evaluate() {
914 # Expand the option values, which may contain shell snippets
915 ${rm} -f ${newlst} ${newmk} ${newh}
916 exec 5<&0 6>&1 <${tmp} >${newlst}
917 while read line; do
919 if [ -n "${good_shell}" ]; then
920 i=${line%%=*}
921 [ "${i}" != "${i#OPT_}" ] && z=1
922 else
923 i=`${awk} -v LINE="${line}" 'BEGIN{
924 gsub(/=.*$/, "", LINE);\
925 print LINE
927 if echo "${i}" | ${grep} '^OPT_' >/dev/null 2>&1; then
932 eval j=\$${i}
933 if [ -n "${z}" ]; then
934 j="`echo ${j} | ${tr} '[A-Z]' '[a-z]'`"
935 if [ -z "${j}" ] || feat_val_no "${j}"; then
937 printf " /* #undef ${i} */\n" >> ${newh}
938 elif feat_val_yes "${j}"; then
939 if feat_val_require "${j}"; then
940 j=require
941 else
944 printf " /* #define ${i} */\n" >> ${newh}
945 else
946 msg 'ERROR: cannot parse <%s>' "${line}"
947 config_exit 1
949 elif { echo ${i} | ${grep} ${H_BLACKLIST} >/dev/null 2>&1; }; then
951 else
952 printf "#define ${i} \"${j}\"\n" >> ${newh}
954 printf "${i} = ${j}\n" >> ${newmk}
955 printf "${i}=${j}\n"
956 eval "${i}=\"${j}\""
957 done
958 exec 0<&5 1>&6 5<&- 6<&-
961 val_allof() {
962 eval __expo__=\$${1}
963 ${awk} -v HEAP="${2}" -v USER="${__expo__}" '
964 BEGIN{
965 i = split(HEAP, ha, /[, ]/)
966 if((j = split(USER, ua, /[, ]/)) == 0)
967 exit
968 for(; j != 0; --j){
969 us = tolower(ua[j])
970 if(us == "all" || us == "any")
971 continue
972 ok = 0
973 for(ii = i; ii != 0; --ii)
974 if(tolower(ha[ii]) == us){
975 ok = 1
976 break
978 if(!ok)
979 exit 1
983 __rv__=${?}
984 [ ${__rv__} -ne 0 ] && return ${__rv__}
986 if ${awk} -v USER="${__expo__}" '
987 BEGIN{
988 if((j = split(USER, ua, /[, ]/)) == 0)
989 exit
990 for(; j != 0; --j){
991 us = tolower(ua[j])
992 if(us == "all" || us == "any")
993 exit 0
995 exit 1
997 '; then
998 eval "${1}"=\"${2}\"
999 else
1000 # Enfore lowercase also in otherwise unchanged user value..
1001 eval "${1}"=\""`echo ${__expo__} | ${tr} '[A-Z]_' '[a-z]-'`"\"
1003 return 0
1006 path_check() {
1007 # "path_check VARNAME" or "path_check VARNAME FLAG VARNAME"
1008 varname=${1} addflag=${2} flagvarname=${3}
1009 j=${IFS}
1010 IFS=:
1011 [ -n "${noglob_shell}" ] && set -o noglob
1012 eval "set -- \$${1}"
1013 [ -n "${noglob_shell}" ] && set +o noglob
1014 IFS=${j}
1015 j= k= y= z=
1016 for i
1018 [ -z "${i}" ] && continue
1019 [ -d "${i}" ] || continue
1020 if [ -n "${j}" ]; then
1021 if { z=${y}; echo "${z}"; } | ${grep} ":${i}:" >/dev/null 2>&1; then
1023 else
1024 y="${y} :${i}:"
1025 j="${j}:${i}"
1026 # But do not link any fakeroot path into our binaries!
1027 if [ -n "${addflag}" ]; then
1028 case "${i}" in *fakeroot*) continue;; esac
1029 k="${k} ${addflag}${i}"
1032 else
1033 y=" :${i}:"
1034 j="${i}"
1035 # But do not link any fakeroot path into our binaries!
1036 if [ -n "${addflag}" ]; then
1037 case "${i}" in *fakeroot*) continue;; esac
1038 k="${k} ${addflag}${i}"
1041 done
1042 eval "${varname}=\"${j}\""
1043 [ -n "${addflag}" ] && eval "${flagvarname}=\"${k}\""
1044 unset varname
1047 ld_runtime_flags() {
1048 if [ -n "${ld_need_R_flags}" ]; then
1049 i=${IFS}
1050 IFS=:
1051 set -- ${LD_LIBRARY_PATH}
1052 IFS=${i}
1053 for i
1055 # But do not link any fakeroot path into our binaries!
1056 case "${i}" in *fakeroot*) continue;; esac
1057 LDFLAGS="${LDFLAGS} ${ld_need_R_flags}${i}"
1058 _LDFLAGS="${_LDFLAGS} ${ld_need_R_flags}${i}"
1059 done
1060 export LDFLAGS
1062 # Disable it for a possible second run.
1063 ld_need_R_flags=
1066 cc_check() {
1067 [ -n "${cc_check_silent}" ] || msg_nonl ' . CC %s .. ' "${1}"
1068 if ${CC} ${INCS} \
1069 ${_CFLAGS} ${1} ${EXTRA_CFLAGS} ${_LDFLAGS} ${EXTRA_LDFLAGS} \
1070 -o ${tmp2} ${tmp}.c ${LIBS} >/dev/null 2>&1; then
1071 _CFLAGS="${_CFLAGS} ${1}"
1072 [ -n "${cc_check_silent}" ] || msg 'yes'
1073 return 0
1075 [ -n "${cc_check_silent}" ] || msg 'no'
1076 return 1
1079 ld_check() {
1080 # $1=option [$2=option argument] [$3=if set, shall NOT be added to _LDFLAGS]
1081 [ -n "${cc_check_silent}" ] || msg_nonl ' . LD %s .. ' "${1}"
1082 if ${CC} ${INCS} ${_CFLAGS} ${_LDFLAGS} ${1}${2} ${EXTRA_LDFLAGS} \
1083 -o ${tmp2} ${tmp}.c ${LIBS} >/dev/null 2>&1; then
1084 [ -n "${3}" ] || _LDFLAGS="${_LDFLAGS} ${1}"
1085 [ -n "${cc_check_silent}" ] || msg 'yes'
1086 return 0
1088 [ -n "${cc_check_silent}" ] || msg 'no'
1089 return 1
1092 dump_test_program=1
1093 _check_preface() {
1094 variable=$1 topic=$2 define=$3
1096 echo '**********'
1097 msg_nonl ' . %s ... ' "${topic}"
1098 #echo "/* checked ${topic} */" >> ${h}
1099 ${rm} -f ${tmp} ${tmp}.o
1100 if [ "${dump_test_program}" = 1 ]; then
1101 echo '*** test program is'
1102 { echo '#include <'"${h_name}"'>'; cat; } | ${tee} ${tmp}.c
1103 else
1104 { echo '#include <'"${h_name}"'>'; cat; } > ${tmp}.c
1106 #echo '*** the preprocessor generates'
1107 #${make} -f ${makefile} ${tmp}.x
1108 #${cat} ${tmp}.x
1109 echo '*** tests results'
1112 without_check() {
1113 yesno=$1 variable=$2 topic=$3 define=$4 libs=$5 incs=$6
1115 echo '**********'
1116 msg_nonl ' . %s ... ' "${topic}"
1118 echo '*** enforced unchecked results are'
1119 if feat_val_yes ${yesno}; then
1120 if [ -n "${incs}" ] || [ -n "${libs}" ]; then
1121 echo "*** adding INCS<${incs}> LIBS<${libs}>"
1122 LIBS="${LIBS} ${libs}"
1123 echo "${libs}" >> ${lib}
1124 INCS="${INCS} ${incs}"
1125 echo "${incs}" >> ${inc}
1127 msg 'yes (deduced)'
1128 echo "${define}" >> ${h}
1129 eval have_${variable}=yes
1130 return 0
1131 else
1132 #echo "/* ${define} */" >> ${h}
1133 msg 'no (deduced)'
1134 eval unset have_${variable}
1135 return 1
1139 compile_check() {
1140 variable=$1 topic=$2 define=$3
1142 _check_preface "${variable}" "${topic}" "${define}"
1144 if ${make} -f ${makefile} XINCS="${INCS}" \
1145 CFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}" ${tmp}.o &&
1146 [ -f ${tmp}.o ]; then
1147 msg 'yes'
1148 echo "${define}" >> ${h}
1149 eval have_${variable}=yes
1150 return 0
1151 else
1152 #echo "/* ${define} */" >> ${h}
1153 msg 'no'
1154 eval unset have_${variable}
1155 return 1
1159 _link_mayrun() {
1160 run=$1 variable=$2 topic=$3 define=$4 libs=$5 incs=$6
1162 _check_preface "${variable}" "${topic}" "${define}"
1164 if feat_yes CROSS_BUILD; then
1165 if [ ${run} = 1 ]; then
1166 run=0
1170 if ${make} -f ${makefile} XINCS="${INCS} ${incs}" \
1171 CFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}" \
1172 XLIBS="${LIBS} ${libs}" ${tmp} &&
1173 [ -f ${tmp} ] && { [ ${run} -eq 0 ] || ${tmp}; }; then
1174 echo "*** adding INCS<${incs}> LIBS<${libs}>; executed: ${run}"
1175 msg 'yes'
1176 echo "${define}" >> ${h}
1177 LIBS="${LIBS} ${libs}"
1178 echo "${libs}" >> ${lib}
1179 INCS="${INCS} ${incs}"
1180 echo "${incs}" >> ${inc}
1181 eval have_${variable}=yes
1182 return 0
1183 else
1184 msg 'no'
1185 #echo "/* ${define} */" >> ${h}
1186 eval unset have_${variable}
1187 return 1
1191 link_check() {
1192 _link_mayrun 0 "${1}" "${2}" "${3}" "${4}" "${5}"
1195 run_check() {
1196 _link_mayrun 1 "${1}" "${2}" "${3}" "${4}" "${5}"
1199 xrun_check() {
1200 _link_mayrun 2 "${1}" "${2}" "${3}" "${4}" "${5}"
1203 squeeze_em() {
1204 < "${1}" > "${2}" ${awk} \
1205 'BEGIN {ORS = " "} /^[^#]/ {print} {next} END {ORS = ""; print "\n"}'
1208 ## -- >8 - <<SUPPORT FUNS | RUNNING>> - 8< -- ##
1210 # First of all, create new configuration and check whether it changed
1212 if [ -d .obj ] || mkdir .obj; then :; else
1213 msg 'ERROR: cannot create .obj build directory'
1214 exit 1
1217 # Very easy checks for the operating system in order to be able to adjust paths
1218 # or similar very basic things which we need to be able to go at all
1219 os_early_setup
1221 # Check those tools right now that we need before including $rc
1222 msg 'Checking for basic utility set'
1223 thecmd_testandset_fail awk awk
1224 thecmd_testandset_fail rm rm
1225 thecmd_testandset_fail tr tr
1227 # Initialize the option set
1228 msg_nonl 'Setting up configuration options ... '
1229 option_setup
1230 msg 'done'
1232 # Include $rc, but only take from it what wasn't overwritten by the user from
1233 # within the command line or from a chosen fixed CONFIG=
1234 # Note we leave alone the values
1235 trap "exit 1" HUP INT TERM
1236 trap "${rm} -f ${tmp}" EXIT
1238 msg_nonl 'Joining in %s ... ' ${rc}
1239 option_join_rc
1240 msg 'done'
1242 # We need to know about that now, in order to provide utility overwrites etc.
1243 os_setup
1245 msg 'Checking for remaining set of utilities'
1246 thecmd_testandset_fail grep grep
1248 # Before we step ahead with the other utilities perform a path cleanup first.
1249 path_check PATH
1251 # awk(1) above
1252 thecmd_testandset_fail basename basename
1253 thecmd_testandset_fail cat cat
1254 thecmd_testandset_fail chmod chmod
1255 thecmd_testandset_fail cp cp
1256 thecmd_testandset_fail cmp cmp
1257 # grep(1) above
1258 thecmd_testandset_fail mkdir mkdir
1259 thecmd_testandset_fail mv mv
1260 # pwd(1) is needed - either for make-emerge.sh, or for ourselves
1261 [ -n "${CWDDIR}" ] || thecmd_testandset_fail pwd pwd
1262 # rm(1) above
1263 thecmd_testandset_fail sed sed
1264 thecmd_testandset_fail sort sort
1265 thecmd_testandset_fail tee tee
1266 __PATH=${PATH}
1267 thecmd_testandset chown chown ||
1268 PATH="/sbin:${PATH}" thecmd_set chown chown ||
1269 PATH="/usr/sbin:${PATH}" thecmd_set_fail chown chown
1270 PATH=${__PATH}
1271 thecmd_testandset_fail MAKE make
1272 make=${MAKE}
1273 export MAKE
1274 thecmd_testandset strip strip && HAVE_STRIP=1 || HAVE_STRIP=0
1276 # For ./cc-test.sh only
1277 thecmd_testandset_fail cksum cksum
1279 # Now that we have pwd(1), set our build paths unless make-emerge.sh has been
1280 # used; it would have created a makefile with the full paths, then
1281 [ -n "${CWDDIR}" ] || CWDDIR=`${pwd}`/
1282 [ -n "${SRCDIR}" ] || SRCDIR=${CWDDIR}
1284 # Update OPT_ options now, in order to get possible inter-dependencies right
1285 option_update
1287 # (No functions since some shells loose non-exported variables in traps)
1288 trap "trap \"\" HUP INT TERM; exit 1" HUP INT TERM
1289 trap "trap \"\" HUP INT TERM EXIT;\
1290 ${rm} -rf ${newlst} ${tmp0}.* ${tmp0}* \
1291 ${newmk} ${oldmk} ${newev} ${newh} ${oldh}" EXIT
1293 # Our configuration options may at this point still contain shell snippets,
1294 # we need to evaluate them in order to get them expanded, and we need those
1295 # evaluated values not only in our new configuration file, but also at hand..
1296 msg_nonl 'Evaluating all configuration items ... '
1297 option_evaluate
1298 msg 'done'
1301 printf "#define VAL_UAGENT \"${VAL_SID}${VAL_MAILX}\"\n" >> ${newh}
1302 printf "VAL_UAGENT = ${VAL_SID}${VAL_MAILX}\n" >> ${newmk}
1304 # The problem now is that the test should be able to run in the users linker
1305 # and path environment, so we need to place the test: rule first, before
1306 # injecting the relevant make variables. Set up necessary environment
1307 if [ -z "${VERBOSE}" ]; then
1308 printf -- "ECHO_CC = @echo ' 'CC \$(@);\n" >> ${newmk}
1309 printf -- "ECHO_LINK = @echo ' 'LINK \$(@);\n" >> ${newmk}
1310 printf -- "ECHO_GEN = @echo ' 'GEN \$(@);\n" >> ${newmk}
1311 printf -- "ECHO_TEST = @\n" >> ${newmk}
1312 printf -- "ECHO_CMD = @echo ' CMD';\n" >> ${newmk}
1313 printf -- "ECHO_BLOCK_BEGIN = @( \n" >> ${newmk}
1314 printf -- "ECHO_BLOCK_END = ) >/dev/null\n" >> ${newmk}
1316 printf 'test: all\n\t$(ECHO_TEST)%s %scc-test.sh --check-only %s\n' \
1317 "${SHELL}" "${SRCDIR}" "./${VAL_SID}${VAL_MAILX}" >> ${newmk}
1319 # Add the known utility and some other variables
1320 printf "#define VAL_PRIVSEP \"${VAL_SID}${VAL_MAILX}-privsep\"\n" >> ${newh}
1321 printf "VAL_PRIVSEP = \$(VAL_UAGENT)-privsep\n" >> ${newmk}
1322 if feat_yes DOTLOCK; then
1323 printf "OPTIONAL_PRIVSEP = \$(VAL_PRIVSEP)\n" >> ${newmk}
1324 else
1325 printf "OPTIONAL_PRIVSEP =\n" >> ${newmk}
1328 for i in \
1329 CWDDIR SRCDIR \
1330 awk basename cat chmod chown cp cmp grep mkdir mv rm sed sort tee tr \
1331 MAKE MAKEFLAGS make SHELL strip \
1332 cksum; do
1333 eval j=\$${i}
1334 printf -- "${i} = ${j}\n" >> ${newmk}
1335 printf -- "${i}=${j}\n" >> ${newlst}
1336 printf -- "${i}=\"${j}\";export ${i}; " >> ${newev}
1337 done
1338 # Note that makefile reads and eval'uates one line of this file, whereas other
1339 # consumers source it via .(1)
1340 printf "\n" >> ${newev}
1342 # Build a basic set of INCS and LIBS according to user environment.
1343 C_INCLUDE_PATH="${CWDDIR}:${CWDDIR}.obj:${SRCDIR}:${C_INCLUDE_PATH}"
1344 path_check C_INCLUDE_PATH -I _INCS
1345 INCS="${INCS} ${_INCS}"
1346 path_check LD_LIBRARY_PATH -L _LIBS
1347 LIBS="${LIBS} ${_LIBS}"
1348 unset _INCS _LIBS
1349 export C_INCLUDE_PATH LD_LIBRARY_PATH
1351 # Some environments need runtime path flags to be able to go at all
1352 ld_runtime_flags
1354 ## Detect CC, whether we can use it, and possibly which CFLAGS we can use
1356 cc_setup
1358 ${cat} > ${tmp}.c << \!
1359 #include <stdio.h>
1360 #include <string.h>
1361 static void doit(char const *s);
1363 main(int argc, char **argv){
1364 (void)argc;
1365 (void)argv;
1366 doit("Hello world");
1367 return 0;
1369 static void
1370 doit(char const *s){
1371 char buf[12];
1372 memcpy(buf, s, strlen(s) +1);
1373 puts(s);
1377 if ${CC} ${INCS} ${CFLAGS} ${EXTRA_CFLAGS} ${LDFLAGS} ${EXTRA_LDFLAGS} \
1378 -o ${tmp2} ${tmp}.c ${LIBS}; then
1380 else
1381 msg 'ERROR: i cannot compile a "Hello world" via'
1382 msg ' %s' \
1383 "${CC} ${INCS} ${CFLAGS} ${EXTRA_CFLAGS} ${LDFLAGS} ${EXTRA_LDFLAGS} ${LIBS}"
1384 msg 'ERROR: Please read INSTALL, rerun'
1385 config_exit 1
1388 # This may also update ld_runtime_flags() (again)
1389 cc_flags
1391 for i in \
1392 INCS LIBS \
1393 ; do
1394 eval j=\$${i}
1395 printf -- "${i}=${j}\n" >> ${newlst}
1396 done
1397 for i in \
1398 CC \
1399 CFLAGS \
1400 LDFLAGS \
1401 PATH C_INCLUDE_PATH LD_LIBRARY_PATH \
1402 OSFULLSPEC \
1403 ; do
1404 eval j=\$${i}
1405 if [ -n "${j}" ]; then
1406 printf -- "${i} = ${j}\n" >> ${newmk}
1407 printf -- "${i}=${j}\n" >> ${newlst}
1409 done
1411 # Now finally check whether we already have a configuration and if so, whether
1412 # all those parameters are still the same.. or something has actually changed
1413 config_updated=
1414 if [ -f ${lst} ] && ${cmp} ${newlst} ${lst} >/dev/null 2>&1; then
1415 echo 'Configuration is up-to-date'
1416 exit 0
1417 elif [ -f ${lst} ]; then
1418 config_updated=1
1419 echo 'Configuration has been updated..'
1420 else
1421 echo 'Shiny configuration..'
1424 # Time to redefine helper 1
1425 config_exit() {
1426 ${rm} -f ${lst} ${h} ${mk}
1427 exit ${1}
1430 ${mv} -f ${newlst} ${lst}
1431 ${mv} -f ${newev} ${ev}
1432 [ -f ${h} ] && ${mv} -f ${h} ${oldh}
1433 ${mv} -f ${newh} ${h}
1434 [ -f ${mk} ] && ${mv} -f ${mk} ${oldmk}
1435 ${mv} -f ${newmk} ${mk}
1437 ## Compile and link checking
1439 tmp3=${tmp0}3$$
1440 log=.obj/mk-config.log
1441 lib=.obj/mk-config.lib
1442 inc=.obj/mk-config.inc
1443 makefile=${tmp0}.mk
1445 # (No function since some shells loose non-exported variables in traps)
1446 trap "trap \"\" HUP INT TERM;\
1447 ${rm} -f ${lst} ${oldh} ${h} ${oldmk} ${mk} ${lib} ${inc}; exit 1" \
1448 HUP INT TERM
1449 trap "trap \"\" HUP INT TERM EXIT;\
1450 ${rm} -rf ${oldh} ${oldmk} ${tmp0}.* ${tmp0}*" EXIT
1452 # Time to redefine helper 2
1453 msg() {
1454 fmt=${1}
1455 shift
1456 printf "*** ${fmt}\\n" "${@}"
1457 printf -- "${fmt}\\n" "${@}" >&5
1459 msg_nonl() {
1460 fmt=${1}
1461 shift
1462 printf "*** ${fmt}\\n" "${@}"
1463 printf -- "${fmt}" "${@}" >&5
1466 # !!
1467 exec 5>&2 > ${log} 2>&1
1469 echo "${LIBS}" > ${lib}
1470 echo "${INCS}" > ${inc}
1471 ${cat} > ${makefile} << \!
1472 .SUFFIXES: .o .c .x .y
1473 .c.o:
1474 $(CC) -I./ $(XINCS) $(CFLAGS) -o $(@) -c $(<)
1475 .c.x:
1476 $(CC) -I./ $(XINCS) -E $(<) > $(@)
1478 $(CC) -I./ $(XINCS) $(CFLAGS) $(LDFLAGS) -o $(@) $(<) $(XLIBS)
1481 ## Generics
1483 # May be multiline..
1484 echo >> ${h}
1485 [ -n "${OS_DEFINES}" ] && printf -- "${OS_DEFINES}" >> ${h}
1486 echo '#define VAL_BUILD_OS "'"${OS}"'"' >> ${h}
1487 echo '#define VAL_BUILD_OSENV "'"${OSENV}"'"' >> ${h}
1489 # Generate n_err_number OS mappings
1490 dump_test_program=0
1492 feat_yes DEVEL && NV= || NV=noverbose
1493 SRCDIR="${SRCDIR}" TARGET="${h}" awk="${awk}" \
1494 ${SHELL} "${SRCDIR}"make-errors.sh ${NV} config
1495 ) | xrun_check oserrno 'OS error mapping table generated' || config_exit 1
1496 dump_test_program=1
1498 feat_def ALWAYS_UNICODE_LOCALE
1499 feat_def AMALGAMATION 0
1500 feat_def CROSS_BUILD
1501 feat_def DOCSTRINGS
1502 feat_def UISTRINGS
1503 feat_def ERRORS
1505 feat_def ASAN_ADDRESS 0
1506 feat_def ASAN_MEMORY 0
1507 feat_def DEBUG 0
1508 feat_def DEVEL 0
1509 feat_def NYD2 0
1510 feat_def NOMEMDBG 0
1512 if xrun_check inline 'inline functions' \
1513 '#define HAVE_INLINE
1514 #define n_INLINE static inline' << \!
1515 static inline int ilf(int i){return ++i;}
1516 int main(void){return ilf(-1);}
1518 then
1520 elif xrun_check inline 'inline functions (via __inline)' \
1521 '#define HAVE_INLINE
1522 #define n_INLINE static __inline' << \!
1523 static __inline int ilf(int i){return ++i;}
1524 int main(void){return ilf(-1);}
1526 then
1530 ## Test for "basic" system-calls / functionality that is used by all parts
1531 ## of our program. Once this is done fork away BASE_LIBS and other BASE_*
1532 ## macros to be used by only the subprograms (potentially).
1534 if run_check clock_gettime 'clock_gettime(2)' \
1535 '#define HAVE_CLOCK_GETTIME' << \!
1536 #include <time.h>
1537 # include <errno.h>
1538 int main(void){
1539 struct timespec ts;
1541 if(!clock_gettime(CLOCK_REALTIME, &ts) || errno != ENOSYS)
1542 return 0;
1543 return 1;
1546 then
1548 elif run_check clock_gettime 'clock_gettime(2) (via -lrt)' \
1549 '#define HAVE_CLOCK_GETTIME' '-lrt' << \!
1550 #include <time.h>
1551 # include <errno.h>
1552 int main(void){
1553 struct timespec ts;
1555 if(!clock_gettime(CLOCK_REALTIME, &ts) || errno != ENOSYS)
1556 return 0;
1557 return 1;
1560 then
1562 elif run_check gettimeofday 'gettimeofday(2)' \
1563 '#define HAVE_GETTIMEOFDAY' << \!
1564 #include <stdio.h> /* For C89 NULL */
1565 #include <sys/time.h>
1566 # include <errno.h>
1567 int main(void){
1568 struct timeval tv;
1570 if(!gettimeofday(&tv, NULL) || errno != ENOSYS)
1571 return 0;
1572 return 1;
1575 then
1577 else
1578 have_no_subsecond_time=1
1581 if run_check nanosleep 'nanosleep(2)' \
1582 '#define HAVE_NANOSLEEP' << \!
1583 #include <time.h>
1584 # include <errno.h>
1585 int main(void){
1586 struct timespec ts;
1588 ts.tv_sec = 1;
1589 ts.tv_nsec = 100000;
1590 if(!nanosleep(&ts, NULL) || errno != ENOSYS)
1591 return 0;
1592 return 1;
1595 then
1597 elif run_check nanosleep 'nanosleep(2) (via -lrt)' \
1598 '#define HAVE_NANOSLEEP' '-lrt' << \!
1599 #include <time.h>
1600 # include <errno.h>
1601 int main(void){
1602 struct timespec ts;
1604 ts.tv_sec = 1;
1605 ts.tv_nsec = 100000;
1606 if(!nanosleep(&ts, NULL) || errno != ENOSYS)
1607 return 0;
1608 return 1;
1611 then
1613 # link_check is enough for this, that function is so old, trust the proto
1614 elif link_check sleep 'sleep(3)' \
1615 '#define HAVE_SLEEP' << \!
1616 #include <unistd.h>
1617 # include <errno.h>
1618 int main(void){
1619 if(!sleep(1) || errno != ENOSYS)
1620 return 0;
1621 return 1;
1624 then
1626 else
1627 msg 'ERROR: we require one of nanosleep(2) and sleep(3).'
1628 config_exit 1
1631 if run_check userdb 'gete?[gu]id(2), getpwuid(3), getpwnam(3)' << \!
1632 #include <pwd.h>
1633 #include <unistd.h>
1634 # include <errno.h>
1635 int main(void){
1636 struct passwd *pw;
1637 gid_t gid;
1638 uid_t uid;
1640 if((gid = getgid()) != 0)
1641 gid = getegid();
1642 if((uid = getuid()) != 0)
1643 uid = geteuid();
1644 if((pw = getpwuid(uid)) == NULL && errno == ENOSYS)
1645 return 1;
1646 if((pw = getpwnam("root")) == NULL && errno == ENOSYS)
1647 return 1;
1648 return 0;
1651 then
1653 else
1654 msg 'ERROR: we require user and group info / database searches.'
1655 msg 'That much Unix we indulge ourselfs.'
1656 config_exit 1
1659 if link_check ftruncate 'ftruncate(2)' \
1660 '#define HAVE_FTRUNCATE' << \!
1661 #include <unistd.h>
1662 #include <sys/types.h>
1663 int main(void){
1664 return (ftruncate(0, 0) != 0);
1667 then
1669 else
1670 # TODO support HAVE_FTRUNCATE *everywhere*, do not require this syscall!
1671 msg 'ERROR: we require the ftruncate(2) system call.'
1672 config_exit 1
1675 if run_check sa_restart 'SA_RESTART (for sigaction(2))' << \!
1676 #include <signal.h>
1677 # include <errno.h>
1678 int main(void){
1679 struct sigaction nact, oact;
1681 nact.sa_handler = SIG_DFL;
1682 sigemptyset(&nact.sa_mask);
1683 nact.sa_flags = SA_RESTART;
1684 return !(!sigaction(SIGCHLD, &nact, &oact) || errno != ENOSYS);
1687 then
1689 else
1690 msg 'ERROR: we (yet) require the SA_RESTART flag for sigaction(2).'
1691 config_exit 1
1694 if link_check snprintf 'snprintf(3)' << \!
1695 #include <stdio.h>
1696 int main(void){
1697 char b[20];
1699 snprintf(b, sizeof b, "%s", "string");
1700 return 0;
1703 then
1705 else
1706 msg 'ERROR: we require the snprintf(3) function.'
1707 config_exit 1
1710 if link_check environ 'environ(3)' << \!
1711 #include <stdio.h> /* For C89 NULL */
1712 int main(void){
1713 extern char **environ;
1715 return environ[0] == NULL;
1718 then
1720 else
1721 msg 'ERROR: we require the environ(3) array for subprocess control.'
1722 config_exit 1
1725 if link_check setenv '(un)?setenv(3)' '#define HAVE_SETENV' << \!
1726 #include <stdlib.h>
1727 int main(void){
1728 setenv("s-mailx", "i want to see it cute!", 1);
1729 unsetenv("s-mailx");
1730 return 0;
1733 then
1735 elif link_check setenv 'putenv(3)' '#define HAVE_PUTENV' << \!
1736 #include <stdlib.h>
1737 int main(void){
1738 putenv("s-mailx=i want to see it cute!");
1739 return 0;
1742 then
1744 else
1745 msg 'ERROR: we require either the setenv(3) or putenv(3) functions.'
1746 config_exit 1
1749 if link_check termios 'termios.h and tc*(3) family' << \!
1750 #include <termios.h>
1751 int main(void){
1752 struct termios tios;
1754 tcgetattr(0, &tios);
1755 tcsetattr(0, TCSANOW | TCSADRAIN | TCSAFLUSH, &tios);
1756 return 0;
1759 then
1761 else
1762 msg 'ERROR: we require termios.h and the tc[gs]etattr() family of functions.'
1763 msg 'That much Unix we indulge ourselfs.'
1764 config_exit 1
1767 ## optional stuff
1769 if link_check vsnprintf 'vsnprintf(3)' << \!
1770 #include <stdarg.h>
1771 #include <stdio.h>
1772 static void dome(char *buf, size_t blen, ...){
1773 va_list ap;
1775 va_start(ap, blen);
1776 vsnprintf(buf, blen, "%s", ap);
1777 va_end(ap);
1779 int main(void){
1780 char b[20];
1782 dome(b, sizeof b, "string");
1783 return 0;
1786 then
1788 else
1789 feat_bail_required ERRORS
1792 if [ "${have_vsnprintf}" = yes ]; then
1793 __va_copy() {
1794 link_check va_copy "va_copy(3) (as ${2})" \
1795 "#define HAVE_N_VA_COPY
1796 #define n_va_copy ${2}" <<_EOT
1797 #include <stdarg.h>
1798 #include <stdio.h>
1799 #if ${1}
1800 # if defined __va_copy && !defined va_copy
1801 # define va_copy __va_copy
1802 # endif
1803 #endif
1804 static void dome2(char *buf, size_t blen, va_list src){
1805 va_list ap;
1807 va_copy(ap, src);
1808 vsnprintf(buf, blen, "%s", ap);
1809 va_end(ap);
1811 static void dome(char *buf, size_t blen, ...){
1812 va_list ap;
1814 va_start(ap, blen);
1815 dome2(buf, blen, ap);
1816 va_end(ap);
1818 int main(void){
1819 char b[20];
1821 dome(b, sizeof b, "string");
1822 return 0;
1824 _EOT
1826 __va_copy 0 va_copy || __va_copy 1 __va_copy
1829 run_check pathconf 'f?pathconf(2)' '#define HAVE_PATHCONF' << \!
1830 #include <unistd.h>
1831 #include <errno.h>
1832 int main(void){
1833 int rv = 0;
1835 errno = 0;
1836 rv |= !(pathconf(".", _PC_NAME_MAX) >= 0 || errno == 0 || errno != ENOSYS);
1837 errno = 0;
1838 rv |= !(pathconf(".", _PC_PATH_MAX) >= 0 || errno == 0 || errno != ENOSYS);
1840 /* Only link check */
1841 fpathconf(0, _PC_NAME_MAX);
1843 return rv;
1847 run_check pipe2 'pipe2(2)' '#define HAVE_PIPE2' << \!
1848 #include <fcntl.h>
1849 #include <unistd.h>
1850 # include <errno.h>
1851 int main(void){
1852 int fds[2];
1854 if(!pipe2(fds, O_CLOEXEC) || errno != ENOSYS)
1855 return 0;
1856 return 1;
1860 link_check tcgetwinsize 'tcgetwinsize(3)' '#define HAVE_TCGETWINSIZE' << \!
1861 #include <termios.h>
1862 int main(void){
1863 struct winsize ws;
1865 tcgetwinsize(0, &ws);
1866 return 0;
1870 # We use this only then for now (need NOW+1)
1871 run_check utimensat 'utimensat(2)' '#define HAVE_UTIMENSAT' << \!
1872 #include <fcntl.h> /* For AT_* */
1873 #include <sys/stat.h>
1874 # include <errno.h>
1875 int main(void){
1876 struct timespec ts[2];
1878 ts[0].tv_nsec = UTIME_NOW;
1879 ts[1].tv_nsec = UTIME_OMIT;
1880 if(!utimensat(AT_FDCWD, "", ts, 0) || errno != ENOSYS)
1881 return 0;
1882 return 1;
1888 # The random check has been moved to below SSL detection due to multiple choice
1889 # selection for PRG sources
1891 link_check putc_unlocked 'putc_unlocked(3)' '#define HAVE_PUTC_UNLOCKED' <<\!
1892 #include <stdio.h>
1893 int main(void){
1894 putc_unlocked('@', stdout);
1895 return 0;
1899 link_check fchdir 'fchdir(3)' '#define HAVE_FCHDIR' << \!
1900 #include <unistd.h>
1901 int main(void){
1902 fchdir(0);
1903 return 0;
1907 if link_check realpath 'realpath(3)' '#define HAVE_REALPATH' << \!
1908 #include <stdlib.h>
1909 int main(void){
1910 char x_buf[4096], *x = realpath(".", x_buf);
1912 return (x != NULL) ? 0 : 1;
1915 then
1916 if run_check realpath_malloc 'realpath(3) takes NULL' \
1917 '#define HAVE_REALPATH_NULL' << \!
1918 #include <stdlib.h>
1919 int main(void){
1920 char *x = realpath(".", NULL);
1922 if(x != NULL)
1923 free(x);
1924 return (x != NULL) ? 0 : 1;
1927 then
1933 ## optional and selectable
1936 if feat_yes DOTLOCK; then
1937 if run_check readlink 'readlink(2)' << \!
1938 #include <unistd.h>
1939 # include <errno.h>
1940 int main(void){
1941 char buf[128];
1943 if(!readlink("here", buf, sizeof buf) || errno != ENOSYS)
1944 return 0;
1945 return 1;
1948 then
1950 else
1951 feat_bail_required DOTLOCK
1955 if feat_yes DOTLOCK; then
1956 if run_check fchown 'fchown(2)' << \!
1957 #include <unistd.h>
1958 # include <errno.h>
1959 int main(void){
1960 if(!fchown(0, 0, 0) || errno != ENOSYS)
1961 return 0;
1962 return 1;
1965 then
1967 else
1968 feat_bail_required DOTLOCK
1972 if feat_yes DOTLOCK; then
1973 if run_check prctl_dumpable 'prctl(2) + PR_SET_DUMPABLE' \
1974 '#define HAVE_PRCTL_DUMPABLE' << \!
1975 #include <sys/prctl.h>
1976 # include <errno.h>
1977 int main(void){
1978 if(!prctl(PR_SET_DUMPABLE, 0) || errno != ENOSYS)
1979 return 0;
1980 return 1;
1983 then
1985 elif run_check prtrace_deny 'ptrace(2) + PT_DENY_ATTACH' \
1986 '#define HAVE_PTRACE_DENY' << \!
1987 #include <sys/ptrace.h>
1988 # include <errno.h>
1989 int main(void){
1990 if(ptrace(PT_DENY_ATTACH, 0, 0, 0) != -1 || errno != ENOSYS)
1991 return 0;
1992 return 1;
1995 then
1997 elif run_check setpflags_protect 'setpflags(2) + __PROC_PROTECT' \
1998 '#define HAVE_SETPFLAGS_PROTECT' << \!
1999 #include <priv.h>
2000 # include <errno.h>
2001 int main(void){
2002 if(!setpflags(__PROC_PROTECT, 1) || errno != ENOSYS)
2003 return 0;
2004 return 1;
2007 then
2012 ## Now it is the time to fork away the BASE_ series
2014 ${rm} -f ${tmp}
2015 squeeze_em ${inc} ${tmp}
2016 ${mv} ${tmp} ${inc}
2017 squeeze_em ${lib} ${tmp}
2018 ${mv} ${tmp} ${lib}
2020 echo "BASE_LIBS = `${cat} ${lib}`" >> ${mk}
2021 echo "BASE_INCS = `${cat} ${inc}`" >> ${mk}
2023 ## The remains are expected to be used only by the main MUA binary!
2025 OPT_LOCALES=0
2026 link_check setlocale 'setlocale(3)' '#define HAVE_SETLOCALE' << \!
2027 #include <locale.h>
2028 int main(void){
2029 setlocale(LC_ALL, "");
2030 return 0;
2033 [ -n "${have_setlocale}" ] && OPT_LOCALES=1
2035 OPT_MULTIBYTE_CHARSETS=0
2036 OPT_WIDE_GLYPHS=0
2037 OPT_TERMINAL_CHARSET=0
2038 if [ -n "${have_setlocale}" ]; then
2039 link_check c90amend1 'ISO/IEC 9899:1990/Amendment 1:1995' \
2040 '#define HAVE_C90AMEND1' << \!
2041 #include <limits.h>
2042 #include <stdlib.h>
2043 #include <wchar.h>
2044 #include <wctype.h>
2045 int main(void){
2046 char mbb[MB_LEN_MAX + 1];
2047 wchar_t wc;
2049 iswprint(L'c');
2050 towupper(L'c');
2051 mbtowc(&wc, "x", 1);
2052 mbrtowc(&wc, "x", 1, NULL);
2053 wctomb(mbb, wc);
2054 return (mblen("\0", 1) == 0);
2057 [ -n "${have_c90amend1}" ] && OPT_MULTIBYTE_CHARSETS=1
2059 if [ -n "${have_c90amend1}" ]; then
2060 link_check wcwidth 'wcwidth(3)' '#define HAVE_WCWIDTH' << \!
2061 #include <wchar.h>
2062 int main(void){
2063 wcwidth(L'c');
2064 return 0;
2067 [ -n "${have_wcwidth}" ] && OPT_WIDE_GLYPHS=1
2070 link_check nl_langinfo 'nl_langinfo(3)' '#define HAVE_NL_LANGINFO' << \!
2071 #include <langinfo.h>
2072 #include <stdlib.h>
2073 int main(void){
2074 nl_langinfo(DAY_1);
2075 return (nl_langinfo(CODESET) == NULL);
2078 [ -n "${have_nl_langinfo}" ] && OPT_TERMINAL_CHARSET=1
2079 fi # have_setlocale
2081 link_check fnmatch 'fnmatch(3)' '#define HAVE_FNMATCH' << \!
2082 #include <fnmatch.h>
2083 int main(void){
2084 return (fnmatch("*", ".", FNM_PATHNAME | FNM_PERIOD) == FNM_NOMATCH);
2088 link_check dirent_d_type 'struct dirent.d_type' '#define HAVE_DIRENT_TYPE' << \!
2089 #include <dirent.h>
2090 int main(void){
2091 struct dirent de;
2092 return !(de.d_type == DT_UNKNOWN ||
2093 de.d_type == DT_DIR || de.d_type == DT_LNK);
2097 ## optional and selectable
2099 if feat_yes ICONV; then
2100 # To be able to create tests we need to figure out which replacement
2101 # sequence the iconv(3) implementation creates
2102 ${cat} > ${tmp2}.c << \!
2103 #include <stdio.h> /* For C89 NULL */
2104 #include <string.h>
2105 #include <iconv.h>
2106 int main(void){
2107 char inb[16], oub[16], *inbp, *oubp;
2108 iconv_t id;
2109 size_t inl, oul;
2111 memcpy(inbp = inb, "\342\200\223", sizeof("\342\200\223"));
2112 inl = sizeof("\342\200\223") -1;
2113 oul = sizeof oub;
2114 oubp = oub;
2116 if((id = iconv_open("ascii", "utf-8")) == (iconv_t)-1)
2117 return 1;
2118 if(iconv(id, &inbp, &inl, &oubp, &oul) == (size_t)-1)
2119 return 1;
2120 iconv_close(id);
2122 *oubp = '\0';
2123 oul = (size_t)(oubp - oub);
2124 if(oul == 0)
2125 return 1;
2126 /* Character-wise replacement? */
2127 if(oul == 1){
2128 if(oub[0] == '?')
2129 return 2;
2130 if(oub[0] == '*')
2131 return 3;
2132 return 1;
2134 /* Byte-wise replacement? */
2135 if(oul == sizeof("\342\200\223") -1){
2136 if(!memcmp(oub, "???????", sizeof("\342\200\223") -1))
2137 return 12;
2138 if(!memcmp(oub, "*******", sizeof("\342\200\223") -1))
2139 return 13;
2140 return 1;
2142 return 0;
2145 < ${tmp2}.c link_check iconv 'iconv(3) functionality' \
2146 '#define HAVE_ICONV' ||
2147 < ${tmp2}.c link_check iconv 'iconv(3) functionality (via -liconv)' \
2148 '#define HAVE_ICONV' '-liconv' ||
2149 feat_bail_required ICONV
2151 if feat_no CROSS_BUILD; then
2152 { ${tmp}; } >/dev/null 2>&1
2153 case ${?} in
2154 2) echo 'MAILX_ICONV_MODE=2;export MAILX_ICONV_MODE;' >> ${ev};;
2155 3) echo 'MAILX_ICONV_MODE=3;export MAILX_ICONV_MODE;' >> ${ev};;
2156 12) echo 'MAILX_ICONV_MODE=12;export MAILX_ICONV_MODE;' >> ${ev};;
2157 13) echo 'MAILX_ICONV_MODE=13;export MAILX_ICONV_MODE;' >> ${ev};;
2158 *) msg 'WARN: will restrict iconv(3) tests due to unknown replacement';;
2159 esac
2161 else
2162 feat_is_disabled ICONV
2163 fi # feat_yes ICONV
2165 if feat_yes SOCKETS || feat_yes SPAM_SPAMD; then
2166 ${cat} > ${tmp2}.c << \!
2167 #include <sys/types.h>
2168 #include <sys/socket.h>
2169 #include <sys/un.h>
2170 # include <errno.h>
2171 int main(void){
2172 struct sockaddr_un soun;
2174 if(socket(AF_UNIX, SOCK_STREAM, 0) == -1 && errno == ENOSYS)
2175 return 1;
2176 if(connect(0, (struct sockaddr*)&soun, 0) == -1 && errno == ENOSYS)
2177 return 1;
2178 if(shutdown(0, SHUT_RD | SHUT_WR | SHUT_RDWR) == -1 && errno == ENOSYS)
2179 return 1;
2180 return 0;
2184 < ${tmp2}.c run_check af_unix 'AF_UNIX sockets' \
2185 '#define HAVE_UNIX_SOCKETS' ||
2186 < ${tmp2}.c run_check af_unix 'AF_UNIX sockets (via -lnsl)' \
2187 '#define HAVE_UNIX_SOCKETS' '-lnsl' ||
2188 < ${tmp2}.c run_check af_unix 'AF_UNIX sockets (via -lsocket -lnsl)' \
2189 '#define HAVE_UNIX_SOCKETS' '-lsocket -lnsl'
2192 if feat_yes SOCKETS; then
2193 ${cat} > ${tmp2}.c << \!
2194 #include <sys/types.h>
2195 #include <sys/socket.h>
2196 #include <netinet/in.h>
2197 # include <errno.h>
2198 int main(void){
2199 struct sockaddr s;
2201 if(socket(AF_INET, SOCK_STREAM, 0) == -1 && errno == ENOSYS)
2202 return 1;
2203 if(connect(0, &s, 0) == -1 && errno == ENOSYS)
2204 return 1;
2205 return 0;
2209 < ${tmp2}.c run_check sockets 'sockets' \
2210 '#define HAVE_SOCKETS' ||
2211 < ${tmp2}.c run_check sockets 'sockets (via -lnsl)' \
2212 '#define HAVE_SOCKETS' '-lnsl' ||
2213 < ${tmp2}.c run_check sockets 'sockets (via -lsocket -lnsl)' \
2214 '#define HAVE_SOCKETS' '-lsocket -lnsl' ||
2215 feat_bail_required SOCKETS
2216 else
2217 feat_is_disabled SOCKETS
2218 fi # feat_yes SOCKETS
2220 feat_yes SOCKETS &&
2221 link_check sockopt '[gs]etsockopt(2)' '#define HAVE_SOCKOPT' << \!
2222 #include <sys/socket.h>
2223 #include <stdlib.h>
2224 # include <errno.h>
2225 int main(void){
2226 socklen_t sol;
2227 int sockfd = 3, soe;
2229 sol = sizeof soe;
2230 if(getsockopt(sockfd, SOL_SOCKET, SO_ERROR, &soe, &sol) == -1 &&
2231 errno == ENOSYS)
2232 return 1;
2233 if(setsockopt(sockfd, SOL_SOCKET, SO_KEEPALIVE, NULL, 0) == -1 &&
2234 errno == ENOSYS)
2235 return 1;
2236 return 0;
2240 feat_yes SOCKETS &&
2241 link_check nonblocksock 'non-blocking sockets' \
2242 '#define HAVE_NONBLOCKSOCK' << \!
2243 #include <sys/types.h>
2244 #include <sys/select.h>
2245 #include <sys/socket.h>
2246 #include <sys/time.h>
2247 #include <arpa/inet.h>
2248 #include <netinet/in.h>
2249 #include <fcntl.h>
2250 #include <stdlib.h>
2251 #include <unistd.h>
2252 # include <errno.h>
2253 int main(void){
2254 fd_set fdset;
2255 struct timeval tv;
2256 struct sockaddr_in sin;
2257 socklen_t sol;
2258 int sofd, soe;
2260 if((sofd = socket(AF_INET, SOCK_STREAM, 0)) == -1 && errno == ENOSYS)
2261 return 1;
2262 if(fcntl(sofd, F_SETFL, O_NONBLOCK) != 0)
2263 return 1;
2265 sin.sin_family = AF_INET;
2266 sin.sin_addr.s_addr = inet_addr("127.0.0.1");
2267 sin.sin_port = htons(80);
2268 if(connect(sofd, &sin, sizeof sin) == -1 && errno == ENOSYS)
2269 return 1;
2271 FD_ZERO(&fdset);
2272 FD_SET(sofd, &fdset);
2273 tv.tv_sec = 10;
2274 tv.tv_usec = 0;
2275 if((soe = select(sofd + 1, NULL, &fdset, NULL, &tv)) == 1){
2276 sol = sizeof soe;
2277 getsockopt(sofd, SOL_SOCKET, SO_ERROR, &soe, &sol);
2278 if(soe == 0)
2279 return 0;
2280 }else if(soe == -1 && errno == ENOSYS)
2281 return 1;
2283 close(sofd);
2284 return 0;
2288 if feat_yes SOCKETS; then
2289 link_check getaddrinfo 'getaddrinfo(3)' \
2290 '#define HAVE_GETADDRINFO' << \!
2291 #include <sys/types.h>
2292 #include <sys/socket.h>
2293 #include <stdio.h>
2294 #include <netdb.h>
2295 int main(void){
2296 struct addrinfo a, *ap;
2297 int lrv;
2299 switch((lrv = getaddrinfo("foo", "0", &a, &ap))){
2300 case EAI_NONAME:
2301 case EAI_SERVICE:
2302 default:
2303 fprintf(stderr, "%s\n", gai_strerror(lrv));
2304 case 0:
2305 break;
2307 return 0;
2312 if feat_yes SOCKETS && [ -z "${have_getaddrinfo}" ]; then
2313 compile_check arpa_inet_h '<arpa/inet.h>' \
2314 '#define HAVE_ARPA_INET_H' << \!
2315 #include <sys/types.h>
2316 #include <sys/socket.h>
2317 #include <netdb.h>
2318 #include <netinet/in.h>
2319 #include <arpa/inet.h>
2322 ${cat} > ${tmp2}.c << \!
2323 #include <sys/types.h>
2324 #include <sys/socket.h>
2325 #include <stdio.h>
2326 #include <string.h>
2327 #include <netdb.h>
2328 #include <netinet/in.h>
2329 #ifdef HAVE_ARPA_INET_H
2330 #include <arpa/inet.h>
2331 #endif
2332 int main(void){
2333 struct sockaddr_in servaddr;
2334 unsigned short portno;
2335 struct servent *ep;
2336 struct hostent *hp;
2337 struct in_addr **pptr;
2339 portno = 0;
2340 if((ep = getservbyname("POPPY-PORT", "tcp")) != NULL)
2341 portno = (unsigned short)ep->s_port;
2343 if((hp = gethostbyname("POPPY-HOST")) != NULL){
2344 pptr = (struct in_addr**)hp->h_addr_list;
2345 if(hp->h_addrtype != AF_INET)
2346 fprintf(stderr, "au\n");
2347 }else{
2348 switch(h_errno){
2349 case HOST_NOT_FOUND:
2350 case TRY_AGAIN:
2351 case NO_RECOVERY:
2352 case NO_DATA:
2353 break;
2354 default:
2355 fprintf(stderr, "au\n");
2356 break;
2360 memset(&servaddr, 0, sizeof servaddr);
2361 servaddr.sin_family = AF_INET;
2362 servaddr.sin_port = htons(portno);
2363 memcpy(&servaddr.sin_addr, *pptr, sizeof(struct in_addr));
2364 fprintf(stderr, "Would connect to %s:%d ...\n",
2365 inet_ntoa(**pptr), (int)portno);
2366 return 0;
2370 < ${tmp2}.c link_check gethostbyname 'get(serv|host)byname(3)' ||
2371 < ${tmp2}.c link_check gethostbyname \
2372 'get(serv|host)byname(3) (via -nsl)' '' '-lnsl' ||
2373 < ${tmp2}.c link_check gethostbyname \
2374 'get(serv|host)byname(3) (via -lsocket -nsl)' \
2375 '' '-lsocket -lnsl' ||
2376 feat_bail_required SOCKETS
2379 feat_yes SOCKETS && [ -n "${have_sockopt}" ] &&
2380 link_check so_xtimeo 'SO_{RCV,SND}TIMEO' '#define HAVE_SO_XTIMEO' << \!
2381 #include <sys/socket.h>
2382 #include <stdlib.h>
2383 int main(void){
2384 struct timeval tv;
2385 int sockfd = 3;
2387 tv.tv_sec = 42;
2388 tv.tv_usec = 21;
2389 setsockopt(sockfd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof tv);
2390 setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof tv);
2391 return 0;
2395 feat_yes SOCKETS && [ -n "${have_sockopt}" ] &&
2396 link_check so_linger 'SO_LINGER' '#define HAVE_SO_LINGER' << \!
2397 #include <sys/socket.h>
2398 #include <stdlib.h>
2399 int main(void){
2400 struct linger li;
2401 int sockfd = 3;
2403 li.l_onoff = 1;
2404 li.l_linger = 42;
2405 setsockopt(sockfd, SOL_SOCKET, SO_LINGER, &li, sizeof li);
2406 return 0;
2410 VAL_SSL_FEATURES=
2411 if feat_yes SSL; then # {{{
2412 # {{{ LibreSSL decided to define OPENSSL_VERSION_NUMBER with a useless value
2413 # instead of keeping it at the one that corresponds to the OpenSSL at fork
2414 # time: we need to test it first in order to get things right
2415 if compile_check _xssl 'TLS/SSL (LibreSSL)' \
2416 '#define HAVE_SSL
2417 #define HAVE_XSSL
2418 #define HAVE_XSSL_RESSL
2419 #define HAVE_XSSL_OPENSSL 0' << \!
2420 #include <openssl/opensslv.h>
2421 #ifdef LIBRESSL_VERSION_NUMBER
2422 #else
2423 # error nope
2424 #endif
2426 then
2427 ossl_v1_1=
2428 VAL_SSL_FEATURES=libressl
2429 # TODO OPENSSL_IS_BORINGSSL, but never tried that one!
2430 elif compile_check _xssl 'TLS/SSL (OpenSSL >= v1.1.0)' \
2431 '#define HAVE_SSL
2432 #define HAVE_XSSL
2433 #define HAVE_XSSL_OPENSSL 0x10100' << \!
2434 #include <openssl/opensslv.h>
2435 #if OPENSSL_VERSION_NUMBER + 0 >= 0x10100000L
2436 #else
2437 # error nope
2438 #endif
2440 then
2441 ossl_v1_1=1
2442 VAL_SSL_FEATURES=libssl-0x10100
2443 elif compile_check _xssl 'TLS/SSL (OpenSSL)' \
2444 '#define HAVE_SSL
2445 #define HAVE_XSSL
2446 #define HAVE_XSSL_OPENSSL 0x10000' << \!
2447 #include <openssl/opensslv.h>
2448 #ifdef OPENSSL_VERSION_NUMBER
2449 #else
2450 # error nope
2451 #endif
2453 then
2454 ossl_v1_1=
2455 VAL_SSL_FEATURES=libssl-0x10000
2456 else
2457 feat_bail_required SSL
2458 fi # }}}
2460 if feat_yes SSL; then # {{{
2461 if [ -n "${ossl_v1_1}" ]; then
2462 without_check yes xssl 'TLS/SSL new style TLS_client_method(3ssl)' \
2463 '#define n_XSSL_CLIENT_METHOD TLS_client_method' \
2464 '-lssl -lcrypto'
2465 elif link_check xssl 'TLS/SSL new style TLS_client_method(3ssl)' \
2466 '#define n_XSSL_CLIENT_METHOD TLS_client_method' \
2467 '-lssl -lcrypto' << \!
2468 #include <openssl/ssl.h>
2469 #include <openssl/err.h>
2470 #include <openssl/x509v3.h>
2471 #include <openssl/x509.h>
2472 #include <openssl/rand.h>
2473 #ifdef OPENSSL_NO_TLS1 /* TODO only deduced from OPENSSL_NO_SSL[23]! */
2474 # error We need TLSv1.
2475 #endif
2476 int main(void){
2477 SSL_CTX *ctx = SSL_CTX_new(TLS_client_method());
2479 SSL_CTX_free(ctx);
2480 PEM_read_PrivateKey(0, 0, 0, 0);
2481 return 0;
2484 then
2486 elif link_check xssl 'TLS/SSL old style SSLv23_client_method(3ssl)' \
2487 '#define n_XSSL_CLIENT_METHOD SSLv23_client_method' \
2488 '-lssl -lcrypto' << \!
2489 #include <openssl/ssl.h>
2490 #include <openssl/err.h>
2491 #include <openssl/x509v3.h>
2492 #include <openssl/x509.h>
2493 #include <openssl/rand.h>
2494 #if defined OPENSSL_NO_SSL3 &&\
2495 defined OPENSSL_NO_TLS1 /* TODO only deduced from OPENSSL_NO_SSL[23]! */
2496 # error We need one of SSLv3 and TLSv1.
2497 #endif
2498 int main(void){
2499 SSL_CTX *ctx = SSL_CTX_new(SSLv23_client_method());
2501 SSL_CTX_free(ctx);
2502 PEM_read_PrivateKey(0, 0, 0, 0);
2503 return 0;
2506 then
2508 else
2509 feat_bail_required SSL
2511 fi # }}}
2513 if feat_yes SSL; then # {{{
2514 if feat_yes SSL_ALL_ALGORITHMS; then
2515 if [ -n "${ossl_v1_1}" ]; then
2516 without_check yes ssl_all_algo 'TLS/SSL all-algorithms support' \
2517 '#define HAVE_SSL_ALL_ALGORITHMS'
2518 elif link_check ssl_all_algo 'TLS/SSL all-algorithms support' \
2519 '#define HAVE_SSL_ALL_ALGORITHMS' << \!
2520 #include <openssl/evp.h>
2521 int main(void){
2522 OpenSSL_add_all_algorithms();
2523 EVP_get_cipherbyname("two cents i never exist");
2524 EVP_cleanup();
2525 return 0;
2528 then
2530 else
2531 feat_bail_required SSL_ALL_ALGORITHMS
2533 elif [ -n "${ossl_v1_1}" ]; then
2534 without_check yes ssl_all_algo \
2535 'TLS/SSL all-algorithms (always available in v1.1.0+)' \
2536 '#define HAVE_SSL_ALL_ALGORITHMS'
2539 if [ -n "${ossl_v1_1}" ]; then
2540 without_check yes xssl_stack_of 'TLS/SSL STACK_OF()' \
2541 '#define HAVE_XSSL_STACK_OF'
2542 elif compile_check xssl_stack_of 'TLS/SSL STACK_OF()' \
2543 '#define HAVE_XSSL_STACK_OF' << \!
2544 #include <stdio.h> /* For C89 NULL */
2545 #include <openssl/ssl.h>
2546 #include <openssl/err.h>
2547 #include <openssl/x509v3.h>
2548 #include <openssl/x509.h>
2549 #include <openssl/rand.h>
2550 int main(void){
2551 STACK_OF(GENERAL_NAME) *gens = NULL;
2553 printf("%p", gens); /* to use it */
2554 return 0;
2557 then
2561 if [ -n "${ossl_v1_1}" ]; then
2562 without_check yes xssl_conf 'TLS/SSL OpenSSL_modules_load_file(3ssl)' \
2563 '#define HAVE_XSSL_CONFIG'
2564 VAL_SSL_FEATURES="${VAL_SSL_FEATURES},+modules-load-file"
2565 elif link_check xssl_conf \
2566 'TLS/SSL OpenSSL_modules_load_file(3ssl) support' \
2567 '#define HAVE_XSSL_CONFIG' << \!
2568 #include <stdio.h> /* For C89 NULL */
2569 #include <openssl/conf.h>
2570 int main(void){
2571 CONF_modules_load_file(NULL, NULL, CONF_MFLAGS_IGNORE_MISSING_FILE);
2572 CONF_modules_free();
2573 return 0;
2576 then
2577 VAL_SSL_FEATURES="${VAL_SSL_FEATURES},+modules-load-file"
2578 else
2579 VAL_SSL_FEATURES="${VAL_SSL_FEATURES},-modules-load-file"
2582 if [ -n "${ossl_v1_1}" ]; then
2583 without_check yes xssl_conf_ctx 'TLS/SSL SSL_CONF_CTX support' \
2584 '#define HAVE_XSSL_CONF_CTX'
2585 VAL_SSL_FEATURES="${VAL_SSL_FEATURES},+conf-ctx"
2586 elif link_check xssl_conf_ctx 'TLS/SSL SSL_CONF_CTX support' \
2587 '#define HAVE_XSSL_CONF_CTX' << \!
2588 #include <openssl/ssl.h>
2589 #include <openssl/err.h>
2590 int main(void){
2591 SSL_CTX *ctx = SSL_CTX_new(n_XSSL_CLIENT_METHOD());
2592 SSL_CONF_CTX *cctx = SSL_CONF_CTX_new();
2594 SSL_CONF_CTX_set_flags(cctx,
2595 SSL_CONF_FLAG_FILE | SSL_CONF_FLAG_CLIENT |
2596 SSL_CONF_FLAG_CERTIFICATE | SSL_CONF_FLAG_SHOW_ERRORS);
2597 SSL_CONF_CTX_set_ssl_ctx(cctx, ctx);
2598 SSL_CONF_cmd(cctx, "Protocol", "ALL");
2599 SSL_CONF_CTX_finish(cctx);
2600 SSL_CONF_CTX_free(cctx);
2601 SSL_CTX_free(ctx);
2602 return 0;
2605 then
2606 VAL_SSL_FEATURES="${VAL_SSL_FEATURES},+conf-ctx"
2607 else
2608 VAL_SSL_FEATURES="${VAL_SSL_FEATURES},-conf-ctx"
2611 if [ -n "${ossl_v1_1}" ]; then
2612 without_check yes xssl_ctx_config 'TLS/SSL SSL_CTX_config(3ssl)' \
2613 '#define HAVE_XSSL_CTX_CONFIG'
2614 VAL_SSL_FEATURES="${VAL_SSL_FEATURES},+ctx-config"
2615 elif [ -n "${have_xssl_conf}" ] && [ -n "${have_xssl_conf_ctx}" ] &&
2616 link_check xssl_ctx_config 'TLS/SSL SSL_CTX_config(3ssl)' \
2617 '#define HAVE_XSSL_CTX_CONFIG' << \!
2618 #include <stdio.h> /* For C89 NULL */
2619 #include <openssl/ssl.h>
2620 int main(void){
2621 SSL_CTX_config(NULL, "SOMEVAL");
2622 return 0;
2625 then
2626 VAL_SSL_FEATURES="${VAL_SSL_FEATURES},+ctx-config"
2627 else
2628 VAL_SSL_FEATURES="${VAL_SSL_FEATURES},-ctx-config"
2631 if [ -n "${ossl_v1_1}" ] && [ -n "${have_xssl_conf_ctx}" ]; then
2632 without_check yes xssl_set_maxmin_proto \
2633 'TLS/SSL SSL_CTX_set_min_proto_version(3ssl)' \
2634 '#define HAVE_XSSL_SET_MIN_PROTO_VERSION'
2635 VAL_SSL_FEATURES="${VAL_SSL_FEATURES},+ctx-set-maxmin-proto"
2636 elif link_check xssl_set_maxmin_proto \
2637 'TLS/SSL SSL_CTX_set_min_proto_version(3ssl)' \
2638 '#define HAVE_XSSL_SET_MIN_PROTO_VERSION' << \!
2639 #include <stdio.h> /* For C89 NULL */
2640 #include <openssl/ssl.h>
2641 int main(void){
2642 SSL_CTX_set_min_proto_version(NULL, 0);
2643 SSL_CTX_set_max_proto_version(NULL, 10);
2644 return 0;
2647 then
2648 VAL_SSL_FEATURES="${VAL_SSL_FEATURES},+ctx-set-maxmin-proto"
2649 else
2650 VAL_SSL_FEATURES="${VAL_SSL_FEATURES},-ctx-set-maxmin-proto"
2653 if [ -n "${ossl_v1_1}" ] && [ -n "${have_xssl_conf_ctx}" ]; then
2654 without_check yes xssl_set_ciphersuites \
2655 'TLSv1.3 SSL_CTX_set_ciphersuites(3ssl)' \
2656 '#define HAVE_XSSL_SET_CIPHERSUITES'
2657 VAL_SSL_FEATURES="${VAL_SSL_FEATURES},+ctx-set-ciphersuites"
2658 elif link_check xssl_set_ciphersuites \
2659 'TLSv1.3 SSL_CTX_set_ciphersuites(3ssl)' \
2660 '#define HAVE_XSSL_SET_CIPHERSUITES' << \!
2661 #include <stdio.h> /* For C89 NULL */
2662 #include <openssl/ssl.h>
2663 int main(void){
2664 SSL_CTX_set_ciphersuites(NULL, NULL);
2665 return 0;
2668 then
2669 VAL_SSL_FEATURES="${VAL_SSL_FEATURES},+ctx-set-ciphersuites"
2670 else
2671 VAL_SSL_FEATURES="${VAL_SSL_FEATURES},-ctx-set-ciphersuites"
2674 if link_check xssl_rand_egd 'TLS/SSL RAND_egd(3ssl)' \
2675 '#define HAVE_XSSL_RAND_EGD' << \!
2676 #include <openssl/rand.h>
2677 int main(void){
2678 return RAND_egd("some.where") > 0;
2681 then
2682 VAL_SSL_FEATURES="${VAL_SSL_FEATURES},+rand-egd"
2683 else
2684 VAL_SSL_FEATURES="${VAL_SSL_FEATURES},-rand-egd"
2686 fi # feat_yes SSL }}}
2688 if feat_yes SSL && feat_yes MD5 && feat_no NOEXTMD5; then # {{{
2689 run_check ssl_md5 'MD5 digest in the used crypto library' \
2690 '#define HAVE_XSSL_MD5' << \!
2691 #include <stdlib.h>
2692 #include <string.h>
2693 #include <openssl/md5.h>
2694 int main(void){
2695 char const dat[] = "abrakadabrafidibus";
2696 char dig[16], hex[16 * 2];
2697 MD5_CTX ctx;
2698 size_t i, j;
2700 memset(dig, 0, sizeof(dig));
2701 memset(hex, 0, sizeof(hex));
2702 MD5_Init(&ctx);
2703 MD5_Update(&ctx, dat, sizeof(dat) - 1);
2704 MD5_Final(dig, &ctx);
2706 #define hexchar(n) ((n) > 9 ? (n) - 10 + 'a' : (n) + '0')
2707 for(i = 0; i < sizeof(hex) / 2; i++){
2708 j = i << 1;
2709 hex[j] = hexchar((dig[i] & 0xf0) >> 4);
2710 hex[++j] = hexchar(dig[i] & 0x0f);
2712 return !!memcmp("6d7d0a3d949da2e96f2aa010f65d8326", hex, sizeof(hex));
2715 fi # }}}
2717 if feat_yes SSL; then
2718 feat_def SSL_ALL_ALGORITHMS
2719 else
2720 feat_bail_required SSL_ALL_ALGORITHMS
2722 else
2723 feat_is_disabled SSL
2724 feat_is_disabled SSL_ALL_ALGORITHMS
2725 fi # }}} feat_yes SSL
2726 printf '#define VAL_SSL_FEATURES "#'"${VAL_SSL_FEATURES}"'"\n' >> ${h}
2728 if [ "${have_xssl}" = yes ]; then
2729 OPT_SMIME=1
2730 else
2731 OPT_SMIME=0
2733 feat_def SMIME
2735 # VAL_RANDOM {{{
2736 if val_allof VAL_RANDOM \
2737 "arc4,ssl,libgetrandom,sysgetrandom,urandom,builtin,error"; then
2739 else
2740 msg 'ERROR: VAL_RANDOM with invalid entries: %s' "${VAL_RANDOM}"
2741 config_exit 1
2744 val_random_arc4() {
2745 link_check arc4random 'VAL_RANDOM: arc4random(3)' \
2746 '#define HAVE_RANDOM n_RANDOM_IMPL_ARC4' << \!
2747 #include <stdlib.h>
2748 int main(void){
2749 arc4random();
2750 return 0;
2755 val_random_ssl() {
2756 if feat_yes SSL; then
2757 msg ' . VAL_RANDOM: ssl ... yes'
2758 echo '#define HAVE_RANDOM n_RANDOM_IMPL_SSL' >> ${h}
2759 return 0
2760 else
2761 msg ' . VAL_RANDOM: ssl ... no'
2762 return 1
2766 val_random_libgetrandom() {
2767 link_check getrandom 'VAL_RANDOM: getrandom(3) (in sys/random.h)' \
2768 '#define HAVE_RANDOM n_RANDOM_IMPL_GETRANDOM
2769 #define n_RANDOM_GETRANDOM_FUN(B,S) getrandom(B, S, 0)
2770 #define n_RANDOM_GETRANDOM_H <sys/random.h>' <<\!
2771 #include <sys/random.h>
2772 int main(void){
2773 char buf[256];
2774 getrandom(buf, sizeof buf, 0);
2775 return 0;
2780 val_random_sysgetrandom() {
2781 link_check getrandom 'VAL_RANDOM: getrandom(2) (via syscall(2))' \
2782 '#define HAVE_RANDOM n_RANDOM_IMPL_GETRANDOM
2783 #define n_RANDOM_GETRANDOM_FUN(B,S) syscall(SYS_getrandom, B, S, 0)
2784 #define n_RANDOM_GETRANDOM_H <sys/syscall.h>' <<\!
2785 #include <sys/syscall.h>
2786 int main(void){
2787 char buf[256];
2788 syscall(SYS_getrandom, buf, sizeof buf, 0);
2789 return 0;
2794 val_random_urandom() {
2795 msg_nonl ' . VAL_RANDOM: /dev/urandom ... '
2796 if feat_yes CROSS_BUILD; then
2797 msg 'yes (unchecked)'
2798 echo '#define HAVE_RANDOM n_RANDOM_IMPL_URANDOM' >> ${h}
2799 elif [ -f /dev/urandom ]; then
2800 msg yes
2801 echo '#define HAVE_RANDOM n_RANDOM_IMPL_URANDOM' >> ${h}
2802 else
2803 msg no
2804 return 1
2806 return 0
2809 val_random_builtin() {
2810 msg_nonl ' . VAL_RANDOM: builtin ... '
2811 if [ -n "${have_no_subsecond_time}" ]; then
2812 msg 'no\nERROR: %s %s' 'without a specialized PRG ' \
2813 'one of clock_gettime(2) and gettimeofday(2) is required.'
2814 config_exit 1
2815 else
2816 msg yes
2817 echo '#define HAVE_RANDOM n_RANDOM_IMPL_BUILTIN' >> ${h}
2821 val_random_error() {
2822 msg 'ERROR: VAL_RANDOM search reached "error" entry'
2823 config_exit 42
2826 oifs=${IFS}
2827 IFS=", "
2828 VAL_RANDOM="${VAL_RANDOM},error"
2829 set -- ${VAL_RANDOM}
2830 IFS=${oifs}
2831 for randfun
2833 eval val_random_$randfun && break
2834 done
2835 # }}} VAL_RANDOM
2837 feat_def SMTP
2838 feat_def POP3
2839 feat_def IMAP
2841 if feat_yes GSSAPI; then
2842 ${cat} > ${tmp2}.c << \!
2843 #include <gssapi/gssapi.h>
2844 int main(void){
2845 gss_import_name(0, 0, GSS_C_NT_HOSTBASED_SERVICE, 0);
2846 gss_init_sec_context(0,0,0,0,0,0,0,0,0,0,0,0,0);
2847 return 0;
2850 ${sed} -e '1s/gssapi\///' < ${tmp2}.c > ${tmp3}.c
2852 if acmd_set i krb5-config; then
2853 GSS_LIBS="`CFLAGS= ${i} --libs gssapi`"
2854 GSS_INCS="`CFLAGS= ${i} --cflags`"
2855 i='GSS-API via krb5-config(1)'
2856 else
2857 GSS_LIBS='-lgssapi'
2858 GSS_INCS=
2859 i='GSS-API in gssapi/gssapi.h, libgssapi'
2861 if < ${tmp2}.c link_check gss \
2862 "${i}" '#define HAVE_GSSAPI' "${GSS_LIBS}" "${GSS_INCS}" ||\
2863 < ${tmp3}.c link_check gss \
2864 'GSS-API in gssapi.h, libgssapi' \
2865 '#define HAVE_GSSAPI
2866 #define GSSAPI_REG_INCLUDE' \
2867 '-lgssapi' ||\
2868 < ${tmp2}.c link_check gss 'GSS-API in libgssapi_krb5' \
2869 '#define HAVE_GSSAPI' \
2870 '-lgssapi_krb5' ||\
2871 < ${tmp3}.c link_check gss \
2872 'GSS-API in libgssapi, OpenBSD-style (pre 5.3)' \
2873 '#define HAVE_GSSAPI
2874 #define GSS_REG_INCLUDE' \
2875 '-lgssapi -lkrb5 -lcrypto' \
2876 '-I/usr/include/kerberosV' ||\
2877 < ${tmp2}.c link_check gss 'GSS-API in libgss' \
2878 '#define HAVE_GSSAPI' \
2879 '-lgss' ||\
2880 link_check gss 'GSS-API in libgssapi_krb5, old-style' \
2881 '#define HAVE_GSSAPI
2882 #define GSSAPI_OLD_STYLE' \
2883 '-lgssapi_krb5' << \!
2884 #include <gssapi/gssapi.h>
2885 #include <gssapi/gssapi_generic.h>
2886 int main(void){
2887 gss_import_name(0, 0, gss_nt_service_name, 0);
2888 gss_init_sec_context(0,0,0,0,0,0,0,0,0,0,0,0,0);
2889 return 0;
2892 then
2894 else
2895 feat_bail_required GSSAPI
2897 else
2898 feat_is_disabled GSSAPI
2899 fi # feat_yes GSSAPI
2901 feat_def NETRC
2902 feat_def AGENT
2904 if feat_yes IDNA; then # {{{
2905 if val_allof VAL_IDNA "idnkit,idn2,idn"; then
2907 else
2908 msg 'ERROR: VAL_IDNA with invalid entries: %s' "${VAL_IDNA}"
2909 config_exit 1
2912 val_idna_idn2() {
2913 link_check idna 'OPT_IDNA: GNU Libidn2' \
2914 '#define HAVE_IDNA n_IDNA_IMPL_LIBIDN2' '-lidn2' << \!
2915 #include <idn2.h>
2916 int main(void){
2917 char *idna_utf8, *idna_lc;
2919 if(idn2_to_ascii_8z("does.this.work", &idna_utf8,
2920 IDN2_NONTRANSITIONAL | IDN2_TRANSITIONAL) != IDN2_OK)
2921 return 1;
2922 if(idn2_to_unicode_8zlz(idna_utf8, &idna_lc, 0) != IDN2_OK)
2923 return 1;
2924 idn2_free(idna_lc);
2925 idn2_free(idna_utf8);
2926 return 0;
2931 val_idna_idn() {
2932 link_check idna 'OPT_IDNA: GNU Libidn' \
2933 '#define HAVE_IDNA n_IDNA_IMPL_LIBIDN' '-lidn' << \!
2934 #include <idna.h>
2935 #include <idn-free.h>
2936 #include <stringprep.h> /* XXX we actually use our own iconv instead */
2937 int main(void){
2938 char *utf8, *idna_ascii, *idna_utf8;
2940 utf8 = stringprep_locale_to_utf8("does.this.work");
2941 if (idna_to_ascii_8z(utf8, &idna_ascii, IDNA_USE_STD3_ASCII_RULES)
2942 != IDNA_SUCCESS)
2943 return 1;
2944 idn_free(idna_ascii);
2945 /* (Rather link check only here) */
2946 idna_utf8 = stringprep_convert(idna_ascii, "UTF-8", "de_DE");
2947 return 0;
2952 val_idna_idnkit() {
2953 link_check idna 'OPT_IDNA: idnkit' \
2954 '#define HAVE_IDNA n_IDNA_IMPL_IDNKIT' '-lidnkit' << \!
2955 #include <stdio.h>
2956 #include <idn/api.h>
2957 #include <idn/result.h>
2958 int main(void){
2959 idn_result_t r;
2960 char ace_name[256];
2961 char local_name[256];
2963 r = idn_encodename(IDN_ENCODE_APP, "does.this.work", ace_name,
2964 sizeof(ace_name));
2965 if (r != idn_success) {
2966 fprintf(stderr, "idn_encodename failed: %s\n", idn_result_tostring(r));
2967 return 1;
2969 r = idn_decodename(IDN_DECODE_APP, ace_name, local_name, sizeof(local_name));
2970 if (r != idn_success) {
2971 fprintf(stderr, "idn_decodename failed: %s\n", idn_result_tostring(r));
2972 return 1;
2974 return 0;
2979 val_idna_bye() {
2980 feat_bail_required IDNA
2983 oifs=${IFS}
2984 IFS=", "
2985 VAL_IDNA="${VAL_IDNA},bye"
2986 set -- ${VAL_IDNA}
2987 IFS=${oifs}
2988 for randfun
2990 eval val_idna_$randfun && break
2991 done
2992 else
2993 feat_is_disabled IDNA
2994 fi # }}} IDNA
2996 feat_def IMAP_SEARCH
2998 if feat_yes REGEX; then
2999 if link_check regex 'regular expressions' '#define HAVE_REGEX' << \!
3000 #include <regex.h>
3001 #include <stdlib.h>
3002 int main(void){
3003 size_t xret;
3004 int status;
3005 regex_t re;
3007 status = regcomp(&re, ".*bsd", REG_EXTENDED | REG_ICASE | REG_NOSUB);
3008 xret = regerror(status, &re, NULL, 0);
3009 status = regexec(&re, "plan9", 0,NULL, 0);
3010 regfree(&re);
3011 return !(status == REG_NOMATCH);
3014 then
3016 else
3017 feat_bail_required REGEX
3019 else
3020 feat_is_disabled REGEX
3023 if feat_yes MLE; then
3024 if [ -n "${have_c90amend1}" ]; then
3025 have_mle=1
3026 echo '#define HAVE_MLE' >> ${h}
3027 else
3028 feat_bail_required MLE
3030 else
3031 feat_is_disabled MLE
3034 # Generic have-a-line-editor switch for those who need it below
3035 if [ -n "${have_mle}" ]; then
3036 have_cle=1
3039 if feat_yes HISTORY; then
3040 if [ -n "${have_cle}" ]; then
3041 echo '#define HAVE_HISTORY' >> ${h}
3042 else
3043 feat_is_unsupported HISTORY
3045 else
3046 feat_is_disabled HISTORY
3049 if feat_yes KEY_BINDINGS; then
3050 if [ -n "${have_mle}" ]; then
3051 echo '#define HAVE_KEY_BINDINGS' >> ${h}
3052 else
3053 feat_is_unsupported KEY_BINDINGS
3055 else
3056 feat_is_disabled KEY_BINDINGS
3059 if feat_yes TERMCAP; then # {{{
3060 ADDINC=
3061 __termcaplib() {
3062 link_check termcap "termcap(5) (via ${4}${ADDINC})" \
3063 "#define HAVE_TERMCAP${3}" "${1}" "${ADDINC}" << _EOT
3064 #include <stdio.h>
3065 #include <stdlib.h>
3066 ${2}
3067 #include <term.h>
3068 #define UNCONST(P) ((void*)(unsigned long)(void const*)(P))
3069 static int my_putc(int c){return putchar(c);}
3070 int main(void){
3071 char buf[1024+512], cmdbuf[2048], *cpb, *r1;
3072 int r2 = OK, r3 = ERR;
3074 tgetent(buf, getenv("TERM"));
3075 cpb = cmdbuf;
3076 r1 = tgetstr(UNCONST("cm"), &cpb);
3077 tgoto(r1, 1, 1);
3078 r2 = tgetnum(UNCONST("Co"));
3079 r3 = tgetflag(UNCONST("ut"));
3080 tputs("cr", 1, &my_putc);
3081 return (r1 == NULL || r2 == -1 || r3 == 0);
3083 _EOT
3086 __terminfolib() {
3087 link_check terminfo "terminfo(5) (via ${2}${ADDINC})" \
3088 '#define HAVE_TERMCAP
3089 #define HAVE_TERMCAP_CURSES
3090 #define HAVE_TERMINFO' "${1}" "${ADDINC}" << _EOT
3091 #include <stdio.h>
3092 #include <curses.h>
3093 #include <term.h>
3094 #define UNCONST(P) ((void*)(unsigned long)(void const*)(P))
3095 static int my_putc(int c){return putchar(c);}
3096 int main(void){
3097 int er, r0, r1, r2;
3098 char *r3, *tp;
3100 er = OK;
3101 r0 = setupterm(NULL, 1, &er);
3102 r1 = tigetflag(UNCONST("bce"));
3103 r2 = tigetnum(UNCONST("colors"));
3104 r3 = tigetstr(UNCONST("cr"));
3105 tp = tparm(r3, NULL, NULL, 0,0,0,0,0,0,0);
3106 tputs(tp, 1, &my_putc);
3107 return (r0 == ERR || r1 == -1 || r2 == -2 || r2 == -1 ||
3108 r3 == (char*)-1 || r3 == NULL);
3110 _EOT
3113 if feat_yes TERMCAP_VIA_TERMINFO; then
3114 ADDINC=
3115 do_me() {
3116 xbail=
3117 __terminfolib -ltinfo -ltinfo ||
3118 __terminfolib -lcurses -lcurses ||
3119 __terminfolib -lcursesw -lcursesw ||
3120 xbail=y
3122 do_me
3123 if [ -n "${xbail}" ] && [ -d /usr/local/include/ncurses ]; then
3124 ADDINC=' -I/usr/local/include/ncurses'
3125 do_me
3127 if [ -n "${xbail}" ] && [ -d /usr/include/ncurses ]; then
3128 ADDINC=' -I/usr/include/ncurses'
3129 do_me
3131 [ -n "${xbail}" ] && feat_bail_required TERMCAP_VIA_TERMINFO
3134 if [ -z "${have_terminfo}" ]; then
3135 ADDINC=
3136 do_me() {
3137 xbail=
3138 __termcaplib -ltermcap '' '' '-ltermcap' ||
3139 __termcaplib -ltermcap '#include <curses.h>' '
3140 #define HAVE_TERMCAP_CURSES' \
3141 'curses.h / -ltermcap' ||
3142 __termcaplib -lcurses '#include <curses.h>' '
3143 #define HAVE_TERMCAP_CURSES' \
3144 'curses.h / -lcurses' ||
3145 __termcaplib -lcursesw '#include <curses.h>' '
3146 #define HAVE_TERMCAP_CURSES' \
3147 'curses.h / -lcursesw' ||
3148 xbail=y
3150 do_me
3151 if [ -n "${xbail}" ] && [ -d /usr/local/include/ncurses ]; then
3152 ADDINC=' -I/usr/local/include/ncurses'
3153 do_me
3155 if [ -n "${xbail}" ] && [ -d /usr/include/ncurses ]; then
3156 ADDINC=' -I/usr/include/ncurses'
3157 do_me
3159 [ -n "${xbail}" ] && feat_bail_required TERMCAP
3161 if [ -n "${have_termcap}" ]; then
3162 run_check tgetent_null \
3163 "tgetent(3) of termcap(5) takes NULL buffer" \
3164 "#define HAVE_TGETENT_NULL_BUF" << _EOT
3165 #include <stdio.h> /* For C89 NULL */
3166 #include <stdlib.h>
3167 #ifdef HAVE_TERMCAP_CURSES
3168 # include <curses.h>
3169 #endif
3170 #include <term.h>
3171 int main(void){
3172 tgetent(NULL, getenv("TERM"));
3173 return 0;
3175 _EOT
3178 unset ADDINC
3179 else # }}}
3180 feat_is_disabled TERMCAP
3181 feat_is_disabled TERMCAP_VIA_TERMINFO
3184 if feat_def SPAM_SPAMC; then
3185 if acmd_set i spamc; then
3186 echo "#define SPAM_SPAMC_PATH \"${i}\"" >> ${h}
3190 if feat_yes SPAM_SPAMD; then
3191 if [ -n "${have_af_unix}" ]; then
3192 echo '#define HAVE_SPAM_SPAMD' >> ${h}
3193 else
3194 feat_bail_required SPAM_SPAMD
3196 else
3197 feat_is_disabled SPAM_SPAMD
3200 feat_def SPAM_FILTER
3202 if feat_yes SPAM_SPAMC || feat_yes SPAM_SPAMD || feat_yes SPAM_FILTER; then
3203 echo '#define HAVE_SPAM' >> ${h}
3204 else
3205 echo '/* HAVE_SPAM */' >> ${h}
3208 if feat_yes QUOTE_FOLD; then
3209 if [ -n "${have_c90amend1}" ] && [ -n "${have_wcwidth}" ]; then
3210 echo '#define HAVE_QUOTE_FOLD' >> ${h}
3211 else
3212 feat_bail_required QUOTE_FOLD
3214 else
3215 feat_is_disabled QUOTE_FOLD
3218 feat_def FILTER_HTML_TAGSOUP
3219 feat_def COLOUR
3220 feat_def DOTLOCK
3221 feat_def MD5
3223 ## Summarizing
3225 ${rm} -f ${tmp}
3226 squeeze_em ${inc} ${tmp}
3227 ${mv} ${tmp} ${inc}
3228 squeeze_em ${lib} ${tmp}
3229 ${mv} ${tmp} ${lib}
3231 echo "LIBS = `${cat} ${lib}`" >> ${mk}
3232 echo "INCS = `${cat} ${inc}`" >> ${mk}
3233 echo >> ${mk}
3235 # mk-config.h
3236 ${mv} ${h} ${tmp}
3237 printf '#ifndef n_MK_CONFIG_H\n# define n_MK_CONFIG_H 1\n' > ${h}
3238 ${cat} ${tmp} >> ${h}
3239 printf '\n' >> ${h}
3240 # We need these for correct "second stage configuration changed" detection */
3241 echo "/* `${cat} ${lib}` */" >> ${h}
3242 echo "/* `${cat} ${inc}` */" >> ${h}
3243 printf '\n' >> ${h}
3245 # Throw away all temporaries
3246 ${rm} -rf ${tmp0}.* ${tmp0}*
3248 # Create the string that is used by *features* and `version'.
3249 # Take this nice opportunity and generate a visual listing of included and
3250 # non-included features for the person who runs the configuration
3251 echo 'The following features are included (+) or not (-):' > ${tmp}
3252 set -- ${OPTIONS_DETECT} ${OPTIONS} ${OPTIONS_XTRA}
3253 printf '/* The "feature string" */\n' >> ${h}
3254 # Because + is expanded by *folder* if first in "echo $features", put something
3255 printf '#define VAL_FEATURES_CNT '${#}'\n#define VAL_FEATURES "#' >> ${h}
3256 sep=
3257 for opt
3259 sdoc=`option_doc_of ${opt}`
3260 [ -z "${sdoc}" ] && continue
3261 sopt="`echo ${opt} | ${tr} '[A-Z]_' '[a-z]-'`"
3262 feat_yes ${opt} && sign=+ || sign=-
3263 printf -- "${sep}${sign}${sopt}" >> ${h}
3264 sep=','
3265 printf ' %s %s: %s\n' ${sign} ${sopt} "${sdoc}" >> ${tmp}
3266 done
3267 # TODO instead of using sh+tr+awk+printf, use awk, drop option_doc_of, inc here
3268 #exec 5>&1 >>${h}
3269 #${awk} -v opts="${OPTIONS_DETECT} ${OPTIONS} ${OPTIONS_XTRA}" \
3270 # -v xopts="${XOPTIONS_DETECT} ${XOPTIONS} ${XOPTIONS_XTRA}" \
3271 printf '"\n' >> ${h}
3273 # Create the real mk-config.mk
3274 # Note we cannout use explicit ./ filename prefix for source and object
3275 # pathnames because of a bug in bmake(1)
3276 srclist= objlist=
3277 if feat_no AMALGAMATION; then
3278 for i in `printf '%s\n' "${SRCDIR}"*.c | ${sort}`; do
3279 i=`basename "${i}" .c`
3280 if [ "${i}" = privsep ]; then
3281 continue
3283 objlist="${objlist} ${i}.o"
3284 srclist="${srclist} \$(SRCDIR)${i}.c"
3285 printf '%s: %s\n\t$(ECHO_CC)$(CC) $(CFLAGS) $(INCS) -c %s\n' \
3286 "${i}.o" "\$(SRCDIR)${i}.c" "\$(SRCDIR)${i}.c" >> ${mk}
3287 done
3288 printf '\nAMALGAM_TARGET =\nAMALGAM_DEP =\n' >> ${mk}
3289 else
3290 printf '%s:\n\t$(ECHO_CC)$(CC) $(CFLAGS) $(INCS) -c $(SRCDIR)%s\n' \
3291 "main.o" "main.c" >> ${mk}
3292 srclist=main.c objlist=main.o
3293 printf '\nAMALGAM_TARGET = main.o\nAMALGAM_DEP = ' >> ${mk}
3295 printf '\n/* HAVE_AMALGAMATION: include sources */\n' >> ${h}
3296 printf '#elif n_MK_CONFIG_H + 0 == 1\n' >> ${h}
3297 printf '# undef n_MK_CONFIG_H\n' >> ${h}
3298 printf '# define n_MK_CONFIG_H 2\n' >> ${h}
3299 for i in `printf '%s\n' "${SRCDIR}"*.c | ${sort}`; do
3300 i=`basename "${i}"`
3301 if [ "${i}" = main.c ] ||
3302 [ "${i}" = privsep.c ]; then
3303 continue
3305 printf '$(SRCDIR)%s ' "${i}" >> ${mk}
3306 printf '# include "%s%s"\n' "${SRCDIR}" "${i}" >> ${h}
3307 done
3308 echo >> ${mk}
3310 printf 'OBJ_SRC = %s\nOBJ = %s\n' "${srclist}" "${objlist}" >> "${mk}"
3312 printf '#endif /* n_MK_CONFIG_H */\n' >> ${h}
3314 echo >> ${mk}
3315 ${cat} "${SRCDIR}"make-config.in >> ${mk}
3317 ## Finished!
3319 # We have completed the new configuration header. Check whether *really*
3320 # Do the "second stage configuration changed" detection, exit if nothing to do
3321 if [ -f ${oldh} ]; then
3322 if ${cmp} ${h} ${oldh} >/dev/null 2>&1; then
3323 ${mv} -f ${oldh} ${h}
3324 msg 'Effective configuration is up-to-date'
3325 exit 0
3327 config_updated=1
3328 ${rm} -f ${oldh}
3329 msg 'Effective configuration has been updated..'
3332 if [ -n "${config_updated}" ]; then
3333 msg 'Wiping away old objects and such..'
3334 ( cd .obj; oldmk=`${basename} ${oldmk}`; ${MAKE} -f ${oldmk} clean )
3337 msg ''
3338 while read l; do msg "${l}"; done < ${tmp}
3340 msg 'Setup:'
3341 msg ' . System-wide resource file: %s/%s' "${VAL_SYSCONFDIR}" "${VAL_SYSCONFRC}"
3342 msg ' . bindir: %s' "${VAL_BINDIR}"
3343 if feat_yes DOTLOCK; then
3344 msg ' . libexecdir: %s' "${VAL_LIBEXECDIR}"
3346 msg ' . mandir: %s' "${VAL_MANDIR}"
3347 msg ' . M(ail)T(ransfer)A(gent): %s (argv0: %s)' "${VAL_MTA}" "${VAL_MTA_ARGV0}"
3348 msg ' . $MAIL spool directory: %s' "${VAL_MAIL}"
3350 msg ''
3351 if [ -n "${have_fnmatch}" ] && [ -n "${have_fchdir}" ]; then
3352 exit 0
3354 msg 'Remarks:'
3355 if [ -z "${have_fnmatch}" ]; then
3356 msg ' . The function fnmatch(3) could not be found.'
3357 msg ' Filename patterns like wildcard are not supported on your system'
3359 if [ -z "${have_fchdir}" ]; then
3360 msg ' . The function fchdir(2) could not be found.'
3361 msg ' We will use chdir(2) instead.'
3362 msg ' This is a problem only if the current working directory is changed'
3363 msg ' while this program is inside of it'
3365 msg ''
3367 # s-it-mode