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_IMAP
=0 WANT_GSSAPI
=0 WANT_POP3
=0 WANT_SMTP
=0
55 if nwantfeat IMAP
&& nwantfeat POP3
&& nwantfeat SMTP
; then
56 WANT_SOCKETS
=0 WANT_IPV6
=0 WANT_SSL
=0
58 if nwantfeat IMAP
&& nwantfeat SMTP
; then
61 # If we don't need MD5 except for producing boundary and message-id strings,
62 # leave it off, plain old srand(3) should be enough for that purpose.
63 if nwantfeat SOCKETS
; then
66 if wantfeat DEBUG
; then
71 # Check out compiler ($CC) and -flags ($CFLAGS)
73 # $CC is overwritten when empty or a default "cc", even without WANT_AUTOCC
74 optim
= dbgoptim
= _CFLAGS
=
75 if [ -z "${CC}" ] ||
[ "${CC}" = cc
]; then
76 if { CC
="`command -v clang`"; }; then
78 elif { CC
="`command -v gcc`"; }; then
80 elif { CC
="`command -v c89`"; }; then
81 [ "`uname -s`" = UnixWare
] && _CFLAGS
=-v optim
=-O dbgoptim
=
82 elif { CC
="`command -v c99`"; }; then
86 echo >&2 ' I cannot find a compiler!'
87 echo >&2 ' Neither of clang(1), gcc(1), c89(1) and c99(1).'
88 echo >&2 ' Please set the CC environment variable, maybe CFLAGS also.'
94 ccver
=`${CC} --version 2>/dev/null`
96 if { i
=${ccver}; echo "${i}"; } |
${grep} -q -i -e gcc
-e clang
; then
97 #if echo "${i}" | ${grep} -q -i -e gcc -e 'clang version 1'; then
100 _CFLAGS
="${_CFLAGS} -std=c89 -Wall -Wextra -pedantic"
101 _CFLAGS
="${_CFLAGS} -fno-unwind-tables -fno-asynchronous-unwind-tables"
102 _CFLAGS
="${_CFLAGS} -fstrict-aliasing"
103 _CFLAGS
="${_CFLAGS} -Wbad-function-cast -Wcast-align -Wcast-qual"
104 _CFLAGS
="${_CFLAGS} -Winit-self -Wmissing-prototypes"
105 _CFLAGS
="${_CFLAGS} -Wshadow -Wunused -Wwrite-strings"
106 _CFLAGS
="${_CFLAGS} -Wno-long-long" # ISO C89 has no 'long long'...
107 if { i
=${ccver}; echo "${i}"; } |
${grep} -q -e 'clang version 1'; then
108 _CFLAGS
="${_CFLAGS} -Wstrict-overflow=5"
110 _CFLAGS
="${_CFLAGS} -fstrict-overflow -Wstrict-overflow=5"
111 if wantfeat AMALGAMATION
&& nwantfeat DEBUG
; then
112 _CFLAGS
="${_CFLAGS} -Wno-unused-function"
114 if { i
=${ccver}; echo "${i}"; } |
${grep} -q -i -e clang
; then
115 _CFLAGS
="${_CFLAGS} -Wno-unused-result" # TODO handle the right way
118 if wantfeat AMALGAMATION
; then
119 _CFLAGS
="${_CFLAGS} -pipe"
121 # elif { i=${ccver}; echo "${i}"; } | ${grep} -q -i -e clang; then
122 # optim=-O3 dbgoptim=-O
124 # _CFLAGS='-std=c89 -Weverything -Wno-long-long'
125 # if wantfeat AMALGAMATION; then
126 # _CFLAGS="${_CFLAGS} -pipe"
128 elif [ -z "${optim}" ]; then
129 optim
=-O1 dbgoptim
=-O
132 if nwantfeat DEBUG
; then
133 _CFLAGS
="${optim} -DNDEBUG ${_CFLAGS}"
135 _CFLAGS
="${dbgoptim} -g ${_CFLAGS}";
136 if [ "${stackprot}" = yes ]; then
137 _CFLAGS
="${_CFLAGS} -ftrapv -fstack-protector-all "
138 _CFLAGS
="${_CFLAGS} -Wstack-protector -D_FORTIFY_SOURCE=2"
141 _CFLAGS
="${_CFLAGS} ${ADDCFLAGS}"
142 # XXX -Wl,-z,relro -Wl,-z,now -Wl,-z,noexecstack: need detection
143 _LDFLAGS
="${_LDFLAGS} ${ADDLDFLAGS}" # XXX -Wl,--sort-common,[-O1]
144 export _CFLAGS _LDFLAGS
146 # $CFLAGS and $LDFLAGS are only overwritten if explicitly wanted
147 if wantfeat AUTOCC
; then
150 export CFLAGS LDFLAGS
157 ## - Heirloom sh(1) (and same origin) have problems with ': >' redirection,
158 ## so use "printf '' >" instead
159 ## - Heirloom sh(1) and maybe more execute loops with redirection in a subshell
160 ## (but don't export eval's from within), therefore we need to (re)include
161 ## variable assignments at toplevel instead (via reading temporary files)
163 ## First of all, create new configuration and check wether it changed ##
170 newlst
=.
/config.lst-new
171 newmk
=.
/config.mk-new
176 # We need some standard utilities
179 n
=$1 i
=$2 opt
=${3:-0}
180 if type "${i}" >/dev
/null
2>&1; then
184 if [ ${opt} -eq 0 ]; then
185 echo >&2 "ERROR: no trace of the utility \`${n}'"
191 # Check those tools right now that we need before including ${conf}
192 check_tool
rm "${rm:-`command -v rm`}"
193 check_tool
sed "${sed:-`command -v sed`}"
195 # Only incorporate what wasn't overwritten from command line / CONFIG
196 trap "${rm} -f ${tmp}; exit" 1 2 15
197 trap "${rm} -f ${tmp}" 0
200 < ${conf} ${sed} -e '/^[ \t]*#/d' -e '/^$/d' -e 's/[ \t]*$//' |
202 i
=`echo ${line} | ${sed} -e 's/=.*$//'`
203 eval j
=\$
${i} jx=\${${i}+x}
204 if [ -n "${j}" ] ||
[ "${jx}" = x
]; then
211 check_tool
awk "${awk:-`command -v awk`}"
212 check_tool
cat "${cat:-`command -v cat`}"
213 check_tool
chmod "${chmod:-`command -v chmod`}"
214 check_tool
cp "${cp:-`command -v cp`}"
215 check_tool
cmp "${cmp:-`command -v cmp`}"
216 check_tool
grep "${grep:-`command -v grep`}"
217 check_tool mkdir
"${mkdir:-`command -v mkdir`}"
218 check_tool
mv "${mv:-`command -v mv`}"
219 # rm(1), sed(1) above
220 check_tool
tee "${tee:-`command -v tee`}"
222 check_tool
make "${MAKE:-`command -v make`}"
223 check_tool strip
"${STRIP:-`command -v strip`}" 1
237 # (No function since some shells loose non-exported variables in traps)
238 trap "${rm} -f ${tmp} ${newlst} ${newmk} ${newh}; exit" 1 2 15
239 trap "${rm} -f ${tmp} ${newlst} ${newmk} ${newh}" 0
240 ${rm} -f ${newlst} ${newmk} ${newh}
242 # (Could: use FD redirection, add eval(1) and don't re-'. ./${newlst}')
244 i
=`echo ${line} | ${sed} -e 's/=.*$//'`
246 if [ -z "${j}" ] ||
[ "${j}" = 0 ]; then
247 printf "/*#define ${i}*/\n" >> ${newh}
248 elif [ "${j}" = 1 ]; then
249 printf "#define ${i}\n" >> ${newh}
251 printf "#define ${i} \"${j}\"\n" >> ${newh}
253 printf "${i} = ${j}\n" >> ${newmk}
254 printf "${i}=\"${j}\"\n"
255 done < ${tmp} > ${newlst}
258 printf "#define UAGENT \"${SID}${NAIL}\"\n" >> ${newh}
259 printf "UAGENT
= ${SID}${NAIL}\n" >> ${newmk}
263 printf "CC = ${CC}\n" >> ${newmk}
264 printf "_CFLAGS = ${_CFLAGS}\nCFLAGS = ${CFLAGS}\n" >> ${newmk}
265 printf "_LDFLAGS
= ${_LDFLAGS}\nLDFLAGS = ${LDFLAGS}\n" >> ${newmk}
266 printf "AWK = ${awk}\nCMP = ${cmp}\nCHMOD = ${chmod}\nCP = ${cp}\n" >> ${newmk}
267 printf "GREP
= ${grep}\nMKDIR = ${mkdir}\nRM = ${rm}\nSED = ${sed}\n" \
269 printf "STRIP
= ${strip}\nHAVE_STRIP = ${HAVE_STRIP}\n" >> ${newmk}
270 # (We include the cc(1)/ld(1) environment only for update detection..)
271 printf "CC=\"${CC}\"\n" >> ${newlst}
272 printf "_CFLAGS=\"${_CFLAGS}\"\nCFLAGS=\"${CFLAGS}\"\n" >> ${newlst}
273 printf "_LDFLAGS
=\"${_LDFLAGS}\"\nLDFLAGS=\"${LDFLAGS}\"\n" >> ${newlst}
274 printf "AWK=${awk}\nCMP=${cmp}\nCHMOD=${chmod}\nCP=${cp}\n" >> ${newlst}
275 printf "GREP
=${grep}\nMKDIR=${mkdir}\nRM=${rm}\nSED=${sed}\n" >> ${newlst}
276 printf "STRIP=${strip}\nHAVE_STRIP=${HAVE_STRIP}\n" >> ${newlst}
278 if [ -f ${lst} ] && ${cmp} ${newlst} ${lst} >/dev/null 2>&1; then
281 [ -f ${lst} ] && echo 'configuration updated..' || echo 'shiny configuration..'
283 ${mv} -f ${newlst} ${lst}
284 ${mv} -f ${newh} ${h}
285 ${mv} -f ${newmk} ${mk}
287 ## Compile and link checking ##
297 # (No function since some shells loose non-exported variables in traps)
298 trap "${rm} -f ${lst} ${h} ${mk} ${lib} ${inc} ${src} ${makefile}; exit" 1 2 15
299 trap "${rm} -rf ${tmp0}.* ${tmp0}* ${makefile}" 0
301 exec 5>&2 > ${log} 2>&1
304 # ${src} is only created if WANT_AMALGAMATION
306 ${cat} > ${makefile} << \!
307 .SUFFIXES: .o .c .x .y
311 $(CC) $(XINCS) -E $< >$@
313 $(CC) $(XINCS) -o $@ $< $(XLIBS)
321 printf "*** ${fmt}\\n
" "${@}"
322 printf "${fmt}" "${@}" >&5
326 variable=$1 topic=$2 define=$3
329 msg "checking
${topic} ...
"
330 echo "/* checked
${topic} */" >> ${h}
331 ${rm} -f ${tmp} ${tmp}.o
332 echo '*** test program is'
334 #echo '*** the preprocessor generates'
335 #${make} -f ${makefile} ${tmp}.x
337 echo '*** results are'
341 variable=$1 topic=$2 define=$3
343 _check_preface "${variable}" "${topic}" "${define}"
345 if ${make} -f ${makefile} XINCS="${INCS}" ./${tmp}.o &&
346 [ -f ./${tmp}.o ]; then
348 echo "${define}" >> ${h}
349 eval have_${variable}=yes
352 echo "/* ${define} */" >> ${h}
354 eval unset have_${variable}
360 run=$1 variable=$2 topic=$3 define=$4 libs=$5 incs=$6
362 _check_preface "${variable}" "${topic}" "${define}"
364 if ${make} -f ${makefile} XINCS="${INCS} ${incs}" \
365 XLIBS
="${LIBS} ${libs}" ./${tmp} &&
367 { [ ${run} -eq 0 ] || ./${tmp}; }; then
368 echo "*** adding INCS
<${incs}> LIBS
<${libs}>"
370 echo "${define}" >> ${h}
371 LIBS="${LIBS} ${libs}"
372 echo "${libs}" >> ${lib}
373 INCS="${INCS} ${incs}"
374 echo "${incs}" >> ${inc}
375 eval have_${variable}=yes
379 echo "/* ${define} */" >> ${h}
380 eval unset have_${variable}
386 _link_mayrun 0 "${1}" "${2}" "${3}" "${4}" "${5}"
390 _link_mayrun 1 "${1}" "${2}" "${3}" "${4}" "${5}"
393 # Build a basic set of INCS and LIBS according to user environment.
394 # On pkgsrc(7) systems automatically add /usr/pkg/*
395 if [ -n "${C_INCLUDE_PATH}" ]; then
398 set -- ${C_INCLUDE_PATH}
400 # for i; do -- new in POSIX Issue 7 + TC1
403 [ "${i}" = '/usr/pkg/include' ] && continue
404 INCS="${INCS} -I${i}"
407 [ -d /usr/pkg/include ] && INCS="${INCS} -I/usr
/pkg
/include
"
408 echo "${INCS}" >> ${inc}
410 if [ -n "${LD_LIBRARY_PATH}" ]; then
413 set -- ${LD_LIBRARY_PATH}
415 # for i; do -- new in POSIX Issue 7 + TC1
418 [ "${i}" = '/usr/pkg/lib' ] && continue
419 LIBS="${LIBS} -L${i}"
422 [ -d /usr/pkg/lib ] && LIBS="${LIBS} -L/usr
/pkg
/lib
"
423 echo "${LIBS}" >> ${lib}
427 # Better set _GNU_SOURCE (if we are on Linux only?); 'surprised it did without
428 echo '#define _GNU_SOURCE' >> ${h}
430 if link_check hello 'if a hello world program can be built' << \!
433 int main(int argc, char *argv[])
444 echo >&5 'This oooops is most certainly not related to me.'
445 echo >&5 "Read the
file ${log} and check your compiler environment.
"
446 ${rm} -f ${lst} ${h} ${mk}
450 if link_check termios 'for termios.h and tc*() family' << \!
456 tcsetattr(0, TCSADRAIN | TCSAFLUSH, &tios);
463 echo >&5 'We require termios.h and the tc*() family of functions.'
464 echo >&5 "That much Unix we indulge ourselfs.
"
465 ${rm} -f ${lst} ${h} ${mk}
469 link_check setenv 'for setenv()/unsetenv()' '#define HAVE_SETENV' << \!
473 setenv("s-nail
", "to be made nifty
!", 1);
479 link_check snprintf 'for snprintf()' '#define HAVE_SNPRINTF' << \!
484 snprintf(b, sizeof b, "%s
", "string
");
489 link_check putc_unlocked 'for putc_unlocked()' '#define HAVE_PUTC_UNLOCKED' <<\!
493 putc_unlocked('@', stdout);
498 link_check fchdir 'for fchdir()' '#define HAVE_FCHDIR' << \!
507 link_check pipe2 'for pipe2()' '#define HAVE_PIPE2' << \!
513 pipe2(fds, O_CLOEXEC);
518 link_check mmap 'for mmap()' '#define HAVE_MMAP' << \!
519 #include <sys/types.h>
520 #include <sys/mman.h>
523 mmap(0, 0, 0, 0, 0, 0);
528 link_check mremap 'for mremap()' '#define HAVE_MREMAP' << \!
529 #include <sys/types.h>
530 #include <sys/mman.h>
533 mremap(0, 0, 0, MREMAP_MAYMOVE);
538 link_check setlocale 'for setlocale()' '#define HAVE_SETLOCALE' << \!
542 setlocale(LC_ALL, "");
547 if [ "${have_setlocale}" = yes ]; then
548 link_check c90amend1 'for ISO/IEC 9899:1990/Amendment 1:1995' \
549 '#define HAVE_C90AMEND1' << \!
556 char mbb[MB_LEN_MAX + 1];
561 mbrtowc(&wc, "x
", 1, NULL);
562 (void)wctomb(mbb, wc);
563 return (mblen("\
0", 1) == 0);
567 if [ "${have_c90amend1}" = yes ]; then
568 link_check wcwidth 'for wcwidth()' '#define HAVE_WCWIDTH' << \!
578 link_check nl_langinfo 'for nl_langinfo()' '#define HAVE_NL_LANGINFO' << \!
579 #include <langinfo.h>
584 return (nl_langinfo(CODESET) == NULL);
589 link_check mkstemp 'for mkstemp()' '#define HAVE_MKSTEMP' << \!
598 # Note: run_check, thus we also get only the desired implementation...
599 run_check realpath 'for realpath()' '#define HAVE_REALPATH' << \!
603 char *x = realpath(".
", NULL), *y = realpath("/", NULL);
604 return (x != NULL && y != NULL) ? 0 : 1;
608 link_check wordexp 'for wordexp()' '#define HAVE_WORDEXP' << \!
612 wordexp((char *)0, (wordexp_t *)0, 0);
619 if wantfeat DEBUG; then
620 echo '#define HAVE_DEBUG' >> ${h}
623 if wantfeat AMALGAMATION; then
624 echo '#define HAVE_AMALGAMATION' >> ${h}
627 if nwantfeat NOALLOCA; then
628 # Due to NetBSD PR lib/47120 it seems best not to use non-cc-builtin
629 # versions of alloca(3) since modern compilers just can't be trusted
630 # not to overoptimize and silently break some code
631 link_check alloca 'for __builtin_alloca()' \
632 '#define HAVE_ALLOCA __builtin_alloca' << \!
635 void *vp = __builtin_alloca(1);
643 if wantfeat ICONV; then
644 ${cat} > ${tmp2}.c << \!
650 id = iconv_open("foo
", "bar
");
654 < ${tmp2}.c link_check iconv 'for iconv functionality' \
655 '#define HAVE_ICONV' ||
656 < ${tmp2}.c link_check iconv \
657 'for iconv functionality in libiconv' \
658 '#define HAVE_ICONV' '-liconv'
660 echo '/* WANT_ICONV=0 */' >> ${h}
663 if wantfeat SOCKETS; then
664 compile_check arpa_inet_h 'for <arpa/inet.h>' \
665 '#define HAVE_ARPA_INET_H' << \!
667 #include <sys/types.h>
668 #include <sys/socket.h>
670 #include <netinet/in.h>
671 #include <arpa/inet.h>
674 ${cat} > ${tmp2}.c << \!
676 #include <sys/types.h>
677 #include <sys/socket.h>
679 #include <netinet/in.h>
680 #ifdef HAVE_ARPA_INET_H
681 #include <arpa/inet.h>
687 socket(AF_INET, SOCK_STREAM, 0);
689 gethostbyname("foo
");
694 < ${tmp2}.c link_check sockets 'for sockets in libc' \
695 '#define HAVE_SOCKETS' ||
696 < ${tmp2}.c link_check sockets 'for sockets in libnsl' \
697 '#define HAVE_SOCKETS' '-lnsl' ||
698 < ${tmp2}.c link_check sockets \
699 'for sockets in libsocket and libnsl' \
700 '#define HAVE_SOCKETS' '-lsocket -lnsl' ||
703 # XXX Shouldn't it be a hard error if there is no socket support, then?
706 echo '/* WANT_SOCKETS=0 */' >> ${h}
707 fi # wantfeat SOCKETS
710 link_check setsockopt 'for setsockopt()' '#define HAVE_SETSOCKOPT' << \!
711 #include <sys/socket.h>
716 setsockopt(sockfd, SOL_SOCKET, SO_KEEPALIVE, NULL, 0);
721 wantfeat SOCKETS && [ -n "${have_setsockopt}" ] &&
722 link_check so_sndtimeo 'for SO_SNDTIMEO' '#define HAVE_SO_SNDTIMEO' << \!
723 #include <sys/socket.h>
731 setsockopt(sockfd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof tv);
732 setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof tv);
737 wantfeat SOCKETS && [ -n "${have_setsockopt}" ] &&
738 link_check so_linger 'for SO_LINGER' '#define HAVE_SO_LINGER' << \!
739 #include <sys/socket.h>
747 setsockopt(sockfd, SOL_SOCKET, SO_LINGER, &li, sizeof li);
752 if wantfeat IPV6; then
753 link_check ipv6 'for IPv6 functionality' '#define HAVE_IPV6' << \!
755 #include <sys/types.h>
756 #include <sys/socket.h>
758 #include <netinet/in.h>
759 #ifdef HAVE_ARPA_INET_H
760 #include <arpa/inet.h>
765 struct addrinfo a, *ap;
766 getaddrinfo("foo
", "0", &a, &ap);
771 echo '/* WANT_IPV6=0 */' >> ${h}
774 if wantfeat IMAP; then
775 echo '#define HAVE_IMAP' >> ${h}
777 echo '/* WANT_IMAP=0 */' >> ${h}
780 if wantfeat POP3; then
781 echo '#define HAVE_POP3' >> ${h}
783 echo '/* WANT_POP3=0 */' >> ${h}
786 if wantfeat SMTP; then
787 echo '#define HAVE_SMTP' >> ${h}
789 echo '/* WANT_SMTP=0 */' >> ${h}
792 if wantfeat SSL; then
793 link_check openssl 'for sufficiently recent OpenSSL' \
795 #define HAVE_OPENSSL' '-lssl -lcrypto' << \!
796 #include <openssl/ssl.h>
797 #include <openssl/err.h>
798 #include <openssl/x509v3.h>
799 #include <openssl/x509.h>
800 #include <openssl/rand.h>
802 #if defined OPENSSL_NO_SSL2 && defined OPENSSL_NO_SSL3 &&\
803 defined OPENSSL_NO_TLS1
804 # error We need one of (SSLv2 and) SSLv3 and TLS1.
809 SSLv23_client_method();
810 #ifndef OPENSSL_NO_SSL3
811 SSLv3_client_method();
813 #ifndef OPENSSL_NO_TLS1
814 TLSv1_client_method();
815 # ifdef TLS1_1_VERSION
816 TLSv1_1_client_method();
818 # ifdef TLS1_2_VERSION
819 TLSv1_2_client_method();
822 PEM_read_PrivateKey(0, 0, 0, 0);
827 if [ "${have_openssl}" = 'yes' ]; then
828 compile_check stack_of 'for OpenSSL STACK_OF()' \
829 '#define HAVE_OPENSSL_STACK_OF' << \!
830 #include <openssl/ssl.h>
831 #include <openssl/err.h>
832 #include <openssl/x509v3.h>
833 #include <openssl/x509.h>
834 #include <openssl/rand.h>
838 STACK_OF(GENERAL_NAME) *gens = NULL;
839 printf("%p
", gens); /* to make it used */
844 link_check rand_egd 'for OpenSSL RAND_egd()' \
845 '#define HAVE_OPENSSL_RAND_EGD' '-lssl -lcrypto' << \!
846 #include <openssl/rand.h>
850 return RAND_egd("some.where
") > 0;
854 if wantfeat MD5 && nwantfeat NOEXTMD5; then
855 run_check openssl_md5 'for MD5 digest in OpenSSL' \
856 '#define HAVE_OPENSSL_MD5' << \!
858 #include <openssl/md5.h>
862 char const dat[] = "abrakadabrafidibus
";
863 char dig[16], hex[16 * 2];
867 memset(dig, 0, sizeof(dig));
868 memset(hex, 0, sizeof(hex));
870 MD5_Update(&ctx, dat, sizeof(dat) - 1);
871 MD5_Final(dig, &ctx);
873 #define hexchar(n) ((n) > 9 ? (n) - 10 + 'a' : (n) + '0')
874 for (i = 0; i < sizeof(hex) / 2; i++) {
876 hex[j] = hexchar((dig[i] & 0xf0) >> 4);
877 hex[++j] = hexchar(dig[i] & 0x0f);
879 return !!memcmp("6d7d0a3d949da2e96f2aa010f65d8326
", hex, sizeof(hex));
882 fi # wantfeat MD5 && nwantfeat NOEXTMD5
885 echo '/* WANT_SSL=0 */' >> ${h}
888 if wantfeat GSSAPI; then
889 ${cat} > ${tmp2}.c << \!
890 #include <gssapi/gssapi.h>
894 gss_import_name(0, 0, GSS_C_NT_HOSTBASED_SERVICE, 0);
895 gss_init_sec_context(0,0,0,0,0,0,0,0,0,0,0,0,0);
899 ${sed} -e '1s/gssapi\///' < ${tmp2}.c > ${tmp3}.c
901 if command -v krb5-config >/dev/null 2>&1; then
902 i=`command -v krb5-config`
903 GSS_LIBS="`CFLAGS= ${i} --libs gssapi`"
904 GSS_INCS="`CFLAGS= ${i} --cflags`"
905 i='for GSS-API via krb5-config(1)'
909 i='for GSS-API in gssapi/gssapi.h, libgssapi'
911 < ${tmp2}.c link_check gss \
912 "${i}" '#define HAVE_GSSAPI' "${GSS_LIBS}" "${GSS_INCS}" ||\
913 < ${tmp3}.c link_check gss \
914 'for GSS-API in gssapi.h, libgssapi' \
916 #define GSSAPI_REG_INCLUDE' \
918 < ${tmp2}.c link_check gss 'for GSS-API in libgssapi_krb5' \
919 '#define HAVE_GSSAPI' \
921 < ${tmp3}.c link_check gss \
922 'for GSS-API in libgssapi, OpenBSD-style (pre 5.3)' \
924 #define GSS_REG_INCLUDE' \
925 '-lgssapi -lkrb5 -lcrypto' \
926 '-I/usr/include/kerberosV' ||\
927 < ${tmp2}.c link_check gss 'for GSS-API in libgss' \
928 '#define HAVE_GSSAPI' \
930 link_check gss 'for GSS-API in libgssapi_krb5, old-style' \
932 #define GSSAPI_OLD_STYLE' \
933 '-lgssapi_krb5' << \!
934 #include <gssapi/gssapi.h>
935 #include <gssapi/gssapi_generic.h>
939 gss_import_name(0, 0, gss_nt_service_name, 0);
940 gss_init_sec_context(0,0,0,0,0,0,0,0,0,0,0,0,0);
945 echo '/* WANT_GSSAPI=0 */' >> ${h}
948 if wantfeat IDNA; then
949 link_check idna 'for GNU Libidn' '#define HAVE_IDNA' '-lidn' << \!
951 #include <idn-free.h>
952 #include <stringprep.h>
955 char *utf8, *idna_ascii, *idna_utf8;
956 utf8 = stringprep_locale_to_utf8("does.this.work
");
957 if (idna_to_ascii_8z(utf8, &idna_ascii, IDNA_USE_STD3_ASCII_RULES)
960 idn_free(idna_ascii);
961 /* (Rather link check only here) */
962 idna_utf8 = stringprep_convert(idna_ascii, "UTF-8
", "de_DE
");
967 echo '/* WANT_IDNA=0 */' >> ${h}
970 if wantfeat REGEX; then
971 link_check regex 'for regular expressions' '#define HAVE_REGEX' << \!
978 if (regcomp(&re, ".
*bsd
", REG_EXTENDED | REG_ICASE | REG_NOSUB) != 0)
980 status = regexec(&re, "plan9
", 0,NULL, 0);
982 return !(status == REG_NOMATCH);
986 echo '/* WANT_REGEX=0 */' >> ${h}
989 if wantfeat READLINE; then
991 link_check readline "for readline
(3) (${1})" \
992 '#define HAVE_READLINE' "${1}" << \!
994 #include <readline/history.h>
995 #include <readline/readline.h>
1004 stifle_history(242);
1005 rl = readline("Enter a line
:");
1009 rl_extend_line_buffer(10);
1010 rl_point = rl_end = 10;
1011 rl_pre_input_hook = (rl_hook_func_t*)NULL;
1012 rl_forced_update_display();
1014 hs = history_get_history_state();
1016 he = history_list();
1019 rl_free_line_state();
1020 rl_cleanup_after_signal();
1021 rl_reset_after_signal();
1027 __edrdlib -lreadline ||
1028 __edrdlib '-lreadline -ltermcap'
1029 [ -n "${have_readline}" ] && WANT_TABEXPAND=1
1032 if wantfeat EDITLINE && [ -z "${have_readline}" ]; then
1034 link_check editline "for editline
(3) (${1})" \
1035 '#define HAVE_EDITLINE' "${1}" << \!
1036 #include <histedit.h>
1037 static char * getprompt(void) { return (char*)"ok
"; }
1040 EditLine *el_el = el_init("TEST
", stdin, stdout, stderr);
1042 History *el_hcom = history_init();
1043 history(el_hcom, &he, H_SETSIZE, 242);
1044 el_set(el_el, EL_SIGNAL, 0);
1045 el_set(el_el, EL_TERMINAL, NULL);
1046 el_set(el_el, EL_HIST, &history, el_hcom);
1047 el_set(el_el, EL_EDITOR, "emacs
");
1048 el_set(el_el, EL_PROMPT, &getprompt);
1049 el_source(el_el, NULL);
1050 history(el_hcom, &he, H_GETSIZE);
1051 history(el_hcom, &he, H_CLEAR);
1053 /* TODO add loader and addfn checks */
1054 history_end(el_hcom);
1061 __edlib '-ledit -ltermcap'
1062 [ -n "${have_editline}" ] && WANT_TABEXPAND=0
1065 if wantfeat NCL && [ -z "${have_editline}" ] && [ -z "${have_readline}" ] &&\
1066 [ -n "${have_c90amend1}" ]; then
1068 echo '#define HAVE_NCL' >> ${h}
1070 echo '/* WANT_{READLINE,EDITLINE,NCL}=0 */' >> ${h}
1073 # Generic have-a-command-line-editor switch for those who need it below
1074 if [ -n "${have_ncl}" ] || [ -n "${have_editline}" ] ||\
1075 [ -n "${have_readline}" ]; then
1079 if [ -n "${have_cle}" ] && wantfeat TABEXPAND; then
1080 echo '#define HAVE_TABEXPAND' >> ${h}
1082 echo '/* WANT_TABEXPAND=0 */' >> ${h}
1085 if [ -n "${have_cle}" ] && wantfeat HISTORY; then
1086 echo '#define HAVE_HISTORY' >> ${h}
1088 echo '/* WANT_HISTORY=0 */' >> ${h}
1091 if wantfeat SPAM; then
1092 echo '#define HAVE_SPAM' >> ${h}
1093 if command -v spamc >/dev/null 2>&1; then
1094 echo "#define SPAMC_PATH \"`command -v spamc`\"" >> ${h}
1097 echo '/* WANT_SPAM=0 */' >> ${h}
1100 if wantfeat DOCSTRINGS
; then
1101 echo '#define HAVE_DOCSTRINGS' >> ${h}
1103 echo '/* WANT_DOCSTRINGS=0 */' >> ${h}
1106 if wantfeat QUOTE_FOLD
&&\
1107 [ -n "${have_c90amend1}" ] && [ -n "${have_wcwidth}" ]; then
1108 echo '#define HAVE_QUOTE_FOLD' >> ${h}
1110 echo '/* WANT_QUOTE_FOLD=0 */' >> ${h}
1113 if wantfeat COLOUR
; then
1114 echo '#define HAVE_COLOUR' >> ${h}
1116 echo '/* WANT_COLOUR=0 */' >> ${h}
1119 if wantfeat IMAP_SEARCH
; then
1120 echo '#define HAVE_IMAP_SEARCH' >> ${h}
1122 echo '/* WANT_IMAP_SEARCH=0 */' >> ${h}
1125 if wantfeat MD5
; then
1126 echo '#define HAVE_MD5' >> ${h}
1128 echo '/* WANT_MD5=0 */' >> ${h}
1133 # Since we cat(1) the content of those to cc/"ld", convert them to single line
1135 < "${1}" > "${2}" ${awk} \
1136 'BEGIN {ORS = " "} /^[^#]/ {print} {next} END {ORS = ""; print "\n"}'
1139 squeeze_em ${inc} ${tmp}
1141 squeeze_em ${lib} ${tmp}
1146 printf '#ifndef _CONFIG_H\n# define _CONFIG_H\n' > ${h}
1147 ${cat} ${tmp} >> ${h}
1149 printf '\n/* The "feature string
", for "simplicity
" and lex.c */\n' >> ${h}
1150 printf '#ifdef _MAIN_SOURCE\n' >> ${h}
1151 printf '# ifdef HAVE_AMALGAMATION\nstatic\n# endif\n' >> ${h}
1152 printf 'char const features[] = "MIME
"\n' >> ${h}
1153 printf '# ifdef HAVE_DOCSTRINGS\n ",DOCSTRINGS
"\n# endif\n' >> ${h}
1154 printf '# ifdef HAVE_ICONV\n ",ICONV
"\n# endif\n' >> ${h}
1155 printf '# ifdef HAVE_SETLOCALE\n ",LOCALES
"\n# endif\n' >> ${h}
1156 printf '# ifdef HAVE_C90AMEND1\n ",MULTIBYTE CHARSETS
"\n# endif\n' >> ${h}
1157 printf '# ifdef HAVE_NL_LANGINFO\n ",TERMINAL CHARSET
"\n# endif\n' >> ${h}
1158 printf '# ifdef HAVE_SOCKETS\n ",NETWORK
"\n# endif\n' >> ${h}
1159 printf '# ifdef HAVE_IPV6\n ",IPv6
"\n# endif\n' >> ${h}
1160 printf '# ifdef HAVE_SSL\n ",S
/MIME
,SSL
/TLS
"\n# endif\n' >> ${h}
1161 printf '# ifdef HAVE_IMAP\n ",IMAP
"\n# endif\n' >> ${h}
1162 printf '# ifdef HAVE_GSSAPI\n ",GSS-API
"\n# endif\n' >> ${h}
1163 printf '# ifdef HAVE_POP3\n ",POP3
"\n# endif\n' >> ${h}
1164 printf '# ifdef HAVE_SMTP\n ",SMTP
"\n# endif\n' >> ${h}
1165 printf '# ifdef HAVE_SPAM\n ",SPAM
"\n# endif\n' >> ${h}
1166 printf '# ifdef HAVE_IDNA\n ",IDNA
"\n# endif\n' >> ${h}
1167 printf '# ifdef HAVE_IMAP_SEARCH\n ",IMAP-searches
"\n# endif\n' >> ${h}
1168 printf '# ifdef HAVE_REGEX\n ",REGEX
"\n# endif\n' >> ${h}
1169 printf '# ifdef HAVE_READLINE\n ",READLINE
"\n# endif\n' >> ${h}
1170 printf '# ifdef HAVE_EDITLINE\n ",EDITLINE
"\n# endif\n' >> ${h}
1171 printf '# ifdef HAVE_NCL\n ",NCL
"\n# endif\n' >> ${h}
1172 printf '# ifdef HAVE_TABEXPAND\n ",TABEXPAND
"\n# endif\n' >> ${h}
1173 printf '# ifdef HAVE_HISTORY\n ",HISTORY MANAGEMENT
"\n# endif\n' >> ${h}
1174 printf '# ifdef HAVE_QUOTE_FOLD\n ",QUOTE-FOLD
"\n# endif\n' >> ${h}
1175 printf '# ifdef HAVE_COLOUR\n ",COLOUR
"\n# endif\n' >> ${h}
1176 printf '# ifdef HAVE_DEBUG\n ",DEBUG
"\n# endif\n' >> ${h}
1177 printf ';\n#endif /* _MAIN_SOURCE */\n' >> ${h}
1179 printf '#endif /* _CONFIG_H */\n' >> ${h}
1182 # Create the real mk.mk
1183 ${rm} -rf ${tmp0}.* ${tmp0}*
1184 printf 'OBJ_SRC = ' >> ${mk}
1185 if nwantfeat AMALGAMATION; then
1187 echo 'OBJ_DEP =' >> ${mk}
1189 j=`echo "${src}" | sed 's/^.\///'`
1190 echo "${j}" >> ${mk}
1191 printf 'OBJ_DEP = main.c ' >> ${mk}
1192 printf '#define _MAIN_SOURCE\n' >> ${src}
1193 printf '#include "nail.h
"\n#include "main.c
"\n' >> ${src}
1195 if [ "${i}" = "${j}" ] || [ "${i}" = main.c ]; then
1198 printf "${i} " >> ${mk}
1199 printf "#include \"${i}\"\n" >> ${src}
1204 echo "LIBS = `${cat} ${lib}`" >> ${mk}
1205 echo "INCLUDES
= `${cat} ${inc}`" >> ${mk}
1207 ${cat} ./mk-mk.in >> ${mk}
1211 ${cat} > ${tmp2}.c << \!
1213 #ifdef HAVE_NL_LANGINFO
1214 # include <langinfo.h>
1217 :The following optional features are enabled:
1219 : + Character set conversion using iconv()
1221 #ifdef HAVE_SETLOCALE
1222 : + Locale support: Printable characters depend on the environment
1223 # ifdef HAVE_C90AMEND1
1224 : + Multibyte character support
1226 # ifdef HAVE_NL_LANGINFO
1227 : + Automatic detection of terminal character set
1234 : + Support for Internet Protocol v6 (IPv6)
1237 # ifdef HAVE_OPENSSL
1238 : + S/MIME and SSL/TLS using OpenSSL
1245 : + GSS-API authentication
1254 : + Interaction with spam filters
1257 : + IDNA (internationalized domain names for applications) support
1259 #ifdef HAVE_IMAP_SEARCH
1260 : + IMAP-style search expressions
1263 : + Regular expression support (searches, conditional expressions etc.)
1265 #if defined HAVE_READLINE || defined HAVE_EDITLINE || defined HAVE_NCL
1266 : + Command line editing
1267 # ifdef HAVE_TABEXPAND
1268 : + + Tabulator expansion
1270 # ifdef HAVE_HISTORY
1271 : + + History management
1274 #ifdef HAVE_QUOTE_FOLD
1275 : + Extended *quote-fold*ing
1278 : + Coloured message display (simple)
1281 :The following optional features are disabled:
1283 : - Character set conversion using iconv()
1285 #ifndef HAVE_SETLOCALE
1286 : - Locale support: Only ASCII characters are recognized
1288 # ifndef HAVE_C90AMEND1
1289 : - Multibyte character support
1291 # ifndef HAVE_NL_LANGINFO
1292 : - Automatic detection of terminal character set
1294 #ifndef HAVE_SOCKETS
1298 : - Support for Internet Protocol v6 (IPv6)
1300 #if !defined HAVE_SSL
1301 : - SSL/TLS (network transport authentication and encryption)
1307 : - GSS-API authentication
1316 : - Interaction with spam filters
1319 : - IDNA (internationalized domain names for applications) support
1321 #ifndef HAVE_IMAP_SEARCH
1322 : - IMAP-style search expressions
1325 : - Regular expression support
1327 #if !defined HAVE_READLINE && !defined HAVE_EDITLINE && !defined HAVE_NCL
1328 : - Command line editing and history
1330 #ifndef HAVE_QUOTE_FOLD
1331 : - Extended *quote-fold*ing
1334 : - Coloured message display (simple)
1338 #ifndef HAVE_SNPRINTF
1339 : . The function snprintf() could not be found. mailx will be compiled to use
1340 : sprintf() instead. This might overflow buffers if input values are larger
1341 : than expected. Use the resulting binary with care or update your system
1342 : environment and start the configuration process again.
1345 : . The function fchdir() could not be found. mailx will be compiled to use
1346 : chdir() instead. This is not a problem unless the current working
1347 : directory of mailx is moved while the IMAP cache is used.
1350 : . Debug enabled binary: not meant to be used by end-users: THANKS!
1355 ${make} -f ${makefile} ${tmp2}.x
1356 < ${tmp2}.x >&5 ${sed} -e '/^[^:]/d; /^$/d; s/^://'
1358 # vim:set fenc=utf-8:s-it-mode