2 #@ Please see `INSTALL' and `make.rc' instead.
7 # Predefined CONFIG= urations take precedence over anything else
8 if [ -n "${CONFIG}" ]; then
13 WANT_READLINE
=0 WANT_EDITLINE
=0 WANT_NCL
=0
24 WANT_READLINE
=0 WANT_EDITLINE
=0
33 WANT_READLINE
=0 WANT_EDITLINE
=0
43 echo >&2 "Unknown CONFIG= setting: ${CONFIG}"
44 echo >&2 'Possible values: MINIMAL, MEDIUM, NETSEND, MAXIMAL'
51 if nwantfeat SOCKETS
; then
52 WANT_IPV6
=0 WANT_SSL
=0
53 WANT_SMTP
=0 WANT_POP3
=0 WANT_IMAP
=0 WANT_GSSAPI
=0
54 WANT_NETRC
=0 WANT_AGENT
=0
56 if nwantfeat SMTP
&& nwantfeat POP3
&& nwantfeat IMAP
; then
57 WANT_SOCKETS
=0 WANT_IPV6
=0 WANT_SSL
=0 WANT_NETRC
=0 WANT_AGENT
=0
59 if nwantfeat SMTP
&& nwantfeat IMAP
; then
62 # If we don't need MD5 except for producing boundary and message-id strings,
63 # leave it off, plain old srand(3) should be enough for that purpose.
64 if nwantfeat SOCKETS
; then
67 if wantfeat DEBUG
; then
68 WANT_NOALLOCA
=1 WANT_DEVEL
=1
72 # Check out compiler ($CC) and -flags ($CFLAGS)
74 # $CC is overwritten when empty or a default "cc", even without WANT_AUTOCC
75 optim
= dbgoptim
= _CFLAGS
=
76 if [ -z "${CC}" ] ||
[ "${CC}" = cc
]; then
77 if { CC
="`command -v clang`"; }; then
79 elif { CC
="`command -v gcc`"; }; then
81 elif { CC
="`command -v c89`"; }; then
82 [ "`uname -s`" = UnixWare
] && _CFLAGS
=-v optim
=-O dbgoptim
=
83 elif { CC
="`command -v c99`"; }; then
87 echo >&2 ' I cannot find a compiler!'
88 echo >&2 ' Neither of clang(1), gcc(1), c89(1) and c99(1).'
89 echo >&2 ' Please set the CC environment variable, maybe CFLAGS also.'
95 ccver
=`${CC} --version 2>/dev/null`
97 if { i
=${ccver}; echo "${i}"; } |
${grep} -q -i -e gcc
-e clang
; then
98 #if echo "${i}" | ${grep} -q -i -e gcc -e 'clang version 1'; then
101 _CFLAGS
="${_CFLAGS} -std=c89 -Wall -Wextra -pedantic"
102 _CFLAGS
="${_CFLAGS} -fno-unwind-tables -fno-asynchronous-unwind-tables"
103 _CFLAGS
="${_CFLAGS} -fstrict-aliasing"
104 _CFLAGS
="${_CFLAGS} -Wbad-function-cast -Wcast-align -Wcast-qual"
105 _CFLAGS
="${_CFLAGS} -Winit-self -Wmissing-prototypes"
106 _CFLAGS
="${_CFLAGS} -Wshadow -Wunused -Wwrite-strings"
107 _CFLAGS
="${_CFLAGS} -Wno-long-long" # ISO C89 has no 'long long'...
108 if { i
=${ccver}; echo "${i}"; } |
${grep} -q -e 'clang version 1'; then
109 _CFLAGS
="${_CFLAGS} -Wstrict-overflow=5"
111 _CFLAGS
="${_CFLAGS} -fstrict-overflow -Wstrict-overflow=5"
112 if wantfeat AMALGAMATION
&& nwantfeat DEBUG
; then
113 _CFLAGS
="${_CFLAGS} -Wno-unused-function"
115 if { i
=${ccver}; echo "${i}"; } |
${grep} -q -i -e clang
; then
116 _CFLAGS
="${_CFLAGS} -Wno-unused-result" # TODO handle the right way
119 if wantfeat AMALGAMATION
; then
120 _CFLAGS
="${_CFLAGS} -pipe"
122 # elif { i=${ccver}; echo "${i}"; } | ${grep} -q -i -e clang; then
123 # optim=-O3 dbgoptim=-O
125 # _CFLAGS='-std=c89 -Weverything -Wno-long-long'
126 # if wantfeat AMALGAMATION; then
127 # _CFLAGS="${_CFLAGS} -pipe"
129 elif [ -z "${optim}" ]; then
130 optim
=-O1 dbgoptim
=-O
133 if nwantfeat DEBUG
; then
134 _CFLAGS
="${optim} -DNDEBUG ${_CFLAGS}"
136 _CFLAGS
="${dbgoptim} -g ${_CFLAGS}";
137 if [ "${stackprot}" = yes ]; then
138 _CFLAGS
="${_CFLAGS} -ftrapv -fstack-protector-all "
139 _CFLAGS
="${_CFLAGS} -Wstack-protector -D_FORTIFY_SOURCE=2"
142 _CFLAGS
="${_CFLAGS} ${ADDCFLAGS}"
143 # XXX -Wl,-z,relro -Wl,-z,now -Wl,-z,noexecstack: need detection
144 _LDFLAGS
="${_LDFLAGS} ${ADDLDFLAGS}" # XXX -Wl,--sort-common,[-O1]
145 export _CFLAGS _LDFLAGS
147 # $CFLAGS and $LDFLAGS are only overwritten if explicitly wanted
148 if wantfeat AUTOCC
; then
151 export CFLAGS LDFLAGS
158 ## - Heirloom sh(1) (and same origin) have problems with ': >' redirection,
159 ## so use "printf '' >" instead
160 ## - Heirloom sh(1) and maybe more execute loops with redirection in a subshell
161 ## (but don't export eval's from within), therefore we need to (re)include
162 ## variable assignments at toplevel instead (via reading temporary files)
164 ## First of all, create new configuration and check wether it changed ##
171 newlst
=.
/config.lst-new
172 newmk
=.
/config.mk-new
177 # We need some standard utilities
180 n
=$1 i
=$2 opt
=${3:-0}
181 if type "${i}" >/dev
/null
2>&1; then
185 if [ ${opt} -eq 0 ]; then
186 echo >&2 "ERROR: no trace of the utility \`${n}'"
192 # Check those tools right now that we need before including $rc
193 check_tool
rm "${rm:-`command -v rm`}"
194 check_tool
sed "${sed:-`command -v sed`}"
196 # Include $rc, but only take from it what wasn't overwritten by the user from
197 # within the command line or from a chosen fixed CONFIG=
198 # Note we leave alone the values
199 trap "${rm} -f ${tmp}; exit" 1 2 15
200 trap "${rm} -f ${tmp}" 0
203 < ${rc} ${sed} -e '/^[ \t]*#/d' -e '/^$/d' -e 's/[ \t]*$//' |
205 i
="`echo ${line} | ${sed} -e 's/=.*$//'`"
206 eval j
="\$${i}" jx="\${${i}+x}"
207 if [ -n "${j}" ] ||
[ "${jx}" = x
]; then
214 check_tool
awk "${awk:-`command -v awk`}"
215 check_tool
cat "${cat:-`command -v cat`}"
216 check_tool
chmod "${chmod:-`command -v chmod`}"
217 check_tool
cp "${cp:-`command -v cp`}"
218 check_tool
cmp "${cmp:-`command -v cmp`}"
219 check_tool
grep "${grep:-`command -v grep`}"
220 check_tool mkdir
"${mkdir:-`command -v mkdir`}"
221 check_tool
mv "${mv:-`command -v mv`}"
222 # rm(1), sed(1) above
223 check_tool
tee "${tee:-`command -v tee`}"
225 check_tool
make "${MAKE:-`command -v make`}"
226 check_tool strip
"${STRIP:-`command -v strip`}" 1
240 # (No function since some shells loose non-exported variables in traps)
241 trap "${rm} -f ${tmp} ${newlst} ${newmk} ${newh}; exit" 1 2 15
242 trap "${rm} -f ${tmp} ${newlst} ${newmk} ${newh}" 0
243 ${rm} -f ${newlst} ${newmk} ${newh}
245 # (Could: use FD redirection, add eval(1) and don't re-'. ./${newlst}')
247 i
=`echo ${line} | ${sed} -e 's/=.*$//'`
249 if [ -z "${j}" ] ||
[ "${j}" = 0 ]; then
250 printf "/*#define ${i}*/\n" >> ${newh}
251 elif [ "${j}" = 1 ]; then
252 printf "#define ${i}\n" >> ${newh}
254 printf "#define ${i} \"${j}\"\n" >> ${newh}
256 printf "${i} = ${j}\n" >> ${newmk}
257 printf "${i}=\"${j}\"\n"
258 done < ${tmp} > ${newlst}
261 printf "#define UAGENT \"${SID}${NAIL}\"\n" >> ${newh}
262 printf "UAGENT
= ${SID}${NAIL}\n" >> ${newmk}
266 printf "CC = ${CC}\n" >> ${newmk}
267 printf "_CFLAGS = ${_CFLAGS}\nCFLAGS = ${CFLAGS}\n" >> ${newmk}
268 printf "_LDFLAGS
= ${_LDFLAGS}\nLDFLAGS = ${LDFLAGS}\n" >> ${newmk}
269 printf "AWK = ${awk}\nCMP = ${cmp}\nCHMOD = ${chmod}\nCP = ${cp}\n" >> ${newmk}
270 printf "GREP
= ${grep}\nMKDIR = ${mkdir}\nRM = ${rm}\nSED = ${sed}\n" \
272 printf "STRIP
= ${strip}\nHAVE_STRIP = ${HAVE_STRIP}\n" >> ${newmk}
273 # (We include the cc(1)/ld(1) environment only for update detection..)
274 printf "CC=\"${CC}\"\n" >> ${newlst}
275 printf "_CFLAGS=\"${_CFLAGS}\"\nCFLAGS=\"${CFLAGS}\"\n" >> ${newlst}
276 printf "_LDFLAGS
=\"${_LDFLAGS}\"\nLDFLAGS=\"${LDFLAGS}\"\n" >> ${newlst}
277 printf "AWK=${awk}\nCMP=${cmp}\nCHMOD=${chmod}\nCP=${cp}\n" >> ${newlst}
278 printf "GREP
=${grep}\nMKDIR=${mkdir}\nRM=${rm}\nSED=${sed}\n" >> ${newlst}
279 printf "STRIP=${strip}\nHAVE_STRIP=${HAVE_STRIP}\n" >> ${newlst}
281 if [ -f ${lst} ] && ${cmp} ${newlst} ${lst} >/dev/null 2>&1; then
284 [ -f ${lst} ] && echo 'configuration updated..' || echo 'shiny configuration..'
286 ${mv} -f ${newlst} ${lst}
287 ${mv} -f ${newh} ${h}
288 ${mv} -f ${newmk} ${mk}
290 ## Compile and link checking ##
300 # (No function since some shells loose non-exported variables in traps)
301 trap "${rm} -f ${lst} ${h} ${mk} ${lib} ${inc} ${src} ${makefile}; exit" 1 2 15
302 trap "${rm} -rf ${tmp0}.* ${tmp0}* ${makefile}" 0
304 exec 5>&2 > ${log} 2>&1
307 # ${src} is only created if WANT_AMALGAMATION
309 ${cat} > ${makefile} << \!
310 .SUFFIXES: .o .c .x .y
314 $(CC) $(XINCS) -E $< >$@
316 $(CC) $(XINCS) -o $@ $< $(XLIBS)
324 printf "*** ${fmt}\\n
" "${@}"
325 printf "${fmt}" "${@}" >&5
329 variable=$1 topic=$2 define=$3
332 msg "checking
${topic} ...
"
333 echo "/* checked
${topic} */" >> ${h}
334 ${rm} -f ${tmp} ${tmp}.o
335 echo '*** test program is'
337 #echo '*** the preprocessor generates'
338 #${make} -f ${makefile} ${tmp}.x
340 echo '*** results are'
344 variable=$1 topic=$2 define=$3
346 _check_preface "${variable}" "${topic}" "${define}"
348 if ${make} -f ${makefile} XINCS="${INCS}" ./${tmp}.o &&
349 [ -f ./${tmp}.o ]; then
351 echo "${define}" >> ${h}
352 eval have_${variable}=yes
355 echo "/* ${define} */" >> ${h}
357 eval unset have_${variable}
363 run=$1 variable=$2 topic=$3 define=$4 libs=$5 incs=$6
365 _check_preface "${variable}" "${topic}" "${define}"
367 if ${make} -f ${makefile} XINCS="${INCS} ${incs}" \
368 XLIBS
="${LIBS} ${libs}" ./${tmp} &&
370 { [ ${run} -eq 0 ] || ./${tmp}; }; then
371 echo "*** adding INCS
<${incs}> LIBS
<${libs}>"
373 echo "${define}" >> ${h}
374 LIBS="${LIBS} ${libs}"
375 echo "${libs}" >> ${lib}
376 INCS="${INCS} ${incs}"
377 echo "${incs}" >> ${inc}
378 eval have_${variable}=yes
382 echo "/* ${define} */" >> ${h}
383 eval unset have_${variable}
389 _link_mayrun 0 "${1}" "${2}" "${3}" "${4}" "${5}"
393 _link_mayrun 1 "${1}" "${2}" "${3}" "${4}" "${5}"
396 # Build a basic set of INCS and LIBS according to user environment.
397 # On pkgsrc(7) systems automatically add /usr/pkg/*
398 if [ -n "${C_INCLUDE_PATH}" ]; then
401 set -- ${C_INCLUDE_PATH}
403 # for i; do -- new in POSIX Issue 7 + TC1
406 [ "${i}" = '/usr/pkg/include' ] && continue
407 INCS="${INCS} -I${i}"
410 [ -d /usr/pkg/include ] && INCS="${INCS} -I/usr
/pkg
/include
"
411 echo "${INCS}" >> ${inc}
413 if [ -n "${LD_LIBRARY_PATH}" ]; then
416 set -- ${LD_LIBRARY_PATH}
418 # for i; do -- new in POSIX Issue 7 + TC1
421 [ "${i}" = '/usr/pkg/lib' ] && continue
422 LIBS="${LIBS} -L${i}"
425 [ -d /usr/pkg/lib ] && LIBS="${LIBS} -L/usr
/pkg
/lib
"
426 echo "${LIBS}" >> ${lib}
430 # Better set _GNU_SOURCE (if we are on Linux only?); 'surprised it did without
431 echo '#define _GNU_SOURCE' >> ${h}
433 if link_check hello 'if a hello world program can be built' << \!
436 int main(int argc, char *argv[])
447 echo >&5 'This oooops is most certainly not related to me.'
448 echo >&5 "Read the
file ${log} and check your compiler environment.
"
449 ${rm} -f ${lst} ${h} ${mk}
453 if link_check termios 'for termios.h and tc*() family' << \!
459 tcsetattr(0, TCSADRAIN | TCSAFLUSH, &tios);
466 echo >&5 'We require termios.h and the tc*() family of functions.'
467 echo >&5 "That much Unix we indulge ourselfs.
"
468 ${rm} -f ${lst} ${h} ${mk}
472 link_check setenv 'for setenv()/unsetenv()' '#define HAVE_SETENV' << \!
476 setenv("s-nail
", "to be made nifty
!", 1);
482 link_check snprintf 'for snprintf()' '#define HAVE_SNPRINTF' << \!
487 snprintf(b, sizeof b, "%s
", "string
");
492 link_check putc_unlocked 'for putc_unlocked()' '#define HAVE_PUTC_UNLOCKED' <<\!
496 putc_unlocked('@', stdout);
501 link_check fchdir 'for fchdir()' '#define HAVE_FCHDIR' << \!
510 link_check pipe2 'for pipe2()' '#define HAVE_PIPE2' << \!
516 pipe2(fds, O_CLOEXEC);
521 link_check mmap 'for mmap()' '#define HAVE_MMAP' << \!
522 #include <sys/types.h>
523 #include <sys/mman.h>
526 mmap(0, 0, 0, 0, 0, 0);
531 link_check mremap 'for mremap()' '#define HAVE_MREMAP' << \!
532 #include <sys/types.h>
533 #include <sys/mman.h>
536 mremap(0, 0, 0, MREMAP_MAYMOVE);
541 link_check setlocale 'for setlocale()' '#define HAVE_SETLOCALE' << \!
545 setlocale(LC_ALL, "");
550 if [ "${have_setlocale}" = yes ]; then
551 link_check c90amend1 'for ISO/IEC 9899:1990/Amendment 1:1995' \
552 '#define HAVE_C90AMEND1' << \!
559 char mbb[MB_LEN_MAX + 1];
564 mbrtowc(&wc, "x
", 1, NULL);
565 (void)wctomb(mbb, wc);
566 return (mblen("\
0", 1) == 0);
570 if [ "${have_c90amend1}" = yes ]; then
571 link_check wcwidth 'for wcwidth()' '#define HAVE_WCWIDTH' << \!
581 link_check nl_langinfo 'for nl_langinfo()' '#define HAVE_NL_LANGINFO' << \!
582 #include <langinfo.h>
587 return (nl_langinfo(CODESET) == NULL);
592 link_check mkstemp 'for mkstemp()' '#define HAVE_MKSTEMP' << \!
601 # Note: run_check, thus we also get only the desired implementation...
602 run_check realpath 'for realpath()' '#define HAVE_REALPATH' << \!
606 char *x = realpath(".
", NULL), *y = realpath("/", NULL);
607 return (x != NULL && y != NULL) ? 0 : 1;
611 link_check wordexp 'for wordexp()' '#define HAVE_WORDEXP' << \!
615 wordexp((char *)0, (wordexp_t *)0, 0);
622 if wantfeat DEBUG; then
623 echo '#define HAVE_DEBUG' >> ${h}
626 if wantfeat AMALGAMATION; then
627 echo '#define HAVE_AMALGAMATION' >> ${h}
630 if nwantfeat NOALLOCA; then
631 # Due to NetBSD PR lib/47120 it seems best not to use non-cc-builtin
632 # versions of alloca(3) since modern compilers just can't be trusted
633 # not to overoptimize and silently break some code
634 link_check alloca 'for __builtin_alloca()' \
635 '#define HAVE_ALLOCA __builtin_alloca' << \!
638 void *vp = __builtin_alloca(1);
644 if wantfeat DEVEL; then
645 echo '#define HAVE_DEVEL' >> ${h}
648 if wantfeat NYD2; then
649 echo '#define HAVE_NYD2' >> ${h}
654 if wantfeat ICONV; then
655 ${cat} > ${tmp2}.c << \!
661 id = iconv_open("foo
", "bar
");
665 < ${tmp2}.c link_check iconv 'for iconv functionality' \
666 '#define HAVE_ICONV' ||
667 < ${tmp2}.c link_check iconv \
668 'for iconv functionality in libiconv' \
669 '#define HAVE_ICONV' '-liconv'
671 echo '/* WANT_ICONV=0 */' >> ${h}
674 if wantfeat SOCKETS; then
675 compile_check arpa_inet_h 'for <arpa/inet.h>' \
676 '#define HAVE_ARPA_INET_H' << \!
678 #include <sys/types.h>
679 #include <sys/socket.h>
681 #include <netinet/in.h>
682 #include <arpa/inet.h>
685 ${cat} > ${tmp2}.c << \!
687 #include <sys/types.h>
688 #include <sys/socket.h>
690 #include <netinet/in.h>
691 #ifdef HAVE_ARPA_INET_H
692 #include <arpa/inet.h>
698 socket(AF_INET, SOCK_STREAM, 0);
700 gethostbyname("foo
");
705 < ${tmp2}.c link_check sockets 'for sockets in libc' \
706 '#define HAVE_SOCKETS' ||
707 < ${tmp2}.c link_check sockets 'for sockets in libnsl' \
708 '#define HAVE_SOCKETS' '-lnsl' ||
709 < ${tmp2}.c link_check sockets \
710 'for sockets in libsocket and libnsl' \
711 '#define HAVE_SOCKETS' '-lsocket -lnsl' ||
714 # XXX Shouldn't it be a hard error if there is no socket support, then?
717 echo '/* WANT_SOCKETS=0 */' >> ${h}
718 fi # wantfeat SOCKETS
721 link_check setsockopt 'for setsockopt()' '#define HAVE_SETSOCKOPT' << \!
722 #include <sys/socket.h>
727 setsockopt(sockfd, SOL_SOCKET, SO_KEEPALIVE, NULL, 0);
732 wantfeat SOCKETS && [ -n "${have_setsockopt}" ] &&
733 link_check so_sndtimeo 'for SO_SNDTIMEO' '#define HAVE_SO_SNDTIMEO' << \!
734 #include <sys/socket.h>
742 setsockopt(sockfd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof tv);
743 setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof tv);
748 wantfeat SOCKETS && [ -n "${have_setsockopt}" ] &&
749 link_check so_linger 'for SO_LINGER' '#define HAVE_SO_LINGER' << \!
750 #include <sys/socket.h>
758 setsockopt(sockfd, SOL_SOCKET, SO_LINGER, &li, sizeof li);
763 if wantfeat IPV6; then
764 link_check ipv6 'for IPv6 functionality' '#define HAVE_IPV6' << \!
766 #include <sys/types.h>
767 #include <sys/socket.h>
769 #include <netinet/in.h>
770 #ifdef HAVE_ARPA_INET_H
771 #include <arpa/inet.h>
776 struct addrinfo a, *ap;
777 getaddrinfo("foo
", "0", &a, &ap);
782 echo '/* WANT_IPV6=0 */' >> ${h}
785 if wantfeat SSL; then
786 link_check openssl 'for sufficiently recent OpenSSL' \
788 #define HAVE_OPENSSL' '-lssl -lcrypto' << \!
789 #include <openssl/ssl.h>
790 #include <openssl/err.h>
791 #include <openssl/x509v3.h>
792 #include <openssl/x509.h>
793 #include <openssl/rand.h>
795 #if defined OPENSSL_NO_SSL2 && defined OPENSSL_NO_SSL3 &&\
796 defined OPENSSL_NO_TLS1
797 # error We need one of (SSLv2 and) SSLv3 and TLS1.
802 SSLv23_client_method();
803 #ifndef OPENSSL_NO_SSL3
804 SSLv3_client_method();
806 #ifndef OPENSSL_NO_TLS1
807 TLSv1_client_method();
808 # ifdef TLS1_1_VERSION
809 TLSv1_1_client_method();
811 # ifdef TLS1_2_VERSION
812 TLSv1_2_client_method();
815 PEM_read_PrivateKey(0, 0, 0, 0);
820 if [ "${have_openssl}" = 'yes' ]; then
821 compile_check stack_of 'for OpenSSL STACK_OF()' \
822 '#define HAVE_OPENSSL_STACK_OF' << \!
823 #include <openssl/ssl.h>
824 #include <openssl/err.h>
825 #include <openssl/x509v3.h>
826 #include <openssl/x509.h>
827 #include <openssl/rand.h>
831 STACK_OF(GENERAL_NAME) *gens = NULL;
832 printf("%p
", gens); /* to make it used */
837 link_check rand_egd 'for OpenSSL RAND_egd()' \
838 '#define HAVE_OPENSSL_RAND_EGD' '-lssl -lcrypto' << \!
839 #include <openssl/rand.h>
843 return RAND_egd("some.where
") > 0;
847 if wantfeat MD5 && nwantfeat NOEXTMD5; then
848 run_check openssl_md5 'for MD5 digest in OpenSSL' \
849 '#define HAVE_OPENSSL_MD5' << \!
851 #include <openssl/md5.h>
855 char const dat[] = "abrakadabrafidibus
";
856 char dig[16], hex[16 * 2];
860 memset(dig, 0, sizeof(dig));
861 memset(hex, 0, sizeof(hex));
863 MD5_Update(&ctx, dat, sizeof(dat) - 1);
864 MD5_Final(dig, &ctx);
866 #define hexchar(n) ((n) > 9 ? (n) - 10 + 'a' : (n) + '0')
867 for (i = 0; i < sizeof(hex) / 2; i++) {
869 hex[j] = hexchar((dig[i] & 0xf0) >> 4);
870 hex[++j] = hexchar(dig[i] & 0x0f);
872 return !!memcmp("6d7d0a3d949da2e96f2aa010f65d8326
", hex, sizeof(hex));
875 fi # wantfeat MD5 && nwantfeat NOEXTMD5
878 echo '/* WANT_SSL=0 */' >> ${h}
881 if wantfeat SMTP; then
882 echo '#define HAVE_SMTP' >> ${h}
884 echo '/* WANT_SMTP=0 */' >> ${h}
887 if wantfeat POP3; then
888 echo '#define HAVE_POP3' >> ${h}
890 echo '/* WANT_POP3=0 */' >> ${h}
893 if wantfeat IMAP; then
894 echo '#define HAVE_IMAP' >> ${h}
896 echo '/* WANT_IMAP=0 */' >> ${h}
899 if wantfeat GSSAPI; then
900 ${cat} > ${tmp2}.c << \!
901 #include <gssapi/gssapi.h>
905 gss_import_name(0, 0, GSS_C_NT_HOSTBASED_SERVICE, 0);
906 gss_init_sec_context(0,0,0,0,0,0,0,0,0,0,0,0,0);
910 ${sed} -e '1s/gssapi\///' < ${tmp2}.c > ${tmp3}.c
912 if command -v krb5-config >/dev/null 2>&1; then
913 i=`command -v krb5-config`
914 GSS_LIBS="`CFLAGS= ${i} --libs gssapi`"
915 GSS_INCS="`CFLAGS= ${i} --cflags`"
916 i='for GSS-API via krb5-config(1)'
920 i='for GSS-API in gssapi/gssapi.h, libgssapi'
922 < ${tmp2}.c link_check gss \
923 "${i}" '#define HAVE_GSSAPI' "${GSS_LIBS}" "${GSS_INCS}" ||\
924 < ${tmp3}.c link_check gss \
925 'for GSS-API in gssapi.h, libgssapi' \
927 #define GSSAPI_REG_INCLUDE' \
929 < ${tmp2}.c link_check gss 'for GSS-API in libgssapi_krb5' \
930 '#define HAVE_GSSAPI' \
932 < ${tmp3}.c link_check gss \
933 'for GSS-API in libgssapi, OpenBSD-style (pre 5.3)' \
935 #define GSS_REG_INCLUDE' \
936 '-lgssapi -lkrb5 -lcrypto' \
937 '-I/usr/include/kerberosV' ||\
938 < ${tmp2}.c link_check gss 'for GSS-API in libgss' \
939 '#define HAVE_GSSAPI' \
941 link_check gss 'for GSS-API in libgssapi_krb5, old-style' \
943 #define GSSAPI_OLD_STYLE' \
944 '-lgssapi_krb5' << \!
945 #include <gssapi/gssapi.h>
946 #include <gssapi/gssapi_generic.h>
950 gss_import_name(0, 0, gss_nt_service_name, 0);
951 gss_init_sec_context(0,0,0,0,0,0,0,0,0,0,0,0,0);
956 echo '/* WANT_GSSAPI=0 */' >> ${h}
959 if wantfeat NETRC; then
960 echo '#define HAVE_NETRC' >> ${h}
962 echo '/* WANT_NETRC=0 */' >> ${h}
965 if wantfeat AGENT; then
966 echo '#define HAVE_AGENT' >> ${h}
968 echo '/* WANT_AGENT=0 */' >> ${h}
971 if wantfeat IDNA; then
972 link_check idna 'for GNU Libidn' '#define HAVE_IDNA' '-lidn' << \!
974 #include <idn-free.h>
975 #include <stringprep.h>
978 char *utf8, *idna_ascii, *idna_utf8;
979 utf8 = stringprep_locale_to_utf8("does.this.work
");
980 if (idna_to_ascii_8z(utf8, &idna_ascii, IDNA_USE_STD3_ASCII_RULES)
983 idn_free(idna_ascii);
984 /* (Rather link check only here) */
985 idna_utf8 = stringprep_convert(idna_ascii, "UTF-8
", "de_DE
");
990 echo '/* WANT_IDNA=0 */' >> ${h}
993 if wantfeat IMAP_SEARCH; then
994 echo '#define HAVE_IMAP_SEARCH' >> ${h}
996 echo '/* WANT_IMAP_SEARCH=0 */' >> ${h}
999 if wantfeat REGEX; then
1000 link_check regex 'for regular expressions' '#define HAVE_REGEX' << \!
1007 if (regcomp(&re, ".
*bsd
", REG_EXTENDED | REG_ICASE | REG_NOSUB) != 0)
1009 status = regexec(&re, "plan9
", 0,NULL, 0);
1011 return !(status == REG_NOMATCH);
1015 echo '/* WANT_REGEX=0 */' >> ${h}
1018 if wantfeat READLINE; then
1020 link_check readline "for readline
(3) (${1})" \
1021 '#define HAVE_READLINE' "${1}" << \!
1023 #include <readline/history.h>
1024 #include <readline/readline.h>
1033 stifle_history(242);
1034 rl = readline("Enter a line
:");
1038 rl_extend_line_buffer(10);
1039 rl_point = rl_end = 10;
1040 rl_pre_input_hook = (rl_hook_func_t*)NULL;
1041 rl_forced_update_display();
1043 hs = history_get_history_state();
1045 he = history_list();
1048 rl_free_line_state();
1049 rl_cleanup_after_signal();
1050 rl_reset_after_signal();
1056 __edrdlib -lreadline ||
1057 __edrdlib '-lreadline -ltermcap'
1058 [ -n "${have_readline}" ] && WANT_TABEXPAND=1
1061 if wantfeat EDITLINE && [ -z "${have_readline}" ]; then
1063 link_check editline "for editline
(3) (${1})" \
1064 '#define HAVE_EDITLINE' "${1}" << \!
1065 #include <histedit.h>
1066 static char * getprompt(void) { return (char*)"ok
"; }
1069 EditLine *el_el = el_init("TEST
", stdin, stdout, stderr);
1071 History *el_hcom = history_init();
1072 history(el_hcom, &he, H_SETSIZE, 242);
1073 el_set(el_el, EL_SIGNAL, 0);
1074 el_set(el_el, EL_TERMINAL, NULL);
1075 el_set(el_el, EL_HIST, &history, el_hcom);
1076 el_set(el_el, EL_EDITOR, "emacs
");
1077 el_set(el_el, EL_PROMPT, &getprompt);
1078 el_source(el_el, NULL);
1079 history(el_hcom, &he, H_GETSIZE);
1080 history(el_hcom, &he, H_CLEAR);
1082 /* TODO add loader and addfn checks */
1083 history_end(el_hcom);
1090 __edlib '-ledit -ltermcap'
1091 [ -n "${have_editline}" ] && WANT_TABEXPAND=0
1094 if wantfeat NCL && [ -z "${have_editline}" ] && [ -z "${have_readline}" ] &&\
1095 [ -n "${have_c90amend1}" ]; then
1097 echo '#define HAVE_NCL' >> ${h}
1099 echo '/* WANT_{READLINE,EDITLINE,NCL}=0 */' >> ${h}
1102 # Generic have-a-command-line-editor switch for those who need it below
1103 if [ -n "${have_ncl}" ] || [ -n "${have_editline}" ] ||\
1104 [ -n "${have_readline}" ]; then
1108 if [ -n "${have_cle}" ] && wantfeat HISTORY; then
1109 echo '#define HAVE_HISTORY' >> ${h}
1111 echo '/* WANT_HISTORY=0 */' >> ${h}
1114 if [ -n "${have_cle}" ] && wantfeat TABEXPAND; then
1115 echo '#define HAVE_TABEXPAND' >> ${h}
1117 echo '/* WANT_TABEXPAND=0 */' >> ${h}
1120 if wantfeat SPAM; then
1121 echo '#define HAVE_SPAM' >> ${h}
1122 if command -v spamc >/dev/null 2>&1; then
1123 echo "#define SPAMC_PATH \"`command -v spamc`\"" >> ${h}
1126 echo '/* WANT_SPAM=0 */' >> ${h}
1129 if wantfeat DOCSTRINGS
; then
1130 echo '#define HAVE_DOCSTRINGS' >> ${h}
1132 echo '/* WANT_DOCSTRINGS=0 */' >> ${h}
1135 if wantfeat QUOTE_FOLD
&&\
1136 [ -n "${have_c90amend1}" ] && [ -n "${have_wcwidth}" ]; then
1137 echo '#define HAVE_QUOTE_FOLD' >> ${h}
1139 echo '/* WANT_QUOTE_FOLD=0 */' >> ${h}
1142 if wantfeat COLOUR
; then
1143 echo '#define HAVE_COLOUR' >> ${h}
1145 echo '/* WANT_COLOUR=0 */' >> ${h}
1148 if wantfeat MD5
; then
1149 echo '#define HAVE_MD5' >> ${h}
1151 echo '/* WANT_MD5=0 */' >> ${h}
1156 # Since we cat(1) the content of those to cc/"ld", convert them to single line
1158 < "${1}" > "${2}" ${awk} \
1159 'BEGIN {ORS = " "} /^[^#]/ {print} {next} END {ORS = ""; print "\n"}'
1162 squeeze_em ${inc} ${tmp}
1164 squeeze_em ${lib} ${tmp}
1169 printf '#ifndef _CONFIG_H\n# define _CONFIG_H\n' > ${h}
1170 ${cat} ${tmp} >> ${h}
1172 printf '\n/* The "feature string
", for "simplicity
" and lex.c */\n' >> ${h}
1173 printf '#ifdef _MAIN_SOURCE\n' >> ${h}
1174 printf '# ifdef HAVE_AMALGAMATION\nstatic\n# endif\n' >> ${h}
1175 printf 'char const features[] = "MIME
"\n' >> ${h}
1176 printf '# ifdef HAVE_SETLOCALE\n ",LOCALES
"\n# endif\n' >> ${h}
1177 printf '# ifdef HAVE_C90AMEND1\n ",MULTIBYTE CHARSETS
"\n# endif\n' >> ${h}
1178 printf '# ifdef HAVE_NL_LANGINFO\n ",TERMINAL CHARSET
"\n# endif\n' >> ${h}
1179 printf '# ifdef HAVE_ICONV\n ",ICONV
"\n# endif\n' >> ${h}
1180 printf '# ifdef HAVE_SOCKETS\n ",NETWORK
"\n# endif\n' >> ${h}
1181 printf '# ifdef HAVE_IPV6\n ",IPv6
"\n# endif\n' >> ${h}
1182 printf '# ifdef HAVE_SSL\n ",S
/MIME
,SSL
/TLS
"\n# endif\n' >> ${h}
1183 printf '# ifdef HAVE_SMTP\n ",SMTP
"\n# endif\n' >> ${h}
1184 printf '# ifdef HAVE_POP3\n ",POP3
"\n# endif\n' >> ${h}
1185 printf '# ifdef HAVE_IMAP\n ",IMAP
"\n# endif\n' >> ${h}
1186 printf '# ifdef HAVE_GSSAPI\n ",GSS-API
"\n# endif\n' >> ${h}
1187 printf '# ifdef HAVE_NETRC\n ",NETRC
"\n# endif\n' >> ${h}
1188 printf '# ifdef HAVE_AGENT\n ",AGENT
"\n# endif\n' >> ${h}
1189 printf '# ifdef HAVE_IDNA\n ",IDNA
"\n# endif\n' >> ${h}
1190 printf '# ifdef HAVE_IMAP_SEARCH\n ",IMAP-searches
"\n# endif\n' >> ${h}
1191 printf '# ifdef HAVE_REGEX\n ",REGEX
"\n# endif\n' >> ${h}
1192 printf '# ifdef HAVE_READLINE\n ",READLINE
"\n# endif\n' >> ${h}
1193 printf '# ifdef HAVE_EDITLINE\n ",EDITLINE
"\n# endif\n' >> ${h}
1194 printf '# ifdef HAVE_NCL\n ",NCL
"\n# endif\n' >> ${h}
1195 printf '# ifdef HAVE_TABEXPAND\n ",TABEXPAND
"\n# endif\n' >> ${h}
1196 printf '# ifdef HAVE_HISTORY\n ",HISTORY
"\n# endif\n' >> ${h}
1197 printf '# ifdef HAVE_SPAM\n ",SPAM
"\n# endif\n' >> ${h}
1198 printf '# ifdef HAVE_DOCSTRINGS\n ",DOCSTRINGS
"\n# endif\n' >> ${h}
1199 printf '# ifdef HAVE_QUOTE_FOLD\n ",QUOTE-FOLD
"\n# endif\n' >> ${h}
1200 printf '# ifdef HAVE_COLOUR\n ",COLOUR
"\n# endif\n' >> ${h}
1201 printf '# ifdef HAVE_DEBUG\n ",DEBUG
"\n# endif\n' >> ${h}
1202 printf ';\n#endif /* _MAIN_SOURCE */\n' >> ${h}
1204 printf '#endif /* _CONFIG_H */\n' >> ${h}
1207 # Create the real mk.mk
1208 ${rm} -rf ${tmp0}.* ${tmp0}*
1209 printf 'OBJ_SRC = ' >> ${mk}
1210 if nwantfeat AMALGAMATION; then
1212 echo 'OBJ_DEP =' >> ${mk}
1214 j=`echo "${src}" | sed 's/^.\///'`
1215 echo "${j}" >> ${mk}
1216 printf 'OBJ_DEP = main.c ' >> ${mk}
1217 printf '#define _MAIN_SOURCE\n' >> ${src}
1218 printf '#include "nail.h
"\n#include "main.c
"\n' >> ${src}
1220 if [ "${i}" = "${j}" ] || [ "${i}" = main.c ]; then
1223 printf "${i} " >> ${mk}
1224 printf "#include \"${i}\"\n" >> ${src}
1229 echo "LIBS = `${cat} ${lib}`" >> ${mk}
1230 echo "INCLUDES
= `${cat} ${inc}`" >> ${mk}
1232 ${cat} ./mk-mk.in >> ${mk}
1236 ${cat} > ${tmp2}.c << \!
1238 #ifdef HAVE_NL_LANGINFO
1239 # include <langinfo.h>
1242 :The following optional features are enabled:
1243 #ifdef HAVE_SETLOCALE
1244 : + Locale support: Printable characters depend on the environment
1245 # ifdef HAVE_C90AMEND1
1246 : + Multibyte character support
1248 # ifdef HAVE_NL_LANGINFO
1249 : + Automatic detection of terminal character set
1253 : + Character set conversion using iconv()
1259 : + Support for Internet Protocol v6 (IPv6)
1262 # ifdef HAVE_OPENSSL
1263 : + S/MIME and SSL/TLS (OpenSSL)
1276 : + GSS-API authentication
1279 : + .netrc file support
1282 : + Password query through agent
1285 : + IDNA (internationalized domain names for applications) support
1287 #ifdef HAVE_IMAP_SEARCH
1288 : + IMAP-style search expressions
1291 : + Regular expression support (searches, conditional expressions etc.)
1293 #if defined HAVE_READLINE || defined HAVE_EDITLINE || defined HAVE_NCL
1294 : + Command line editing
1295 # ifdef HAVE_TABEXPAND
1296 : + + Tabulator expansion
1298 # ifdef HAVE_HISTORY
1299 : + + History management
1303 : + Interaction with spam filters
1305 #ifdef HAVE_DOCSTRINGS
1306 : + Documentation summary strings
1308 #ifdef HAVE_QUOTE_FOLD
1309 : + Extended *quote-fold*ing
1312 : + Coloured message display (simple)
1315 :The following optional features are disabled:
1316 #ifndef HAVE_SETLOCALE
1317 : - Locale support: Only ASCII characters are recognized
1319 # ifndef HAVE_C90AMEND1
1320 : - Multibyte character support
1322 # ifndef HAVE_NL_LANGINFO
1323 : - Automatic detection of terminal character set
1326 : - Character set conversion using iconv()
1328 #ifndef HAVE_SOCKETS
1332 : - Support for Internet Protocol v6 (IPv6)
1335 : - S/MIME and SSL/TLS
1347 : - GSS-API authentication
1350 : - .netrc file support
1353 : - Password query through agent
1356 : - IDNA (internationalized domain names for applications) support
1358 #ifndef HAVE_IMAP_SEARCH
1359 : - IMAP-style search expressions
1362 : - Regular expression support
1364 #if !defined HAVE_READLINE && !defined HAVE_EDITLINE && !defined HAVE_NCL
1365 : - Command line editing and history
1368 : - Interaction with spam filters
1370 #ifndef HAVE_DOCSTRINGS
1371 : - Documentation summary strings
1373 #ifndef HAVE_QUOTE_FOLD
1374 : - Extended *quote-fold*ing
1377 : - Coloured message display (simple)
1381 #ifndef HAVE_SNPRINTF
1382 : . The function snprintf() could not be found. We will use and internal
1383 : sprintf() instead. This might overflow buffers if input values are larger
1384 : than expected. Use the resulting binary with care or update your system
1385 : environment and start the configuration process again.
1388 : . The function fchdir() could not be found. We will use chdir()
1389 : instead. This is not a problem unless the current working
1390 : directory of mailx is moved while the IMAP cache is used.
1393 : . Debug enabled binary: not meant to be used by end-users: THANKS!
1398 ${make} -f ${makefile} ${tmp2}.x
1399 < ${tmp2}.x >&5 ${sed} -e '/^[^:]/d; /^$/d; s/^://'