2 #@ Please see `INSTALL' and `conf.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 ${conf}
193 check_tool
rm "${rm:-`command -v rm`}"
194 check_tool
sed "${sed:-`command -v sed`}"
196 # Only incorporate what wasn't overwritten from command line / CONFIG
197 trap "${rm} -f ${tmp}; exit" 1 2 15
198 trap "${rm} -f ${tmp}" 0
201 < ${conf} ${sed} -e '/^[ \t]*#/d' -e '/^$/d' -e 's/[ \t]*$//' |
203 i
="`echo ${line} | ${sed} -e 's/=.*$//'`"
204 eval j
="\$${i}" jx="\${${i}+x}"
205 if [ -n "${j}" ] ||
[ "${jx}" = x
]; then
212 check_tool
awk "${awk:-`command -v awk`}"
213 check_tool
cat "${cat:-`command -v cat`}"
214 check_tool
chmod "${chmod:-`command -v chmod`}"
215 check_tool
cp "${cp:-`command -v cp`}"
216 check_tool
cmp "${cmp:-`command -v cmp`}"
217 check_tool
grep "${grep:-`command -v grep`}"
218 check_tool mkdir
"${mkdir:-`command -v mkdir`}"
219 check_tool
mv "${mv:-`command -v mv`}"
220 # rm(1), sed(1) above
221 check_tool
tee "${tee:-`command -v tee`}"
223 check_tool
make "${MAKE:-`command -v make`}"
224 check_tool strip
"${STRIP:-`command -v strip`}" 1
238 # (No function since some shells loose non-exported variables in traps)
239 trap "${rm} -f ${tmp} ${newlst} ${newmk} ${newh}; exit" 1 2 15
240 trap "${rm} -f ${tmp} ${newlst} ${newmk} ${newh}" 0
241 ${rm} -f ${newlst} ${newmk} ${newh}
243 # (Could: use FD redirection, add eval(1) and don't re-'. ./${newlst}')
245 i
=`echo ${line} | ${sed} -e 's/=.*$//'`
247 if [ -z "${j}" ] ||
[ "${j}" = 0 ]; then
248 printf "/*#define ${i}*/\n" >> ${newh}
249 elif [ "${j}" = 1 ]; then
250 printf "#define ${i}\n" >> ${newh}
252 printf "#define ${i} \"${j}\"\n" >> ${newh}
254 printf "${i} = ${j}\n" >> ${newmk}
255 printf "${i}=\"${j}\"\n"
256 done < ${tmp} > ${newlst}
259 printf "#define UAGENT \"${SID}${NAIL}\"\n" >> ${newh}
260 printf "UAGENT
= ${SID}${NAIL}\n" >> ${newmk}
264 printf "CC = ${CC}\n" >> ${newmk}
265 printf "_CFLAGS = ${_CFLAGS}\nCFLAGS = ${CFLAGS}\n" >> ${newmk}
266 printf "_LDFLAGS
= ${_LDFLAGS}\nLDFLAGS = ${LDFLAGS}\n" >> ${newmk}
267 printf "AWK = ${awk}\nCMP = ${cmp}\nCHMOD = ${chmod}\nCP = ${cp}\n" >> ${newmk}
268 printf "GREP
= ${grep}\nMKDIR = ${mkdir}\nRM = ${rm}\nSED = ${sed}\n" \
270 printf "STRIP
= ${strip}\nHAVE_STRIP = ${HAVE_STRIP}\n" >> ${newmk}
271 # (We include the cc(1)/ld(1) environment only for update detection..)
272 printf "CC=\"${CC}\"\n" >> ${newlst}
273 printf "_CFLAGS=\"${_CFLAGS}\"\nCFLAGS=\"${CFLAGS}\"\n" >> ${newlst}
274 printf "_LDFLAGS
=\"${_LDFLAGS}\"\nLDFLAGS=\"${LDFLAGS}\"\n" >> ${newlst}
275 printf "AWK=${awk}\nCMP=${cmp}\nCHMOD=${chmod}\nCP=${cp}\n" >> ${newlst}
276 printf "GREP
=${grep}\nMKDIR=${mkdir}\nRM=${rm}\nSED=${sed}\n" >> ${newlst}
277 printf "STRIP=${strip}\nHAVE_STRIP=${HAVE_STRIP}\n" >> ${newlst}
279 if [ -f ${lst} ] && ${cmp} ${newlst} ${lst} >/dev/null 2>&1; then
282 [ -f ${lst} ] && echo 'configuration updated..' || echo 'shiny configuration..'
284 ${mv} -f ${newlst} ${lst}
285 ${mv} -f ${newh} ${h}
286 ${mv} -f ${newmk} ${mk}
288 ## Compile and link checking ##
298 # (No function since some shells loose non-exported variables in traps)
299 trap "${rm} -f ${lst} ${h} ${mk} ${lib} ${inc} ${src} ${makefile}; exit" 1 2 15
300 trap "${rm} -rf ${tmp0}.* ${tmp0}* ${makefile}" 0
302 exec 5>&2 > ${log} 2>&1
305 # ${src} is only created if WANT_AMALGAMATION
307 ${cat} > ${makefile} << \!
308 .SUFFIXES: .o .c .x .y
312 $(CC) $(XINCS) -E $< >$@
314 $(CC) $(XINCS) -o $@ $< $(XLIBS)
322 printf "*** ${fmt}\\n
" "${@}"
323 printf "${fmt}" "${@}" >&5
327 variable=$1 topic=$2 define=$3
330 msg "checking
${topic} ...
"
331 echo "/* checked
${topic} */" >> ${h}
332 ${rm} -f ${tmp} ${tmp}.o
333 echo '*** test program is'
335 #echo '*** the preprocessor generates'
336 #${make} -f ${makefile} ${tmp}.x
338 echo '*** results are'
342 variable=$1 topic=$2 define=$3
344 _check_preface "${variable}" "${topic}" "${define}"
346 if ${make} -f ${makefile} XINCS="${INCS}" ./${tmp}.o &&
347 [ -f ./${tmp}.o ]; then
349 echo "${define}" >> ${h}
350 eval have_${variable}=yes
353 echo "/* ${define} */" >> ${h}
355 eval unset have_${variable}
361 run=$1 variable=$2 topic=$3 define=$4 libs=$5 incs=$6
363 _check_preface "${variable}" "${topic}" "${define}"
365 if ${make} -f ${makefile} XINCS="${INCS} ${incs}" \
366 XLIBS
="${LIBS} ${libs}" ./${tmp} &&
368 { [ ${run} -eq 0 ] || ./${tmp}; }; then
369 echo "*** adding INCS
<${incs}> LIBS
<${libs}>"
371 echo "${define}" >> ${h}
372 LIBS="${LIBS} ${libs}"
373 echo "${libs}" >> ${lib}
374 INCS="${INCS} ${incs}"
375 echo "${incs}" >> ${inc}
376 eval have_${variable}=yes
380 echo "/* ${define} */" >> ${h}
381 eval unset have_${variable}
387 _link_mayrun 0 "${1}" "${2}" "${3}" "${4}" "${5}"
391 _link_mayrun 1 "${1}" "${2}" "${3}" "${4}" "${5}"
394 # Build a basic set of INCS and LIBS according to user environment.
395 # On pkgsrc(7) systems automatically add /usr/pkg/*
396 if [ -n "${C_INCLUDE_PATH}" ]; then
399 set -- ${C_INCLUDE_PATH}
401 # for i; do -- new in POSIX Issue 7 + TC1
404 [ "${i}" = '/usr/pkg/include' ] && continue
405 INCS="${INCS} -I${i}"
408 [ -d /usr/pkg/include ] && INCS="${INCS} -I/usr
/pkg
/include
"
409 echo "${INCS}" >> ${inc}
411 if [ -n "${LD_LIBRARY_PATH}" ]; then
414 set -- ${LD_LIBRARY_PATH}
416 # for i; do -- new in POSIX Issue 7 + TC1
419 [ "${i}" = '/usr/pkg/lib' ] && continue
420 LIBS="${LIBS} -L${i}"
423 [ -d /usr/pkg/lib ] && LIBS="${LIBS} -L/usr
/pkg
/lib
"
424 echo "${LIBS}" >> ${lib}
428 # Better set _GNU_SOURCE (if we are on Linux only?); 'surprised it did without
429 echo '#define _GNU_SOURCE' >> ${h}
431 if link_check hello 'if a hello world program can be built' << \!
434 int main(int argc, char *argv[])
445 echo >&5 'This oooops is most certainly not related to me.'
446 echo >&5 "Read the
file ${log} and check your compiler environment.
"
447 ${rm} -f ${lst} ${h} ${mk}
451 if link_check termios 'for termios.h and tc*() family' << \!
457 tcsetattr(0, TCSADRAIN | TCSAFLUSH, &tios);
464 echo >&5 'We require termios.h and the tc*() family of functions.'
465 echo >&5 "That much Unix we indulge ourselfs.
"
466 ${rm} -f ${lst} ${h} ${mk}
470 link_check setenv 'for setenv()/unsetenv()' '#define HAVE_SETENV' << \!
474 setenv("s-nail
", "to be made nifty
!", 1);
480 link_check snprintf 'for snprintf()' '#define HAVE_SNPRINTF' << \!
485 snprintf(b, sizeof b, "%s
", "string
");
490 link_check putc_unlocked 'for putc_unlocked()' '#define HAVE_PUTC_UNLOCKED' <<\!
494 putc_unlocked('@', stdout);
499 link_check fchdir 'for fchdir()' '#define HAVE_FCHDIR' << \!
508 link_check pipe2 'for pipe2()' '#define HAVE_PIPE2' << \!
514 pipe2(fds, O_CLOEXEC);
519 link_check mmap 'for mmap()' '#define HAVE_MMAP' << \!
520 #include <sys/types.h>
521 #include <sys/mman.h>
524 mmap(0, 0, 0, 0, 0, 0);
529 link_check mremap 'for mremap()' '#define HAVE_MREMAP' << \!
530 #include <sys/types.h>
531 #include <sys/mman.h>
534 mremap(0, 0, 0, MREMAP_MAYMOVE);
539 link_check setlocale 'for setlocale()' '#define HAVE_SETLOCALE' << \!
543 setlocale(LC_ALL, "");
548 if [ "${have_setlocale}" = yes ]; then
549 link_check c90amend1 'for ISO/IEC 9899:1990/Amendment 1:1995' \
550 '#define HAVE_C90AMEND1' << \!
557 char mbb[MB_LEN_MAX + 1];
562 mbrtowc(&wc, "x
", 1, NULL);
563 (void)wctomb(mbb, wc);
564 return (mblen("\
0", 1) == 0);
568 if [ "${have_c90amend1}" = yes ]; then
569 link_check wcwidth 'for wcwidth()' '#define HAVE_WCWIDTH' << \!
579 link_check nl_langinfo 'for nl_langinfo()' '#define HAVE_NL_LANGINFO' << \!
580 #include <langinfo.h>
585 return (nl_langinfo(CODESET) == NULL);
590 link_check mkstemp 'for mkstemp()' '#define HAVE_MKSTEMP' << \!
599 # Note: run_check, thus we also get only the desired implementation...
600 run_check realpath 'for realpath()' '#define HAVE_REALPATH' << \!
604 char *x = realpath(".
", NULL), *y = realpath("/", NULL);
605 return (x != NULL && y != NULL) ? 0 : 1;
609 link_check wordexp 'for wordexp()' '#define HAVE_WORDEXP' << \!
613 wordexp((char *)0, (wordexp_t *)0, 0);
620 if wantfeat DEBUG; then
621 echo '#define HAVE_DEBUG' >> ${h}
624 if wantfeat AMALGAMATION; then
625 echo '#define HAVE_AMALGAMATION' >> ${h}
628 if nwantfeat NOALLOCA; then
629 # Due to NetBSD PR lib/47120 it seems best not to use non-cc-builtin
630 # versions of alloca(3) since modern compilers just can't be trusted
631 # not to overoptimize and silently break some code
632 link_check alloca 'for __builtin_alloca()' \
633 '#define HAVE_ALLOCA __builtin_alloca' << \!
636 void *vp = __builtin_alloca(1);
642 if wantfeat DEVEL; then
643 echo '#define HAVE_DEVEL' >> ${h}
646 if wantfeat NYD2; then
647 echo '#define HAVE_NYD2' >> ${h}
652 if wantfeat ICONV; then
653 ${cat} > ${tmp2}.c << \!
659 id = iconv_open("foo
", "bar
");
663 < ${tmp2}.c link_check iconv 'for iconv functionality' \
664 '#define HAVE_ICONV' ||
665 < ${tmp2}.c link_check iconv \
666 'for iconv functionality in libiconv' \
667 '#define HAVE_ICONV' '-liconv'
669 echo '/* WANT_ICONV=0 */' >> ${h}
672 if wantfeat SOCKETS; then
673 compile_check arpa_inet_h 'for <arpa/inet.h>' \
674 '#define HAVE_ARPA_INET_H' << \!
676 #include <sys/types.h>
677 #include <sys/socket.h>
679 #include <netinet/in.h>
680 #include <arpa/inet.h>
683 ${cat} > ${tmp2}.c << \!
685 #include <sys/types.h>
686 #include <sys/socket.h>
688 #include <netinet/in.h>
689 #ifdef HAVE_ARPA_INET_H
690 #include <arpa/inet.h>
696 socket(AF_INET, SOCK_STREAM, 0);
698 gethostbyname("foo
");
703 < ${tmp2}.c link_check sockets 'for sockets in libc' \
704 '#define HAVE_SOCKETS' ||
705 < ${tmp2}.c link_check sockets 'for sockets in libnsl' \
706 '#define HAVE_SOCKETS' '-lnsl' ||
707 < ${tmp2}.c link_check sockets \
708 'for sockets in libsocket and libnsl' \
709 '#define HAVE_SOCKETS' '-lsocket -lnsl' ||
712 # XXX Shouldn't it be a hard error if there is no socket support, then?
715 echo '/* WANT_SOCKETS=0 */' >> ${h}
716 fi # wantfeat SOCKETS
719 link_check setsockopt 'for setsockopt()' '#define HAVE_SETSOCKOPT' << \!
720 #include <sys/socket.h>
725 setsockopt(sockfd, SOL_SOCKET, SO_KEEPALIVE, NULL, 0);
730 wantfeat SOCKETS && [ -n "${have_setsockopt}" ] &&
731 link_check so_sndtimeo 'for SO_SNDTIMEO' '#define HAVE_SO_SNDTIMEO' << \!
732 #include <sys/socket.h>
740 setsockopt(sockfd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof tv);
741 setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof tv);
746 wantfeat SOCKETS && [ -n "${have_setsockopt}" ] &&
747 link_check so_linger 'for SO_LINGER' '#define HAVE_SO_LINGER' << \!
748 #include <sys/socket.h>
756 setsockopt(sockfd, SOL_SOCKET, SO_LINGER, &li, sizeof li);
761 if wantfeat IPV6; then
762 link_check ipv6 'for IPv6 functionality' '#define HAVE_IPV6' << \!
764 #include <sys/types.h>
765 #include <sys/socket.h>
767 #include <netinet/in.h>
768 #ifdef HAVE_ARPA_INET_H
769 #include <arpa/inet.h>
774 struct addrinfo a, *ap;
775 getaddrinfo("foo
", "0", &a, &ap);
780 echo '/* WANT_IPV6=0 */' >> ${h}
783 if wantfeat SSL; then
784 link_check openssl 'for sufficiently recent OpenSSL' \
786 #define HAVE_OPENSSL' '-lssl -lcrypto' << \!
787 #include <openssl/ssl.h>
788 #include <openssl/err.h>
789 #include <openssl/x509v3.h>
790 #include <openssl/x509.h>
791 #include <openssl/rand.h>
793 #if defined OPENSSL_NO_SSL2 && defined OPENSSL_NO_SSL3 &&\
794 defined OPENSSL_NO_TLS1
795 # error We need one of (SSLv2 and) SSLv3 and TLS1.
800 SSLv23_client_method();
801 #ifndef OPENSSL_NO_SSL3
802 SSLv3_client_method();
804 #ifndef OPENSSL_NO_TLS1
805 TLSv1_client_method();
806 # ifdef TLS1_1_VERSION
807 TLSv1_1_client_method();
809 # ifdef TLS1_2_VERSION
810 TLSv1_2_client_method();
813 PEM_read_PrivateKey(0, 0, 0, 0);
818 if [ "${have_openssl}" = 'yes' ]; then
819 compile_check stack_of 'for OpenSSL STACK_OF()' \
820 '#define HAVE_OPENSSL_STACK_OF' << \!
821 #include <openssl/ssl.h>
822 #include <openssl/err.h>
823 #include <openssl/x509v3.h>
824 #include <openssl/x509.h>
825 #include <openssl/rand.h>
829 STACK_OF(GENERAL_NAME) *gens = NULL;
830 printf("%p
", gens); /* to make it used */
835 link_check rand_egd 'for OpenSSL RAND_egd()' \
836 '#define HAVE_OPENSSL_RAND_EGD' '-lssl -lcrypto' << \!
837 #include <openssl/rand.h>
841 return RAND_egd("some.where
") > 0;
845 if wantfeat MD5 && nwantfeat NOEXTMD5; then
846 run_check openssl_md5 'for MD5 digest in OpenSSL' \
847 '#define HAVE_OPENSSL_MD5' << \!
849 #include <openssl/md5.h>
853 char const dat[] = "abrakadabrafidibus
";
854 char dig[16], hex[16 * 2];
858 memset(dig, 0, sizeof(dig));
859 memset(hex, 0, sizeof(hex));
861 MD5_Update(&ctx, dat, sizeof(dat) - 1);
862 MD5_Final(dig, &ctx);
864 #define hexchar(n) ((n) > 9 ? (n) - 10 + 'a' : (n) + '0')
865 for (i = 0; i < sizeof(hex) / 2; i++) {
867 hex[j] = hexchar((dig[i] & 0xf0) >> 4);
868 hex[++j] = hexchar(dig[i] & 0x0f);
870 return !!memcmp("6d7d0a3d949da2e96f2aa010f65d8326
", hex, sizeof(hex));
873 fi # wantfeat MD5 && nwantfeat NOEXTMD5
876 echo '/* WANT_SSL=0 */' >> ${h}
879 if wantfeat SMTP; then
880 echo '#define HAVE_SMTP' >> ${h}
882 echo '/* WANT_SMTP=0 */' >> ${h}
885 if wantfeat POP3; then
886 echo '#define HAVE_POP3' >> ${h}
888 echo '/* WANT_POP3=0 */' >> ${h}
891 if wantfeat IMAP; then
892 echo '#define HAVE_IMAP' >> ${h}
894 echo '/* WANT_IMAP=0 */' >> ${h}
897 if wantfeat GSSAPI; then
898 ${cat} > ${tmp2}.c << \!
899 #include <gssapi/gssapi.h>
903 gss_import_name(0, 0, GSS_C_NT_HOSTBASED_SERVICE, 0);
904 gss_init_sec_context(0,0,0,0,0,0,0,0,0,0,0,0,0);
908 ${sed} -e '1s/gssapi\///' < ${tmp2}.c > ${tmp3}.c
910 if command -v krb5-config >/dev/null 2>&1; then
911 i=`command -v krb5-config`
912 GSS_LIBS="`CFLAGS= ${i} --libs gssapi`"
913 GSS_INCS="`CFLAGS= ${i} --cflags`"
914 i='for GSS-API via krb5-config(1)'
918 i='for GSS-API in gssapi/gssapi.h, libgssapi'
920 < ${tmp2}.c link_check gss \
921 "${i}" '#define HAVE_GSSAPI' "${GSS_LIBS}" "${GSS_INCS}" ||\
922 < ${tmp3}.c link_check gss \
923 'for GSS-API in gssapi.h, libgssapi' \
925 #define GSSAPI_REG_INCLUDE' \
927 < ${tmp2}.c link_check gss 'for GSS-API in libgssapi_krb5' \
928 '#define HAVE_GSSAPI' \
930 < ${tmp3}.c link_check gss \
931 'for GSS-API in libgssapi, OpenBSD-style (pre 5.3)' \
933 #define GSS_REG_INCLUDE' \
934 '-lgssapi -lkrb5 -lcrypto' \
935 '-I/usr/include/kerberosV' ||\
936 < ${tmp2}.c link_check gss 'for GSS-API in libgss' \
937 '#define HAVE_GSSAPI' \
939 link_check gss 'for GSS-API in libgssapi_krb5, old-style' \
941 #define GSSAPI_OLD_STYLE' \
942 '-lgssapi_krb5' << \!
943 #include <gssapi/gssapi.h>
944 #include <gssapi/gssapi_generic.h>
948 gss_import_name(0, 0, gss_nt_service_name, 0);
949 gss_init_sec_context(0,0,0,0,0,0,0,0,0,0,0,0,0);
954 echo '/* WANT_GSSAPI=0 */' >> ${h}
957 if wantfeat NETRC; then
958 echo '#define HAVE_NETRC' >> ${h}
960 echo '/* WANT_NETRC=0 */' >> ${h}
963 if wantfeat AGENT; then
964 echo '#define HAVE_AGENT' >> ${h}
966 echo '/* WANT_AGENT=0 */' >> ${h}
969 if wantfeat IDNA; then
970 link_check idna 'for GNU Libidn' '#define HAVE_IDNA' '-lidn' << \!
972 #include <idn-free.h>
973 #include <stringprep.h>
976 char *utf8, *idna_ascii, *idna_utf8;
977 utf8 = stringprep_locale_to_utf8("does.this.work
");
978 if (idna_to_ascii_8z(utf8, &idna_ascii, IDNA_USE_STD3_ASCII_RULES)
981 idn_free(idna_ascii);
982 /* (Rather link check only here) */
983 idna_utf8 = stringprep_convert(idna_ascii, "UTF-8
", "de_DE
");
988 echo '/* WANT_IDNA=0 */' >> ${h}
991 if wantfeat IMAP_SEARCH; then
992 echo '#define HAVE_IMAP_SEARCH' >> ${h}
994 echo '/* WANT_IMAP_SEARCH=0 */' >> ${h}
997 if wantfeat REGEX; then
998 link_check regex 'for regular expressions' '#define HAVE_REGEX' << \!
1005 if (regcomp(&re, ".
*bsd
", REG_EXTENDED | REG_ICASE | REG_NOSUB) != 0)
1007 status = regexec(&re, "plan9
", 0,NULL, 0);
1009 return !(status == REG_NOMATCH);
1013 echo '/* WANT_REGEX=0 */' >> ${h}
1016 if wantfeat READLINE; then
1018 link_check readline "for readline
(3) (${1})" \
1019 '#define HAVE_READLINE' "${1}" << \!
1021 #include <readline/history.h>
1022 #include <readline/readline.h>
1031 stifle_history(242);
1032 rl = readline("Enter a line
:");
1036 rl_extend_line_buffer(10);
1037 rl_point = rl_end = 10;
1038 rl_pre_input_hook = (rl_hook_func_t*)NULL;
1039 rl_forced_update_display();
1041 hs = history_get_history_state();
1043 he = history_list();
1046 rl_free_line_state();
1047 rl_cleanup_after_signal();
1048 rl_reset_after_signal();
1054 __edrdlib -lreadline ||
1055 __edrdlib '-lreadline -ltermcap'
1056 [ -n "${have_readline}" ] && WANT_TABEXPAND=1
1059 if wantfeat EDITLINE && [ -z "${have_readline}" ]; then
1061 link_check editline "for editline
(3) (${1})" \
1062 '#define HAVE_EDITLINE' "${1}" << \!
1063 #include <histedit.h>
1064 static char * getprompt(void) { return (char*)"ok
"; }
1067 EditLine *el_el = el_init("TEST
", stdin, stdout, stderr);
1069 History *el_hcom = history_init();
1070 history(el_hcom, &he, H_SETSIZE, 242);
1071 el_set(el_el, EL_SIGNAL, 0);
1072 el_set(el_el, EL_TERMINAL, NULL);
1073 el_set(el_el, EL_HIST, &history, el_hcom);
1074 el_set(el_el, EL_EDITOR, "emacs
");
1075 el_set(el_el, EL_PROMPT, &getprompt);
1076 el_source(el_el, NULL);
1077 history(el_hcom, &he, H_GETSIZE);
1078 history(el_hcom, &he, H_CLEAR);
1080 /* TODO add loader and addfn checks */
1081 history_end(el_hcom);
1088 __edlib '-ledit -ltermcap'
1089 [ -n "${have_editline}" ] && WANT_TABEXPAND=0
1092 if wantfeat NCL && [ -z "${have_editline}" ] && [ -z "${have_readline}" ] &&\
1093 [ -n "${have_c90amend1}" ]; then
1095 echo '#define HAVE_NCL' >> ${h}
1097 echo '/* WANT_{READLINE,EDITLINE,NCL}=0 */' >> ${h}
1100 # Generic have-a-command-line-editor switch for those who need it below
1101 if [ -n "${have_ncl}" ] || [ -n "${have_editline}" ] ||\
1102 [ -n "${have_readline}" ]; then
1106 if [ -n "${have_cle}" ] && wantfeat HISTORY; then
1107 echo '#define HAVE_HISTORY' >> ${h}
1109 echo '/* WANT_HISTORY=0 */' >> ${h}
1112 if [ -n "${have_cle}" ] && wantfeat TABEXPAND; then
1113 echo '#define HAVE_TABEXPAND' >> ${h}
1115 echo '/* WANT_TABEXPAND=0 */' >> ${h}
1118 if wantfeat SPAM; then
1119 echo '#define HAVE_SPAM' >> ${h}
1120 if command -v spamc >/dev/null 2>&1; then
1121 echo "#define SPAMC_PATH \"`command -v spamc`\"" >> ${h}
1124 echo '/* WANT_SPAM=0 */' >> ${h}
1127 if wantfeat DOCSTRINGS
; then
1128 echo '#define HAVE_DOCSTRINGS' >> ${h}
1130 echo '/* WANT_DOCSTRINGS=0 */' >> ${h}
1133 if wantfeat QUOTE_FOLD
&&\
1134 [ -n "${have_c90amend1}" ] && [ -n "${have_wcwidth}" ]; then
1135 echo '#define HAVE_QUOTE_FOLD' >> ${h}
1137 echo '/* WANT_QUOTE_FOLD=0 */' >> ${h}
1140 if wantfeat COLOUR
; then
1141 echo '#define HAVE_COLOUR' >> ${h}
1143 echo '/* WANT_COLOUR=0 */' >> ${h}
1146 if wantfeat MD5
; then
1147 echo '#define HAVE_MD5' >> ${h}
1149 echo '/* WANT_MD5=0 */' >> ${h}
1154 # Since we cat(1) the content of those to cc/"ld", convert them to single line
1156 < "${1}" > "${2}" ${awk} \
1157 'BEGIN {ORS = " "} /^[^#]/ {print} {next} END {ORS = ""; print "\n"}'
1160 squeeze_em ${inc} ${tmp}
1162 squeeze_em ${lib} ${tmp}
1167 printf '#ifndef _CONFIG_H\n# define _CONFIG_H\n' > ${h}
1168 ${cat} ${tmp} >> ${h}
1170 printf '\n/* The "feature string
", for "simplicity
" and lex.c */\n' >> ${h}
1171 printf '#ifdef _MAIN_SOURCE\n' >> ${h}
1172 printf '# ifdef HAVE_AMALGAMATION\nstatic\n# endif\n' >> ${h}
1173 printf 'char const features[] = "MIME
"\n' >> ${h}
1174 printf '# ifdef HAVE_SETLOCALE\n ",LOCALES
"\n# endif\n' >> ${h}
1175 printf '# ifdef HAVE_C90AMEND1\n ",MULTIBYTE CHARSETS
"\n# endif\n' >> ${h}
1176 printf '# ifdef HAVE_NL_LANGINFO\n ",TERMINAL CHARSET
"\n# endif\n' >> ${h}
1177 printf '# ifdef HAVE_ICONV\n ",ICONV
"\n# endif\n' >> ${h}
1178 printf '# ifdef HAVE_SOCKETS\n ",NETWORK
"\n# endif\n' >> ${h}
1179 printf '# ifdef HAVE_IPV6\n ",IPv6
"\n# endif\n' >> ${h}
1180 printf '# ifdef HAVE_SSL\n ",S
/MIME
,SSL
/TLS
"\n# endif\n' >> ${h}
1181 printf '# ifdef HAVE_SMTP\n ",SMTP
"\n# endif\n' >> ${h}
1182 printf '# ifdef HAVE_POP3\n ",POP3
"\n# endif\n' >> ${h}
1183 printf '# ifdef HAVE_IMAP\n ",IMAP
"\n# endif\n' >> ${h}
1184 printf '# ifdef HAVE_GSSAPI\n ",GSS-API
"\n# endif\n' >> ${h}
1185 printf '# ifdef HAVE_NETRC\n ",NETRC
"\n# endif\n' >> ${h}
1186 printf '# ifdef HAVE_AGENT\n ",AGENT
"\n# endif\n' >> ${h}
1187 printf '# ifdef HAVE_IDNA\n ",IDNA
"\n# endif\n' >> ${h}
1188 printf '# ifdef HAVE_IMAP_SEARCH\n ",IMAP-searches
"\n# endif\n' >> ${h}
1189 printf '# ifdef HAVE_REGEX\n ",REGEX
"\n# endif\n' >> ${h}
1190 printf '# ifdef HAVE_READLINE\n ",READLINE
"\n# endif\n' >> ${h}
1191 printf '# ifdef HAVE_EDITLINE\n ",EDITLINE
"\n# endif\n' >> ${h}
1192 printf '# ifdef HAVE_NCL\n ",NCL
"\n# endif\n' >> ${h}
1193 printf '# ifdef HAVE_TABEXPAND\n ",TABEXPAND
"\n# endif\n' >> ${h}
1194 printf '# ifdef HAVE_HISTORY\n ",HISTORY
"\n# endif\n' >> ${h}
1195 printf '# ifdef HAVE_SPAM\n ",SPAM
"\n# endif\n' >> ${h}
1196 printf '# ifdef HAVE_DOCSTRINGS\n ",DOCSTRINGS
"\n# endif\n' >> ${h}
1197 printf '# ifdef HAVE_QUOTE_FOLD\n ",QUOTE-FOLD
"\n# endif\n' >> ${h}
1198 printf '# ifdef HAVE_COLOUR\n ",COLOUR
"\n# endif\n' >> ${h}
1199 printf '# ifdef HAVE_DEBUG\n ",DEBUG
"\n# endif\n' >> ${h}
1200 printf ';\n#endif /* _MAIN_SOURCE */\n' >> ${h}
1202 printf '#endif /* _CONFIG_H */\n' >> ${h}
1205 # Create the real mk.mk
1206 ${rm} -rf ${tmp0}.* ${tmp0}*
1207 printf 'OBJ_SRC = ' >> ${mk}
1208 if nwantfeat AMALGAMATION; then
1210 echo 'OBJ_DEP =' >> ${mk}
1212 j=`echo "${src}" | sed 's/^.\///'`
1213 echo "${j}" >> ${mk}
1214 printf 'OBJ_DEP = main.c ' >> ${mk}
1215 printf '#define _MAIN_SOURCE\n' >> ${src}
1216 printf '#include "nail.h
"\n#include "main.c
"\n' >> ${src}
1218 if [ "${i}" = "${j}" ] || [ "${i}" = main.c ]; then
1221 printf "${i} " >> ${mk}
1222 printf "#include \"${i}\"\n" >> ${src}
1227 echo "LIBS = `${cat} ${lib}`" >> ${mk}
1228 echo "INCLUDES
= `${cat} ${inc}`" >> ${mk}
1230 ${cat} ./mk-mk.in >> ${mk}
1234 ${cat} > ${tmp2}.c << \!
1236 #ifdef HAVE_NL_LANGINFO
1237 # include <langinfo.h>
1240 :The following optional features are enabled:
1241 #ifdef HAVE_SETLOCALE
1242 : + Locale support: Printable characters depend on the environment
1243 # ifdef HAVE_C90AMEND1
1244 : + Multibyte character support
1246 # ifdef HAVE_NL_LANGINFO
1247 : + Automatic detection of terminal character set
1251 : + Character set conversion using iconv()
1257 : + Support for Internet Protocol v6 (IPv6)
1260 # ifdef HAVE_OPENSSL
1261 : + S/MIME and SSL/TLS (OpenSSL)
1274 : + GSS-API authentication
1277 : + .netrc file support
1280 : + Password query through agent
1283 : + IDNA (internationalized domain names for applications) support
1285 #ifdef HAVE_IMAP_SEARCH
1286 : + IMAP-style search expressions
1289 : + Regular expression support (searches, conditional expressions etc.)
1291 #if defined HAVE_READLINE || defined HAVE_EDITLINE || defined HAVE_NCL
1292 : + Command line editing
1293 # ifdef HAVE_TABEXPAND
1294 : + + Tabulator expansion
1296 # ifdef HAVE_HISTORY
1297 : + + History management
1301 : + Interaction with spam filters
1303 #ifdef HAVE_DOCSTRINGS
1304 : + Documentation summary strings
1306 #ifdef HAVE_QUOTE_FOLD
1307 : + Extended *quote-fold*ing
1310 : + Coloured message display (simple)
1313 :The following optional features are disabled:
1314 #ifndef HAVE_SETLOCALE
1315 : - Locale support: Only ASCII characters are recognized
1317 # ifndef HAVE_C90AMEND1
1318 : - Multibyte character support
1320 # ifndef HAVE_NL_LANGINFO
1321 : - Automatic detection of terminal character set
1324 : - Character set conversion using iconv()
1326 #ifndef HAVE_SOCKETS
1330 : - Support for Internet Protocol v6 (IPv6)
1333 : - S/MIME and SSL/TLS
1345 : - GSS-API authentication
1348 : - .netrc file support
1351 : - Password query through agent
1354 : - IDNA (internationalized domain names for applications) support
1356 #ifndef HAVE_IMAP_SEARCH
1357 : - IMAP-style search expressions
1360 : - Regular expression support
1362 #if !defined HAVE_READLINE && !defined HAVE_EDITLINE && !defined HAVE_NCL
1363 : - Command line editing and history
1366 : - Interaction with spam filters
1368 #ifndef HAVE_DOCSTRINGS
1369 : - Documentation summary strings
1371 #ifndef HAVE_QUOTE_FOLD
1372 : - Extended *quote-fold*ing
1375 : - Coloured message display (simple)
1379 #ifndef HAVE_SNPRINTF
1380 : . The function snprintf() could not be found. We will use and internal
1381 : sprintf() instead. This might overflow buffers if input values are larger
1382 : than expected. Use the resulting binary with care or update your system
1383 : environment and start the configuration process again.
1386 : . The function fchdir() could not be found. We will use chdir()
1387 : instead. This is not a problem unless the current working
1388 : directory of mailx is moved while the IMAP cache is used.
1391 : . Debug enabled binary: not meant to be used by end-users: THANKS!
1396 ${make} -f ${makefile} ${tmp2}.x
1397 < ${tmp2}.x >&5 ${sed} -e '/^[^:]/d; /^$/d; s/^://'