Don't use UI32_MAX buffer size with snprintf(3)..
[s-mailx.git] / mk-conf.sh
blobde46edeb6810b3d4c1bf9655a2a7a56278627d43
1 #!/bin/sh -
2 #@ Please see `INSTALL' and `make.rc' instead.
4 LC_ALL=C
5 export LC_ALL
7 # Predefined CONFIG= urations take precedence over anything else
8 if [ -n "${CONFIG}" ]; then
9 case ${CONFIG} in
10 MINIMAL)
11 WANT_ICONV=1
12 WANT_SOCKETS=0
13 WANT_IDNA=0
14 WANT_IMAP_SEARCH=0
15 WANT_REGEX=0
16 WANT_READLINE=0 WANT_EDITLINE=0 WANT_NCL=0
17 WANT_SPAM=0
18 WANT_DOCSTRINGS=0
19 WANT_QUOTE_FOLD=0
20 WANT_COLOUR=0
22 MEDIUM)
23 WANT_ICONV=1
24 WANT_SOCKETS=0
25 WANT_IDNA=0
26 WANT_IMAP_SEARCH=0
27 WANT_REGEX=1
28 WANT_READLINE=0 WANT_EDITLINE=0 WANT_NCL=1
29 WANT_HISTORY=1 WANT_TABEXPAND=0
30 WANT_SPAM=0
31 WANT_DOCSTRINGS=1
32 WANT_QUOTE_FOLD=0
33 WANT_COLOUR=0
35 NETSEND)
36 WANT_ICONV=1
37 WANT_SOCKETS=1
38 WANT_IPV6=1 WANT_SSL=1 WANT_SMTP=require WANT_POP3=0 WANT_IMAP=0
39 WANT_GSSAPI=1 WANT_NETRC=1 WANT_AGENT=1
40 WANT_IDNA=1
41 WANT_IMAP_SEARCH=0
42 WANT_REGEX=1
43 WANT_READLINE=0 WANT_EDITLINE=0 WANT_NCL=1
44 WANT_HISTORY=1 WANT_TABEXPAND=0
45 WANT_SPAM=0
46 WANT_DOCSTRINGS=1
47 WANT_QUOTE_FOLD=0
48 WANT_COLOUR=0
50 MAXIMAL)
51 WANT_ICONV=1
52 WANT_SOCKETS=1
53 WANT_IPV6=1 WANT_SSL=1 WANT_SMTP=1 WANT_POP3=1 WANT_IMAP=1
54 WANT_GSSAPI=1 WANT_NETRC=1 WANT_AGENT=1
55 WANT_IDNA=1
56 WANT_IMAP_SEARCH=1
57 WANT_REGEX=1
58 WANT_READLINE=0 WANT_EDITLINE=0 WANT_NCL=1
59 WANT_HISTORY=1 WANT_TABEXPAND=1
60 WANT_SPAM=1
61 WANT_DOCSTRINGS=1
62 WANT_QUOTE_FOLD=1
63 WANT_COLOUR=1
66 echo >&2 "Unknown CONFIG= setting: ${CONFIG}"
67 echo >&2 'Possible values: MINIMAL, MEDIUM, NETSEND, MAXIMAL'
68 exit 1
69 esac
72 # Inter-relationships
73 option_update() {
74 if feat_no SOCKETS; then
75 if feat_require SMTP; then
76 msg "ERROR: need SOCKETS for required feature SMTP\\n"
77 config_exit 13
79 if feat_require POP3; then
80 msg "ERROR: need SOCKETS for required feature POP3\\n"
81 config_exit 13
83 if feat_require IMAP; then
84 msg "ERROR: need SOCKETS for required feature IMAP\\n"
85 config_exit 13
87 WANT_IPV6=0 WANT_SSL=0
88 WANT_SMTP=0 WANT_POP3=0 WANT_IMAP=0 WANT_GSSAPI=0
89 WANT_NETRC=0 WANT_AGENT=0
91 if feat_no SMTP && feat_no POP3 && feat_no IMAP; then
92 WANT_SOCKETS=0 WANT_IPV6=0 WANT_SSL=0 WANT_NETRC=0 WANT_AGENT=0
94 if feat_no SMTP && feat_no IMAP; then
95 WANT_GSSAPI=0
97 if feat_no READLINE && feat_no EDITLINE && feat_no NCL; then
98 WANT_HISTORY=0 WANT_TABEXPAND=0
100 # If we don't need MD5 except for producing boundary and message-id strings,
101 # leave it off, plain old srand(3) should be enough for that purpose.
102 if feat_no SOCKETS; then
103 WANT_MD5=0
105 if feat_yes DEBUG; then
106 WANT_NOALLOCA=1 WANT_DEVEL=1
110 # Check out compiler ($CC) and -flags ($CFLAGS)
111 compiler_flags() {
112 # $CC is overwritten when empty or a default "cc", even without WANT_AUTOCC
113 optim= dbgoptim= _CFLAGS=
114 if [ -z "${CC}" ] || [ "${CC}" = cc ]; then
115 if { CC="`command -v clang`"; }; then
117 elif { CC="`command -v gcc`"; }; then
119 elif { CC="`command -v c89`"; }; then
120 [ "`uname -s`" = UnixWare ] && _CFLAGS=-v optim=-O dbgoptim=
121 elif { CC="`command -v c99`"; }; then
123 else
124 msg 'ERROR'
125 msg ' I cannot find a compiler!'
126 msg ' Neither of clang(1), gcc(1), c89(1) and c99(1).'
127 msg ' Please set the CC environment variable, maybe CFLAGS also.'
128 config_exit 1
131 export CC
133 ccver=`${CC} --version 2>/dev/null`
134 stackprot=no
135 if { i=${ccver}; echo "${i}"; } | ${grep} -q -i -e gcc -e clang; then
136 #if echo "${i}" | ${grep} -q -i -e gcc -e 'clang version 1'; then
137 optim=-O2 dbgoptim=-O
138 stackprot=yes
139 _CFLAGS="${_CFLAGS} -std=c89 -Wall -Wextra -pedantic"
140 _CFLAGS="${_CFLAGS} -fno-unwind-tables -fno-asynchronous-unwind-tables"
141 _CFLAGS="${_CFLAGS} -fstrict-aliasing"
142 _CFLAGS="${_CFLAGS} -Wbad-function-cast -Wcast-align -Wcast-qual"
143 _CFLAGS="${_CFLAGS} -Winit-self -Wmissing-prototypes"
144 _CFLAGS="${_CFLAGS} -Wshadow -Wunused -Wwrite-strings"
145 _CFLAGS="${_CFLAGS} -Wno-long-long" # ISO C89 has no 'long long'...
146 if { i=${ccver}; echo "${i}"; } | ${grep} -q -e 'clang version 1'; then
147 _CFLAGS="${_CFLAGS} -Wstrict-overflow=5"
148 else
149 _CFLAGS="${_CFLAGS} -fstrict-overflow -Wstrict-overflow=5"
150 if feat_yes AMALGAMATION && feat_no DEBUG; then
151 _CFLAGS="${_CFLAGS} -Wno-unused-function"
153 if { i=${ccver}; echo "${i}"; } | ${grep} -q -i -e clang; then
154 _CFLAGS="${_CFLAGS} -Wno-unused-result" # TODO handle the right way
157 if feat_yes AMALGAMATION; then
158 _CFLAGS="${_CFLAGS} -pipe"
160 # elif { i=${ccver}; echo "${i}"; } | ${grep} -q -i -e clang; then
161 # optim=-O3 dbgoptim=-O
162 # stackprot=yes
163 # _CFLAGS='-std=c89 -Weverything -Wno-long-long'
164 # if feat_yes AMALGAMATION; then
165 # _CFLAGS="${_CFLAGS} -pipe"
166 # fi
167 elif [ -z "${optim}" ]; then
168 optim=-O1 dbgoptim=-O
171 if feat_no DEBUG; then
172 _CFLAGS="${optim} -DNDEBUG ${_CFLAGS}"
173 else
174 _CFLAGS="${dbgoptim} -g ${_CFLAGS}";
175 if [ "${stackprot}" = yes ]; then
176 _CFLAGS="${_CFLAGS} -ftrapv -fstack-protector-all "
177 _CFLAGS="${_CFLAGS} -Wstack-protector -D_FORTIFY_SOURCE=2"
180 _CFLAGS="${_CFLAGS} ${ADDCFLAGS}"
181 # XXX -Wl,-z,relro -Wl,-z,now -Wl,-z,noexecstack: need detection
182 _LDFLAGS="${_LDFLAGS} ${ADDLDFLAGS}" # XXX -Wl,--sort-common,[-O1]
183 export _CFLAGS _LDFLAGS
185 # $CFLAGS and $LDFLAGS are only overwritten if explicitly wanted
186 if feat_yes AUTOCC; then
187 CFLAGS=$_CFLAGS
188 LDFLAGS=$_LDFLAGS
189 export CFLAGS LDFLAGS
193 ## -- >8 -- 8< -- ##
195 ## Notes:
196 ## - Heirloom sh(1) (and same origin) have _sometimes_ problems with ': >'
197 ## redirection, so use "printf '' >" instead
199 ## Very first: we undergo several states regarding I/O redirection etc.,
200 ## but need to deal with option updates from within all. Since all the
201 ## option stuff should be above the scissor line, define utility functions
202 ## and redefine them as necessary.
203 ## And, since we have those functions, simply use them for whatever
205 config_exit() {
206 exit ${1}
209 msg() {
210 fmt=${1}
211 shift
212 printf >&2 "${fmt}\\n" "${@}"
215 ## First of all, create new configuration and check wether it changed ##
217 rc=./make.rc
218 lst=./config.lst
219 h=./config.h
220 mk=./mk.mk
222 newlst=./config.lst-new
223 newmk=./config.mk-new
224 newh=./config.h-new
225 tmp0=___tmp
226 tmp=./${tmp0}1$$
228 # We need some standard utilities
229 unset -f command
230 check_tool() {
231 n=${1} i=${2} opt=${3:-0}
232 # Evaluate, just in case user comes in with shell snippets (..well..)
233 eval i="${i}"
234 if type "${i}" >/dev/null 2>&1; then
235 eval ${n}=${i}
236 return 0
238 if [ ${opt} -eq 0 ]; then
239 msg "ERROR: no trace of the utility \`${n}'\\n"
240 config_exit 1
242 return 0
245 # Check those tools right now that we need before including $rc
246 check_tool rm "${rm:-`command -v rm`}"
247 check_tool sed "${sed:-`command -v sed`}"
249 # Include $rc, but only take from it what wasn't overwritten by the user from
250 # within the command line or from a chosen fixed CONFIG=
251 # Note we leave alone the values
252 trap "${rm} -f ${tmp}; exit" 1 2 15
253 trap "${rm} -f ${tmp}" 0
255 ${rm} -f ${tmp}
256 < ${rc} ${sed} -e '/^[ \t]*#/d' -e '/^$/d' -e 's/[ \t]*$//' |
257 while read line; do
258 i="`echo ${line} | ${sed} -e 's/=.*$//'`"
259 eval j="\$${i}" jx="\${${i}+x}"
260 if [ -n "${j}" ] || [ "${jx}" = x ]; then
261 : # Yet present
262 else
263 j="`echo ${line} | ${sed} -e 's/^[^=]*=//' -e 's/^\"*//' -e 's/\"*$//'`"
265 echo "${i}=\"${j}\""
266 done > ${tmp}
267 # Reread the mixed version right now
268 . ./${tmp}
270 check_tool awk "${awk:-`command -v awk`}"
271 check_tool cat "${cat:-`command -v cat`}"
272 check_tool chmod "${chmod:-`command -v chmod`}"
273 check_tool cp "${cp:-`command -v cp`}"
274 check_tool cmp "${cmp:-`command -v cmp`}"
275 check_tool grep "${grep:-`command -v grep`}"
276 check_tool mkdir "${mkdir:-`command -v mkdir`}"
277 check_tool mv "${mv:-`command -v mv`}"
278 # rm(1), sed(1) above
279 check_tool tee "${tee:-`command -v tee`}"
281 check_tool make "${MAKE:-`command -v make`}"
282 check_tool strip "${STRIP:-`command -v strip`}" 1
283 HAVE_STRIP=${?}
285 # Update WANT_ options now, in order to get possible inter-dependencies right
287 feat_val_no() {
288 [ "x${1}" = x0 ] || [ "x${1}" = xfalse ] || [ "x${1}" = xno ]
291 feat_val_yes() {
292 [ "x${1}" = x1 ] || [ "x${1}" = xtrue ] || [ "x${1}" = xyes ] ||
293 [ "x${1}" = xrequire ]
296 feat_val_require() {
297 [ "x${1}" = xrequire ]
300 _feat_check() {
301 eval i=\$WANT_${1}
302 i="`echo ${i} | tr '[A-Z]' '[a-z]'`"
303 if feat_val_no "${i}"; then
304 return 1
305 elif feat_val_yes "${i}"; then
306 return 0
307 else
308 msg "ERROR: ${1}: allowed: 0/false/no or 1/true/yes/require, got: ${i}\\n"
309 config_exit 11
313 feat_yes() {
314 _feat_check ${1}
317 feat_no() {
318 _feat_check ${1} && return 1
319 return 0
322 feat_require() {
323 eval i=\$WANT_${1}
324 i="`echo ${i} | tr '[A-Z]' '[a-z]'`"
325 [ "x${i}" = xrequire ]
328 option_update
330 # (No functions since some shells loose non-exported variables in traps)
331 trap "${rm} -f ${tmp} ${newlst} ${newmk} ${newh}; exit" 1 2 15
332 trap "${rm} -f ${tmp} ${newlst} ${newmk} ${newh}" 0
334 # Our configuration options may at this point still contain shell snippets,
335 # we need to evaluate them in order to get them expanded, and we need those
336 # evaluated values not only in our new configuration file, but also at hand..
337 ${rm} -f ${newlst} ${newmk} ${newh}
338 exec 5<&0 6>&1 <${tmp} >${newlst}
339 while read line; do
340 i=`echo ${line} | ${sed} -e 's/=.*$//'`
341 eval j=\$${i}
342 if echo "${i}" | grep -e '^WANT_' >/dev/null 2>&1; then
343 if [ -z "${j}" ] || feat_val_no "${j}"; then
345 printf "/*#define ${i}*/\n" >> ${newh}
346 elif feat_val_yes "${j}"; then
347 if feat_val_require "${j}"; then
348 j=require
349 else
352 printf "#define ${i}\n" >> ${newh}
353 else
354 msg "ERROR: internal error -42\\n"
355 config_exit 1
357 else
358 printf "#define ${i} \"${j}\"\n" >> ${newh}
360 printf "${i} = ${j}\n" >> ${newmk}
361 printf "${i}=${j}\n"
362 eval "${i}=\"${j}\""
363 done
364 exec 0<&5 1<&6 5<&- 6<&-
366 printf "#define UAGENT \"${SID}${NAIL}\"\n" >> ${newh}
367 printf "UAGENT = ${SID}${NAIL}\n" >> ${newmk}
369 compiler_flags
371 printf "CC = ${CC}\n" >> ${newmk}
372 printf "CC=${CC}\n" >> ${newlst}
374 printf "_CFLAGS = ${_CFLAGS}\nCFLAGS = ${CFLAGS}\n" >> ${newmk}
375 printf "_CFLAGS=${_CFLAGS}\nCFLAGS=${CFLAGS}\n" >> ${newlst}
377 printf "_LDFLAGS = ${_LDFLAGS}\nLDFLAGS = ${LDFLAGS}\n" >> ${newmk}
378 printf "_LDFLAGS=${_LDFLAGS}\nLDFLAGS=${LDFLAGS}\n" >> ${newlst}
380 printf "AWK = ${awk}\nCMP = ${cmp}\nCHMOD = ${chmod}\nCP = ${cp}\n" >> ${newmk}
381 printf "AWK=${awk}\nCMP=${cmp}\nCHMOD=${chmod}\nCP=${cp}\n" >> ${newlst}
383 printf "GREP = ${grep}\nMKDIR = ${mkdir}\nRM = ${rm}\nSED = ${sed}\n" \
384 >> ${newmk}
385 printf "GREP=${grep}\nMKDIR=${mkdir}\nRM=${rm}\nSED=${sed}\n" >> ${newlst}
387 printf "STRIP = ${strip}\nHAVE_STRIP = ${HAVE_STRIP}\n" >> ${newmk}
388 printf "STRIP=${strip}\nHAVE_STRIP=${HAVE_STRIP}\n" >> ${newlst}
390 # Build a basic set of INCS and LIBS according to user environment.
391 # On pkgsrc(7) systems automatically add /usr/pkg/*
392 if [ -n "${C_INCLUDE_PATH}" ]; then
393 i=${IFS}
394 IFS=:
395 set -- ${C_INCLUDE_PATH}
396 IFS=${i}
397 # for i; do -- new in POSIX Issue 7 + TC1
398 for i
400 [ "${i}" = /usr/pkg/include ] && continue
401 INCS="${INCS} -I${i}"
402 done
404 [ -d /usr/pkg/include ] && INCS="${INCS} -I/usr/pkg/include"
405 printf "INCS=${INCS}\n" >> ${newlst}
407 if [ -n "${LD_LIBRARY_PATH}" ]; then
408 i=${IFS}
409 IFS=:
410 set -- ${LD_LIBRARY_PATH}
411 IFS=${i}
412 # for i; do -- new in POSIX Issue 7 + TC1
413 for i
415 [ "${i}" = /usr/pkg/lib ] && continue
416 LIBS="${LIBS} -L${i}"
417 done
419 [ -d /usr/pkg/lib ] && LIBS="${LIBS} -L/usr/pkg/lib"
420 printf "LIBS=${LIBS}\n" >> ${newlst}
422 # Now finally check wether we already have a configuration and if so, wether
423 # all those parameters are still the same.. or something has actually changed
424 if [ -f ${lst} ] && ${cmp} ${newlst} ${lst} >/dev/null 2>&1; then
425 exit 0
427 [ -f ${lst} ] && echo 'configuration updated..' || echo 'shiny configuration..'
429 # Time to redefine helper 1
430 config_exit() {
431 ${rm} -f ${lst} ${h} ${mk}
432 exit ${1}
435 ${mv} -f ${newlst} ${lst}
436 ${mv} -f ${newh} ${h}
437 ${mv} -f ${newmk} ${mk}
439 ## Compile and link checking ##
441 tmp2=./${tmp0}2$$
442 tmp3=./${tmp0}3$$
443 log=./config.log
444 lib=./config.lib
445 inc=./config.inc
446 src=./config.c
447 makefile=./config.mk
449 # (No function since some shells loose non-exported variables in traps)
450 trap "${rm} -f ${lst} ${h} ${mk} ${lib} ${inc} ${src} ${makefile}; exit" 1 2 15
451 trap "${rm} -f ${tmp0}.* ${tmp0}* ${makefile}" 0
453 # Time to redefine helper 2
454 msg() {
455 fmt=${1}
456 shift
457 printf "*** ${fmt}\\n" "${@}"
458 printf "${fmt}" "${@}" >&5
461 exec 5>&2 > ${log} 2>&1
463 echo "${LIBS}" > ${lib}
464 echo "${INCS}" > ${inc}
465 # ${src} is only created if WANT_AMALGAMATION
466 ${rm} -f ${src}
467 ${cat} > ${makefile} << \!
468 .SUFFIXES: .o .c .x .y
469 .c.o:
470 $(CC) $(XINCS) -c $<
471 .c.x:
472 $(CC) $(XINCS) -E $< >$@
474 $(CC) $(XINCS) -o $@ $< $(XLIBS)
475 .y: ;
478 _check_preface() {
479 variable=$1 topic=$2 define=$3
481 echo '**********'
482 msg "checking ${topic} ... "
483 echo "/* checked ${topic} */" >> ${h}
484 ${rm} -f ${tmp} ${tmp}.o
485 echo '*** test program is'
486 ${tee} ${tmp}.c
487 #echo '*** the preprocessor generates'
488 #${make} -f ${makefile} ${tmp}.x
489 #${cat} ${tmp}.x
490 echo '*** results are'
493 compile_check() {
494 variable=$1 topic=$2 define=$3
496 _check_preface "${variable}" "${topic}" "${define}"
498 if ${make} -f ${makefile} XINCS="${INCS}" ./${tmp}.o &&
499 [ -f ./${tmp}.o ]; then
500 msg "yes\\n"
501 echo "${define}" >> ${h}
502 eval have_${variable}=yes
503 return 0
504 else
505 echo "/* ${define} */" >> ${h}
506 msg "no\\n"
507 eval unset have_${variable}
508 return 1
512 _link_mayrun() {
513 run=$1 variable=$2 topic=$3 define=$4 libs=$5 incs=$6
515 _check_preface "${variable}" "${topic}" "${define}"
517 if ${make} -f ${makefile} XINCS="${INCS} ${incs}" \
518 XLIBS="${LIBS} ${libs}" ./${tmp} &&
519 [ -f ./${tmp} ] &&
520 { [ ${run} -eq 0 ] || ./${tmp}; }; then
521 echo "*** adding INCS<${incs}> LIBS<${libs}>"
522 msg "yes\\n"
523 echo "${define}" >> ${h}
524 LIBS="${LIBS} ${libs}"
525 echo "${libs}" >> ${lib}
526 INCS="${INCS} ${incs}"
527 echo "${incs}" >> ${inc}
528 eval have_${variable}=yes
529 return 0
530 else
531 msg "no\\n"
532 echo "/* ${define} */" >> ${h}
533 eval unset have_${variable}
534 return 1
538 link_check() {
539 _link_mayrun 0 "${1}" "${2}" "${3}" "${4}" "${5}"
542 run_check() {
543 _link_mayrun 1 "${1}" "${2}" "${3}" "${4}" "${5}"
546 feat_bail_required() {
547 if feat_require ${1}; then
548 msg "ERROR: feature WANT_${1} is required but not available\\n"
549 config_exit 13
551 eval WANT_${1}=0
552 option_update # XXX this is rather useless here (dependency chain..)
557 # Better set _GNU_SOURCE (if we are on Linux only?); 'surprised it did without!
558 echo '#define _GNU_SOURCE' >> ${h}
560 if link_check hello 'if a hello world program can be built' << \!
561 #include <stdio.h>
563 int main(int argc, char *argv[])
565 (void)argc;
566 (void)argv;
567 puts("hello world");
568 return 0;
571 then
573 else
574 echo >&5 'This oooops is most certainly not related to me.'
575 echo >&5 "Read the file ${log} and check your compiler environment."
576 config_exit 1
579 if link_check termios 'for termios.h and tc*() family' << \!
580 #include <termios.h>
581 int main(void)
583 struct termios tios;
584 tcgetattr(0, &tios);
585 tcsetattr(0, TCSADRAIN | TCSAFLUSH, &tios);
586 return 0;
589 then
591 else
592 echo >&5 'We require termios.h and the tc*() family of functions.'
593 echo >&5 "That much Unix we indulge ourselfs."
594 config_exit 1
597 link_check setenv 'for setenv()/unsetenv()' '#define HAVE_SETENV' << \!
598 #include <stdlib.h>
599 int main(void)
601 setenv("s-nail", "to be made nifty!", 1);
602 unsetenv("s-nail");
603 return 0;
607 link_check snprintf 'for snprintf()' '#define HAVE_SNPRINTF' << \!
608 #include <stdio.h>
609 int main(void)
611 char b[20];
612 snprintf(b, sizeof b, "%s", "string");
613 return 0;
617 link_check putc_unlocked 'for putc_unlocked()' '#define HAVE_PUTC_UNLOCKED' <<\!
618 #include <stdio.h>
619 int main(void)
621 putc_unlocked('@', stdout);
622 return 0;
626 link_check fchdir 'for fchdir()' '#define HAVE_FCHDIR' << \!
627 #include <unistd.h>
628 int main(void)
630 fchdir(0);
631 return 0;
635 link_check pipe2 'for pipe2()' '#define HAVE_PIPE2' << \!
636 #include <fcntl.h>
637 #include <unistd.h>
638 int main(void)
640 int fds[2];
641 pipe2(fds, O_CLOEXEC);
642 return 0;
646 link_check mmap 'for mmap()' '#define HAVE_MMAP' << \!
647 #include <sys/types.h>
648 #include <sys/mman.h>
649 int main(void)
651 mmap(0, 0, 0, 0, 0, 0);
652 return 0;
656 link_check mremap 'for mremap()' '#define HAVE_MREMAP' << \!
657 #include <sys/types.h>
658 #include <sys/mman.h>
659 int main(void)
661 mremap(0, 0, 0, MREMAP_MAYMOVE);
662 return 0;
666 link_check setlocale 'for setlocale()' '#define HAVE_SETLOCALE' << \!
667 #include <locale.h>
668 int main(void)
670 setlocale(LC_ALL, "");
671 return 0;
675 if [ "${have_setlocale}" = yes ]; then
676 link_check c90amend1 'for ISO/IEC 9899:1990/Amendment 1:1995' \
677 '#define HAVE_C90AMEND1' << \!
678 #include <limits.h>
679 #include <stdlib.h>
680 #include <wchar.h>
681 #include <wctype.h>
682 int main(void)
684 char mbb[MB_LEN_MAX + 1];
685 wchar_t wc;
686 iswprint(L'c');
687 towupper(L'c');
688 mbtowc(&wc, "x", 1);
689 mbrtowc(&wc, "x", 1, NULL);
690 wctomb(mbb, wc);
691 return (mblen("\0", 1) == 0);
695 if [ "${have_c90amend1}" = yes ]; then
696 link_check wcwidth 'for wcwidth()' '#define HAVE_WCWIDTH' << \!
697 #include <wchar.h>
698 int main(void)
700 wcwidth(L'c');
701 return 0;
706 link_check nl_langinfo 'for nl_langinfo()' '#define HAVE_NL_LANGINFO' << \!
707 #include <langinfo.h>
708 #include <stdlib.h>
709 int main(void)
711 nl_langinfo(DAY_1);
712 return (nl_langinfo(CODESET) == NULL);
715 fi # have_setlocale
717 link_check mkstemp 'for mkstemp()' '#define HAVE_MKSTEMP' << \!
718 #include <stdlib.h>
719 int main(void)
721 mkstemp("x");
722 return 0;
726 # Note: run_check, thus we also get only the desired implementation...
727 run_check realpath 'for realpath()' '#define HAVE_REALPATH' << \!
728 #include <stdlib.h>
729 int main(void)
731 char *x = realpath(".", NULL), *y = realpath("/", NULL);
732 return (x != NULL && y != NULL) ? 0 : 1;
736 link_check wordexp 'for wordexp()' '#define HAVE_WORDEXP' << \!
737 #include <wordexp.h>
738 int main(void)
740 wordexp((char*)0, (wordexp_t*)0, 0);
741 return 0;
747 if feat_yes DEBUG; then
748 echo '#define HAVE_DEBUG' >> ${h}
751 if feat_yes AMALGAMATION; then
752 echo '#define HAVE_AMALGAMATION' >> ${h}
755 if feat_no NOALLOCA; then
756 # Due to NetBSD PR lib/47120 it seems best not to use non-cc-builtin
757 # versions of alloca(3) since modern compilers just can't be trusted
758 # not to overoptimize and silently break some code
759 link_check alloca 'for __builtin_alloca()' \
760 '#define HAVE_ALLOCA __builtin_alloca' << \!
761 int main(void)
763 void *vp = __builtin_alloca(1);
764 return (vp != NULL);
769 if feat_yes DEVEL; then
770 echo '#define HAVE_DEVEL' >> ${h}
773 if feat_yes NYD2; then
774 echo '#define HAVE_NYD2' >> ${h}
779 if feat_yes ICONV; then
780 ${cat} > ${tmp2}.c << \!
781 #include <iconv.h>
782 int main(void)
784 iconv_t id;
786 id = iconv_open("foo", "bar");
787 return 0;
790 < ${tmp2}.c link_check iconv 'for iconv functionality' \
791 '#define HAVE_ICONV' ||
792 < ${tmp2}.c link_check iconv \
793 'for iconv functionality in libiconv' \
794 '#define HAVE_ICONV' '-liconv' ||
795 feat_bail_required ICONV
796 else
797 echo '/* WANT_ICONV=0 */' >> ${h}
798 fi # feat_yes ICONV
800 if feat_yes SOCKETS; then
801 compile_check arpa_inet_h 'for <arpa/inet.h>' \
802 '#define HAVE_ARPA_INET_H' << \!
803 #include "config.h"
804 #include <sys/types.h>
805 #include <sys/socket.h>
806 #include <netdb.h>
807 #include <netinet/in.h>
808 #include <arpa/inet.h>
811 ${cat} > ${tmp2}.c << \!
812 #include "config.h"
813 #include <sys/types.h>
814 #include <sys/socket.h>
815 #include <netdb.h>
816 #include <netinet/in.h>
817 #ifdef HAVE_ARPA_INET_H
818 #include <arpa/inet.h>
819 #endif
821 int main(void)
823 struct sockaddr s;
824 socket(AF_INET, SOCK_STREAM, 0);
825 connect(0, &s, 0);
826 gethostbyname("foo");
827 return 0;
831 < ${tmp2}.c link_check sockets 'for sockets in libc' \
832 '#define HAVE_SOCKETS' ||
833 < ${tmp2}.c link_check sockets 'for sockets in libnsl' \
834 '#define HAVE_SOCKETS' '-lnsl' ||
835 < ${tmp2}.c link_check sockets \
836 'for sockets in libsocket and libnsl' \
837 '#define HAVE_SOCKETS' '-lsocket -lnsl' ||
838 feat_bail_required SOCKETS
839 else
840 echo '/* WANT_SOCKETS=0 */' >> ${h}
841 fi # feat_yes SOCKETS
843 feat_yes SOCKETS &&
844 link_check setsockopt 'for setsockopt()' '#define HAVE_SETSOCKOPT' << \!
845 #include <sys/socket.h>
846 #include <stdlib.h>
847 int main(void)
849 int sockfd = 3;
850 setsockopt(sockfd, SOL_SOCKET, SO_KEEPALIVE, NULL, 0);
851 return 0;
855 feat_yes SOCKETS && [ -n "${have_setsockopt}" ] &&
856 link_check so_sndtimeo 'for SO_SNDTIMEO' '#define HAVE_SO_SNDTIMEO' << \!
857 #include <sys/socket.h>
858 #include <stdlib.h>
859 int main(void)
861 struct timeval tv;
862 int sockfd = 3;
863 tv.tv_sec = 42;
864 tv.tv_usec = 21;
865 setsockopt(sockfd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof tv);
866 setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof tv);
867 return 0;
871 feat_yes SOCKETS && [ -n "${have_setsockopt}" ] &&
872 link_check so_linger 'for SO_LINGER' '#define HAVE_SO_LINGER' << \!
873 #include <sys/socket.h>
874 #include <stdlib.h>
875 int main(void)
877 struct linger li;
878 int sockfd = 3;
879 li.l_onoff = 1;
880 li.l_linger = 42;
881 setsockopt(sockfd, SOL_SOCKET, SO_LINGER, &li, sizeof li);
882 return 0;
886 if feat_yes IPV6; then
887 if link_check ipv6 'for IPv6 functionality' '#define HAVE_IPV6' << \!
888 #include "config.h"
889 #include <sys/types.h>
890 #include <sys/socket.h>
891 #include <netdb.h>
892 #include <netinet/in.h>
893 #ifdef HAVE_ARPA_INET_H
894 #include <arpa/inet.h>
895 #endif
897 int main(void)
899 struct addrinfo a, *ap;
900 getaddrinfo("foo", "0", &a, &ap);
901 return 0;
904 then
906 else
907 feat_bail_required IPV6
909 else
910 echo '/* WANT_IPV6=0 */' >> ${h}
911 fi # feat_yes IPV6
913 if feat_yes SSL; then
914 if link_check openssl 'for sufficiently recent OpenSSL' \
915 '#define HAVE_SSL
916 #define HAVE_OPENSSL' '-lssl -lcrypto' << \!
917 #include <openssl/ssl.h>
918 #include <openssl/err.h>
919 #include <openssl/x509v3.h>
920 #include <openssl/x509.h>
921 #include <openssl/rand.h>
923 #if defined OPENSSL_NO_SSL2 && defined OPENSSL_NO_SSL3 &&\
924 defined OPENSSL_NO_TLS1
925 # error We need one of (SSLv2 and) SSLv3 and TLS1.
926 #endif
928 int main(void)
930 SSLv23_client_method();
931 #ifndef OPENSSL_NO_SSL3
932 SSLv3_client_method();
933 #endif
934 #ifndef OPENSSL_NO_TLS1
935 TLSv1_client_method();
936 # ifdef TLS1_1_VERSION
937 TLSv1_1_client_method();
938 # endif
939 # ifdef TLS1_2_VERSION
940 TLSv1_2_client_method();
941 # endif
942 #endif
943 PEM_read_PrivateKey(0, 0, 0, 0);
944 return 0;
947 then
949 else
950 feat_bail_required SSL
953 if [ "${have_openssl}" = 'yes' ]; then
954 compile_check stack_of 'for OpenSSL STACK_OF()' \
955 '#define HAVE_OPENSSL_STACK_OF' << \!
956 #include <openssl/ssl.h>
957 #include <openssl/err.h>
958 #include <openssl/x509v3.h>
959 #include <openssl/x509.h>
960 #include <openssl/rand.h>
962 int main(void)
964 STACK_OF(GENERAL_NAME) *gens = NULL;
965 printf("%p", gens); /* to make it used */
966 return 0;
970 link_check rand_egd 'for OpenSSL RAND_egd()' \
971 '#define HAVE_OPENSSL_RAND_EGD' '-lssl -lcrypto' << \!
972 #include <openssl/rand.h>
974 int main(void)
976 return RAND_egd("some.where") > 0;
980 if feat_yes MD5 && feat_no NOEXTMD5; then
981 run_check openssl_md5 'for MD5 digest in OpenSSL' \
982 '#define HAVE_OPENSSL_MD5' << \!
983 #include <string.h>
984 #include <openssl/md5.h>
986 int main(void)
988 char const dat[] = "abrakadabrafidibus";
989 char dig[16], hex[16 * 2];
990 MD5_CTX ctx;
991 size_t i, j;
993 memset(dig, 0, sizeof(dig));
994 memset(hex, 0, sizeof(hex));
995 MD5_Init(&ctx);
996 MD5_Update(&ctx, dat, sizeof(dat) - 1);
997 MD5_Final(dig, &ctx);
999 #define hexchar(n) ((n) > 9 ? (n) - 10 + 'a' : (n) + '0')
1000 for (i = 0; i < sizeof(hex) / 2; i++) {
1001 j = i << 1;
1002 hex[j] = hexchar((dig[i] & 0xf0) >> 4);
1003 hex[++j] = hexchar(dig[i] & 0x0f);
1005 return !!memcmp("6d7d0a3d949da2e96f2aa010f65d8326", hex, sizeof(hex));
1008 fi # feat_yes MD5 && feat_no NOEXTMD5
1010 else
1011 echo '/* WANT_SSL=0 */' >> ${h}
1012 fi # feat_yes SSL
1014 if feat_yes SMTP; then
1015 echo '#define HAVE_SMTP' >> ${h}
1016 else
1017 echo '/* WANT_SMTP=0 */' >> ${h}
1020 if feat_yes POP3; then
1021 echo '#define HAVE_POP3' >> ${h}
1022 else
1023 echo '/* WANT_POP3=0 */' >> ${h}
1026 if feat_yes IMAP; then
1027 echo '#define HAVE_IMAP' >> ${h}
1028 else
1029 echo '/* WANT_IMAP=0 */' >> ${h}
1032 if feat_yes GSSAPI; then
1033 ${cat} > ${tmp2}.c << \!
1034 #include <gssapi/gssapi.h>
1036 int main(void)
1038 gss_import_name(0, 0, GSS_C_NT_HOSTBASED_SERVICE, 0);
1039 gss_init_sec_context(0,0,0,0,0,0,0,0,0,0,0,0,0);
1040 return 0;
1043 ${sed} -e '1s/gssapi\///' < ${tmp2}.c > ${tmp3}.c
1045 if command -v krb5-config >/dev/null 2>&1; then
1046 i=`command -v krb5-config`
1047 GSS_LIBS="`CFLAGS= ${i} --libs gssapi`"
1048 GSS_INCS="`CFLAGS= ${i} --cflags`"
1049 i='for GSS-API via krb5-config(1)'
1050 else
1051 GSS_LIBS='-lgssapi'
1052 GSS_INCS=
1053 i='for GSS-API in gssapi/gssapi.h, libgssapi'
1055 if < ${tmp2}.c link_check gss \
1056 "${i}" '#define HAVE_GSSAPI' "${GSS_LIBS}" "${GSS_INCS}" ||\
1057 < ${tmp3}.c link_check gss \
1058 'for GSS-API in gssapi.h, libgssapi' \
1059 '#define HAVE_GSSAPI
1060 #define GSSAPI_REG_INCLUDE' \
1061 '-lgssapi' ||\
1062 < ${tmp2}.c link_check gss 'for GSS-API in libgssapi_krb5' \
1063 '#define HAVE_GSSAPI' \
1064 '-lgssapi_krb5' ||\
1065 < ${tmp3}.c link_check gss \
1066 'for GSS-API in libgssapi, OpenBSD-style (pre 5.3)' \
1067 '#define HAVE_GSSAPI
1068 #define GSS_REG_INCLUDE' \
1069 '-lgssapi -lkrb5 -lcrypto' \
1070 '-I/usr/include/kerberosV' ||\
1071 < ${tmp2}.c link_check gss 'for GSS-API in libgss' \
1072 '#define HAVE_GSSAPI' \
1073 '-lgss' ||\
1074 link_check gss 'for GSS-API in libgssapi_krb5, old-style' \
1075 '#define HAVE_GSSAPI
1076 #define GSSAPI_OLD_STYLE' \
1077 '-lgssapi_krb5' << \!
1078 #include <gssapi/gssapi.h>
1079 #include <gssapi/gssapi_generic.h>
1081 int main(void)
1083 gss_import_name(0, 0, gss_nt_service_name, 0);
1084 gss_init_sec_context(0,0,0,0,0,0,0,0,0,0,0,0,0);
1085 return 0;
1088 then
1090 else
1091 feat_bail_required GSSAPI
1093 else
1094 echo '/* WANT_GSSAPI=0 */' >> ${h}
1095 fi # feat_yes GSSAPI
1097 if feat_yes NETRC; then
1098 echo '#define HAVE_NETRC' >> ${h}
1099 else
1100 echo '/* WANT_NETRC=0 */' >> ${h}
1103 if feat_yes AGENT; then
1104 echo '#define HAVE_AGENT' >> ${h}
1105 else
1106 echo '/* WANT_AGENT=0 */' >> ${h}
1109 if feat_yes IDNA; then
1110 if link_check idna 'for GNU Libidn' '#define HAVE_IDNA' '-lidn' << \!
1111 #include <idna.h>
1112 #include <idn-free.h>
1113 #include <stringprep.h>
1114 int main(void)
1116 char *utf8, *idna_ascii, *idna_utf8;
1117 utf8 = stringprep_locale_to_utf8("does.this.work");
1118 if (idna_to_ascii_8z(utf8, &idna_ascii, IDNA_USE_STD3_ASCII_RULES)
1119 != IDNA_SUCCESS)
1120 return 1;
1121 idn_free(idna_ascii);
1122 /* (Rather link check only here) */
1123 idna_utf8 = stringprep_convert(idna_ascii, "UTF-8", "de_DE");
1124 return 0;
1127 then
1129 else
1130 feat_bail_required IDNA
1132 else
1133 echo '/* WANT_IDNA=0 */' >> ${h}
1136 if feat_yes IMAP_SEARCH; then
1137 echo '#define HAVE_IMAP_SEARCH' >> ${h}
1138 else
1139 echo '/* WANT_IMAP_SEARCH=0 */' >> ${h}
1142 if feat_yes REGEX; then
1143 if link_check regex 'for regular expressions' '#define HAVE_REGEX' << \!
1144 #include <regex.h>
1145 #include <stdlib.h>
1146 int main(void)
1148 int status;
1149 regex_t re;
1150 if (regcomp(&re, ".*bsd", REG_EXTENDED | REG_ICASE | REG_NOSUB) != 0)
1151 return 1;
1152 status = regexec(&re, "plan9", 0,NULL, 0);
1153 regfree(&re);
1154 return !(status == REG_NOMATCH);
1157 then
1159 else
1160 feat_bail_required REGEX
1162 else
1163 echo '/* WANT_REGEX=0 */' >> ${h}
1166 if feat_yes READLINE; then
1167 __edrdlib() {
1168 link_check readline "for readline(3) (${1})" \
1169 '#define HAVE_READLINE' "${1}" << \!
1170 #include <stdio.h>
1171 #include <readline/history.h>
1172 #include <readline/readline.h>
1173 int main(void)
1175 char *rl;
1176 HISTORY_STATE *hs;
1177 HIST_ENTRY **he;
1178 int i;
1179 using_history();
1180 read_history("");
1181 stifle_history(242);
1182 rl = readline("Enter a line:");
1183 if (rl && *rl)
1184 add_history(rl);
1185 write_history("");
1186 rl_extend_line_buffer(10);
1187 rl_point = rl_end = 10;
1188 rl_pre_input_hook = (rl_hook_func_t*)NULL;
1189 rl_forced_update_display();
1190 clear_history();
1191 hs = history_get_history_state();
1192 i = hs->length;
1193 he = history_list();
1194 if (i > 0)
1195 rl = he[0]->line;
1196 rl_free_line_state();
1197 rl_cleanup_after_signal();
1198 rl_reset_after_signal();
1199 return 0;
1204 __edrdlib -lreadline ||
1205 __edrdlib '-lreadline -ltermcap' || feat_bail_required READLINE
1206 [ -n "${have_readline}" ] && WANT_TABEXPAND=1
1209 if feat_yes EDITLINE && [ -z "${have_readline}" ]; then
1210 __edlib() {
1211 link_check editline "for editline(3) (${1})" \
1212 '#define HAVE_EDITLINE' "${1}" << \!
1213 #include <histedit.h>
1214 static char * getprompt(void) { return (char*)"ok"; }
1215 int main(void)
1217 EditLine *el_el = el_init("TEST", stdin, stdout, stderr);
1218 HistEvent he;
1219 History *el_hcom = history_init();
1220 history(el_hcom, &he, H_SETSIZE, 242);
1221 el_set(el_el, EL_SIGNAL, 0);
1222 el_set(el_el, EL_TERMINAL, NULL);
1223 el_set(el_el, EL_HIST, &history, el_hcom);
1224 el_set(el_el, EL_EDITOR, "emacs");
1225 el_set(el_el, EL_PROMPT, &getprompt);
1226 el_source(el_el, NULL);
1227 history(el_hcom, &he, H_GETSIZE);
1228 history(el_hcom, &he, H_CLEAR);
1229 el_end(el_el);
1230 /* TODO add loader and addfn checks */
1231 history_end(el_hcom);
1232 return 0;
1237 __edlib -ledit ||
1238 __edlib '-ledit -ltermcap' || feat_bail_required EDITLINE
1239 [ -n "${have_editline}" ] && WANT_TABEXPAND=0
1242 if feat_yes NCL && [ -z "${have_editline}" ] && [ -z "${have_readline}" ] &&\
1243 [ -n "${have_c90amend1}" ]; then
1244 have_ncl=1
1245 echo '#define HAVE_NCL' >> ${h}
1246 else
1247 feat_bail_required NCL
1248 echo '/* WANT_{READLINE,EDITLINE,NCL}=0 */' >> ${h}
1251 # Generic have-a-command-line-editor switch for those who need it below
1252 if [ -n "${have_ncl}" ] || [ -n "${have_editline}" ] ||\
1253 [ -n "${have_readline}" ]; then
1254 have_cle=1
1257 if [ -n "${have_cle}" ] && feat_yes HISTORY; then
1258 echo '#define HAVE_HISTORY' >> ${h}
1259 else
1260 echo '/* WANT_HISTORY=0 */' >> ${h}
1263 if [ -n "${have_cle}" ] && feat_yes TABEXPAND; then
1264 echo '#define HAVE_TABEXPAND' >> ${h}
1265 else
1266 echo '/* WANT_TABEXPAND=0 */' >> ${h}
1269 if feat_yes SPAM; then
1270 echo '#define HAVE_SPAM' >> ${h}
1271 if command -v spamc >/dev/null 2>&1; then
1272 echo "#define SPAMC_PATH \"`command -v spamc`\"" >> ${h}
1274 else
1275 echo '/* WANT_SPAM=0 */' >> ${h}
1278 if feat_yes DOCSTRINGS; then
1279 echo '#define HAVE_DOCSTRINGS' >> ${h}
1280 else
1281 echo '/* WANT_DOCSTRINGS=0 */' >> ${h}
1284 if feat_yes QUOTE_FOLD &&\
1285 [ -n "${have_c90amend1}" ] && [ -n "${have_wcwidth}" ]; then
1286 echo '#define HAVE_QUOTE_FOLD' >> ${h}
1287 else
1288 echo '/* WANT_QUOTE_FOLD=0 */' >> ${h}
1291 if feat_yes COLOUR; then
1292 echo '#define HAVE_COLOUR' >> ${h}
1293 else
1294 echo '/* WANT_COLOUR=0 */' >> ${h}
1297 if feat_yes MD5; then
1298 echo '#define HAVE_MD5' >> ${h}
1299 else
1300 echo '/* WANT_MD5=0 */' >> ${h}
1303 ## Summarizing ##
1305 # Since we cat(1) the content of those to cc/"ld", convert them to single line
1306 squeeze_em() {
1307 < "${1}" > "${2}" ${awk} \
1308 'BEGIN {ORS = " "} /^[^#]/ {print} {next} END {ORS = ""; print "\n"}'
1310 ${rm} -f ${tmp}
1311 squeeze_em ${inc} ${tmp}
1312 ${mv} ${tmp} ${inc}
1313 squeeze_em ${lib} ${tmp}
1314 ${mv} ${tmp} ${lib}
1316 # config.h
1317 ${mv} ${h} ${tmp}
1318 printf '#ifndef _CONFIG_H\n# define _CONFIG_H\n' > ${h}
1319 ${cat} ${tmp} >> ${h}
1321 printf '\n/* The "feature string", for "simplicity" and lex.c */\n' >> ${h}
1322 printf '#ifdef _MAIN_SOURCE\n' >> ${h}
1323 printf '# ifdef HAVE_AMALGAMATION\nstatic\n# endif\n' >> ${h}
1324 printf 'char const features[] = "MIME"\n' >> ${h}
1325 printf '# ifdef HAVE_SETLOCALE\n ",LOCALES"\n# endif\n' >> ${h}
1326 printf '# ifdef HAVE_C90AMEND1\n ",MULTIBYTE CHARSETS"\n# endif\n' >> ${h}
1327 printf '# ifdef HAVE_NL_LANGINFO\n ",TERMINAL CHARSET"\n# endif\n' >> ${h}
1328 printf '# ifdef HAVE_ICONV\n ",ICONV"\n# endif\n' >> ${h}
1329 printf '# ifdef HAVE_SOCKETS\n ",NETWORK"\n# endif\n' >> ${h}
1330 printf '# ifdef HAVE_IPV6\n ",IPv6"\n# endif\n' >> ${h}
1331 printf '# ifdef HAVE_SSL\n ",S/MIME,SSL/TLS"\n# endif\n' >> ${h}
1332 printf '# ifdef HAVE_SMTP\n ",SMTP"\n# endif\n' >> ${h}
1333 printf '# ifdef HAVE_POP3\n ",POP3"\n# endif\n' >> ${h}
1334 printf '# ifdef HAVE_IMAP\n ",IMAP"\n# endif\n' >> ${h}
1335 printf '# ifdef HAVE_GSSAPI\n ",GSS-API"\n# endif\n' >> ${h}
1336 printf '# ifdef HAVE_NETRC\n ",NETRC"\n# endif\n' >> ${h}
1337 printf '# ifdef HAVE_AGENT\n ",AGENT"\n# endif\n' >> ${h}
1338 printf '# ifdef HAVE_IDNA\n ",IDNA"\n# endif\n' >> ${h}
1339 printf '# ifdef HAVE_IMAP_SEARCH\n ",IMAP-searches"\n# endif\n' >> ${h}
1340 printf '# ifdef HAVE_REGEX\n ",REGEX"\n# endif\n' >> ${h}
1341 printf '# ifdef HAVE_READLINE\n ",READLINE"\n# endif\n' >> ${h}
1342 printf '# ifdef HAVE_EDITLINE\n ",EDITLINE"\n# endif\n' >> ${h}
1343 printf '# ifdef HAVE_NCL\n ",NCL"\n# endif\n' >> ${h}
1344 printf '# ifdef HAVE_TABEXPAND\n ",TABEXPAND"\n# endif\n' >> ${h}
1345 printf '# ifdef HAVE_HISTORY\n ",HISTORY"\n# endif\n' >> ${h}
1346 printf '# ifdef HAVE_SPAM\n ",SPAM"\n# endif\n' >> ${h}
1347 printf '# ifdef HAVE_DOCSTRINGS\n ",DOCSTRINGS"\n# endif\n' >> ${h}
1348 printf '# ifdef HAVE_QUOTE_FOLD\n ",QUOTE-FOLD"\n# endif\n' >> ${h}
1349 printf '# ifdef HAVE_COLOUR\n ",COLOUR"\n# endif\n' >> ${h}
1350 printf '# ifdef HAVE_DEBUG\n ",DEBUG"\n# endif\n' >> ${h}
1351 printf ';\n#endif /* _MAIN_SOURCE */\n' >> ${h}
1353 printf '#endif /* _CONFIG_H */\n' >> ${h}
1354 ${rm} -f ${tmp}
1356 # Create the real mk.mk
1357 ${rm} -rf ${tmp0}.* ${tmp0}*
1358 printf 'OBJ_SRC = ' >> ${mk}
1359 if feat_no AMALGAMATION; then
1360 echo *.c >> ${mk}
1361 echo 'OBJ_DEP =' >> ${mk}
1362 else
1363 j=`echo "${src}" | sed 's/^.\///'`
1364 echo "${j}" >> ${mk}
1365 printf 'OBJ_DEP = main.c ' >> ${mk}
1366 printf '#define _MAIN_SOURCE\n' >> ${src}
1367 printf '#include "nail.h"\n#include "main.c"\n' >> ${src}
1368 for i in *.c; do
1369 if [ "${i}" = "${j}" ] || [ "${i}" = main.c ]; then
1370 continue
1372 printf "${i} " >> ${mk}
1373 printf "#include \"${i}\"\n" >> ${src}
1374 done
1375 echo >> ${mk}
1378 echo "LIBS = `${cat} ${lib}`" >> ${mk}
1379 echo "INCLUDES = `${cat} ${inc}`" >> ${mk}
1380 echo >> ${mk}
1381 ${cat} ./mk-mk.in >> ${mk}
1383 ## Finished! ##
1385 ${cat} > ${tmp2}.c << \!
1386 #include "config.h"
1387 #ifdef HAVE_NL_LANGINFO
1388 # include <langinfo.h>
1389 #endif
1391 :The following optional features are enabled:
1392 #ifdef HAVE_SETLOCALE
1393 : + Locale support: Printable characters depend on the environment
1394 # ifdef HAVE_C90AMEND1
1395 : + Multibyte character support
1396 # endif
1397 # ifdef HAVE_NL_LANGINFO
1398 : + Automatic detection of terminal character set
1399 # endif
1400 #endif
1401 #ifdef HAVE_ICONV
1402 : + Character set conversion using iconv()
1403 #endif
1404 #ifdef HAVE_SOCKETS
1405 : + Network support
1406 #endif
1407 #ifdef HAVE_IPV6
1408 : + Support for Internet Protocol v6 (IPv6)
1409 #endif
1410 #ifdef HAVE_SSL
1411 # ifdef HAVE_OPENSSL
1412 : + S/MIME and SSL/TLS (OpenSSL)
1413 # endif
1414 #endif
1415 #ifdef HAVE_SMTP
1416 : + SMTP protocol
1417 #endif
1418 #ifdef HAVE_POP3
1419 : + POP3 protocol
1420 #endif
1421 #ifdef HAVE_IMAP
1422 : + IMAP protocol
1423 #endif
1424 #ifdef HAVE_GSSAPI
1425 : + GSS-API authentication
1426 #endif
1427 #ifdef HAVE_NETRC
1428 : + .netrc file support
1429 #endif
1430 #ifdef HAVE_AGENT
1431 : + Password query through agent
1432 #endif
1433 #ifdef HAVE_IDNA
1434 : + IDNA (internationalized domain names for applications) support
1435 #endif
1436 #ifdef HAVE_IMAP_SEARCH
1437 : + IMAP-style search expressions
1438 #endif
1439 #ifdef HAVE_REGEX
1440 : + Regular expression support (searches, conditional expressions etc.)
1441 #endif
1442 #if defined HAVE_READLINE || defined HAVE_EDITLINE || defined HAVE_NCL
1443 : + Command line editing
1444 # ifdef HAVE_TABEXPAND
1445 : + + Tabulator expansion
1446 # endif
1447 # ifdef HAVE_HISTORY
1448 : + + History management
1449 # endif
1450 #endif
1451 #ifdef HAVE_SPAM
1452 : + Interaction with spam filters
1453 #endif
1454 #ifdef HAVE_DOCSTRINGS
1455 : + Documentation summary strings
1456 #endif
1457 #ifdef HAVE_QUOTE_FOLD
1458 : + Extended *quote-fold*ing
1459 #endif
1460 #ifdef HAVE_COLOUR
1461 : + Coloured message display (simple)
1462 #endif
1464 :The following optional features are disabled:
1465 #ifndef HAVE_SETLOCALE
1466 : - Locale support: Only ASCII characters are recognized
1467 #endif
1468 # ifndef HAVE_C90AMEND1
1469 : - Multibyte character support
1470 # endif
1471 # ifndef HAVE_NL_LANGINFO
1472 : - Automatic detection of terminal character set
1473 # endif
1474 #ifndef HAVE_ICONV
1475 : - Character set conversion using iconv()
1476 #endif
1477 #ifndef HAVE_SOCKETS
1478 : - Network support
1479 #endif
1480 #ifndef HAVE_IPV6
1481 : - Support for Internet Protocol v6 (IPv6)
1482 #endif
1483 #ifndef HAVE_SSL
1484 : - S/MIME and SSL/TLS
1485 #endif
1486 #ifndef HAVE_SMTP
1487 : - SMTP protocol
1488 #endif
1489 #ifndef HAVE_POP3
1490 : - POP3 protocol
1491 #endif
1492 #ifndef HAVE_IMAP
1493 : - IMAP protocol
1494 #endif
1495 #ifndef HAVE_GSSAPI
1496 : - GSS-API authentication
1497 #endif
1498 #ifndef HAVE_NETRC
1499 : - .netrc file support
1500 #endif
1501 #ifndef HAVE_AGENT
1502 : - Password query through agent
1503 #endif
1504 #ifndef HAVE_IDNA
1505 : - IDNA (internationalized domain names for applications) support
1506 #endif
1507 #ifndef HAVE_IMAP_SEARCH
1508 : - IMAP-style search expressions
1509 #endif
1510 #ifndef HAVE_REGEX
1511 : - Regular expression support
1512 #endif
1513 #if !defined HAVE_READLINE && !defined HAVE_EDITLINE && !defined HAVE_NCL
1514 : - Command line editing and history
1515 #endif
1516 #ifndef HAVE_SPAM
1517 : - Interaction with spam filters
1518 #endif
1519 #ifndef HAVE_DOCSTRINGS
1520 : - Documentation summary strings
1521 #endif
1522 #ifndef HAVE_QUOTE_FOLD
1523 : - Extended *quote-fold*ing
1524 #endif
1525 #ifndef HAVE_COLOUR
1526 : - Coloured message display (simple)
1527 #endif
1529 :Remarks:
1530 #ifndef HAVE_SNPRINTF
1531 : . The function snprintf() could not be found. We will use and internal
1532 : sprintf() instead. This might overflow buffers if input values are larger
1533 : than expected. Use the resulting binary with care or update your system
1534 : environment and start the configuration process again.
1535 #endif
1536 #ifndef HAVE_FCHDIR
1537 : . The function fchdir() could not be found. We will use chdir()
1538 : instead. This is not a problem unless the current working
1539 : directory of mailx is moved while the IMAP cache is used.
1540 #endif
1541 #ifdef HAVE_DEBUG
1542 : . Debug enabled binary: not meant to be used by end-users: THANKS!
1543 #endif
1547 ${make} -f ${makefile} ${tmp2}.x
1548 < ${tmp2}.x >&5 ${sed} -e '/^[^:]/d; /^$/d; s/^://'
1550 # s-it-mode