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
40 echo >&2 "Unknown CONFIG= setting: ${CONFIG}"
41 echo >&2 'Possible values: MINIMAL, MEDIUM, NETSEND'
48 if nwantfeat SOCKETS
; then
49 WANT_IPV6
=0 WANT_SSL
=0
50 WANT_IMAP
=0 WANT_GSSAPI
=0 WANT_POP3
=0 WANT_SMTP
=0
52 if nwantfeat IMAP
&& nwantfeat POP3
&& nwantfeat SMTP
; then
53 WANT_SOCKETS
=0 WANT_IPV6
=0 WANT_SSL
=0
55 if nwantfeat IMAP
; then
58 # If we don't need MD5 except for producing boundary and message-id strings,
59 # leave it off, plain old srand(3) should be enough for that purpose.
60 if nwantfeat SOCKETS
; then
63 if wantfeat DEBUG
; then
68 # Check out compiler ($CC) and -flags ($CFLAGS)
73 # $CC is overwritten when empty or a default "cc", even without WANT_AUTOCC
75 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 [ "${i}" = 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} -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 if { i
=${ccver}; echo "${i}"; } |
${grep} -q -e 'clang version 1'; then
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 if wantfeat DEBUG
; then
122 _CFLAGS
="${_CFLAGS} -std=c89"
123 _CFLAGS
="${_CFLAGS} -Wno-long-long" # ISO C89 has no 'long long'...
125 # elif { i=${ccver}; echo "${i}"; } | ${grep} -q -i -e clang; then
127 # optim=-O3 dbgoptim=-O
128 # _CFLAGS='-std=c89 -g -Weverything -Wno-long-long'
129 # if wantfeat AMALGAMATION; then
130 # _CFLAGS="${_CFLAGS} -pipe"
132 # if wantfeat DEBUG; then
133 # _CFLAGS="${_CFLAGS} -std=c89"
134 # _CFLAGS="${_CFLAGS} -Wno-long-long" # ISO C89 has no 'long long'...
136 elif [ -z "${optim}" ]; then
137 optim
=-O1 dbgoptim
=-O
140 if nwantfeat DEBUG
; then
141 _CFLAGS
="${optim} -DNDEBUG ${_CFLAGS}"
143 _CFLAGS
="${dbgoptim} -g -ftrapv ${_CFLAGS}";
144 if [ "${stackprot}" = yes ]; then
145 _CFLAGS
="${_CFLAGS} -fstack-protector-all "
146 _CFLAGS
="${_CFLAGS} -Wstack-protector -D_FORTIFY_SOURCE=2"
149 _CFLAGS
="${_CFLAGS} ${ADDCFLAGS}"
150 # XXX -Wl,-z,relro -Wl,-z,now -Wl,-z,noexecstack: need detection
151 _LDFLAGS
="${_LDFLAGS} ${ADDLDFLAGS}" # XXX -Wl,--sort-common,[-O1]
152 export _CFLAGS _LDFLAGS
154 # $CFLAGS and $LDFLAGS are only overwritten if explicitly wanted
155 if wantfeat AUTOCC
; then
158 export CFLAGS LDFLAGS
165 ## - Heirloom sh(1) (and same origin) have problems with ': >' redirection,
166 ## so use "printf '' >" instead
167 ## - Heirloom sh(1) and maybe more execute loops with redirection in a subshell
168 ## (but don't export eval's from within), therefore we need to (re)include
169 ## variable assignments at toplevel instead (via reading temporary files)
171 ## First of all, create new configuration and check wether it changed ##
178 newlst
=.
/config.lst-new
179 newmk
=.
/config.mk-new
184 # We need some standard utilities
187 n
=$1 i
=$2 opt
=${3:-0}
188 if type "${i}" >/dev
/null
2>&1; then
192 if [ ${opt} -eq 0 ]; then
193 echo >&2 "ERROR: no trace of the utility \`${n}'"
199 # Check those tools right now that we need before including ${conf}
200 check_tool
rm "${rm:-`command -v rm`}"
201 check_tool
sed "${sed:-`command -v sed`}"
203 # Only incorporate what wasn't overwritten from command line / CONFIG
204 trap "${rm} -f ${tmp}; exit" 1 2 15
205 trap "${rm} -f ${tmp}" 0
208 < ${conf} ${sed} -e '/^[ \t]*#/d' -e '/^$/d' -e 's/[ \t]*$//' |
210 i
=`echo ${line} | ${sed} -e 's/=.*$//'`
211 eval j
=\$
${i} jx=\${${i}+x}
212 if [ -n "${j}" ] ||
[ "${jx}" = x
]; then
219 check_tool
awk "${awk:-`command -v awk`}"
220 check_tool
cat "${cat:-`command -v cat`}"
221 check_tool
chmod "${chmod:-`command -v chmod`}"
222 check_tool
cp "${cp:-`command -v cp`}"
223 check_tool
cmp "${cmp:-`command -v cmp`}"
224 check_tool
grep "${grep:-`command -v grep`}"
225 check_tool mkdir
"${mkdir:-`command -v mkdir`}"
226 check_tool
mv "${mv:-`command -v mv`}"
227 # rm(1), sed(1) above
228 check_tool
tee "${tee:-`command -v tee`}"
230 check_tool
make "${MAKE:-`command -v make`}"
231 check_tool strip
"${STRIP:-`command -v strip`}" 1
245 # (No function since some shells loose non-exported variables in traps)
246 trap "${rm} -f ${tmp} ${newlst} ${newmk} ${newh}; exit" 1 2 15
247 trap "${rm} -f ${tmp} ${newlst} ${newmk} ${newh}" 0
248 ${rm} -f ${newlst} ${newmk} ${newh}
250 # (Could: use FD redirection, add eval(1) and don't re-'. ./${newlst}')
252 i
=`echo ${line} | ${sed} -e 's/=.*$//'`
254 if [ -z "${j}" ] ||
[ "${j}" = 0 ]; then
255 printf "/*#define ${i}*/\n" >> ${newh}
256 elif [ "${j}" = 1 ]; then
257 printf "#define ${i}\n" >> ${newh}
259 printf "#define ${i} \"${j}\"\n" >> ${newh}
261 printf "${i} = ${j}\n" >> ${newmk}
262 printf "${i}=\"${j}\"\n"
263 done < ${tmp} > ${newlst}
266 printf "#define UAGENT \"${SID}${NAIL}\"\n" >> ${newh}
267 printf "UAGENT
= ${SID}${NAIL}\n" >> ${newmk}
271 printf "CC = ${CC}\n" >> ${newmk}
272 printf "_CFLAGS = ${_CFLAGS}\nCFLAGS = ${CFLAGS}\n" >> ${newmk}
273 printf "_LDFLAGS
= ${_LDFLAGS}\nLDFLAGS = ${LDFLAGS}\n" >> ${newmk}
274 printf "AWK = ${awk}\nCMP = ${cmp}\nCHMOD = ${chmod}\nCP = ${cp}\n" >> ${newmk}
275 printf "GREP
= ${grep}\nMKDIR = ${mkdir}\nRM = ${rm}\nSED = ${sed}\n" \
277 printf "STRIP
= ${strip}\nHAVE_STRIP = ${HAVE_STRIP}\n" >> ${newmk}
278 # (We include the cc(1)/ld(1) environment only for update detection..)
279 printf "CC=\"${CC}\"\n" >> ${newlst}
280 printf "_CFLAGS=\"${_CFLAGS}\"\nCFLAGS=\"${CFLAGS}\"\n" >> ${newlst}
281 printf "_LDFLAGS
=\"${_LDFLAGS}\"\nLDFLAGS=\"${LDFLAGS}\"\n" >> ${newlst}
282 printf "AWK=${awk}\nCMP=${cmp}\nCHMOD=${chmod}\nCP=${cp}\n" >> ${newlst}
283 printf "GREP
=${grep}\nMKDIR=${mkdir}\nRM=${rm}\nSED=${sed}\n" >> ${newlst}
284 printf "STRIP=${strip}\nHAVE_STRIP=${HAVE_STRIP}\n" >> ${newlst}
286 if [ -f ${lst} ] && ${cmp} ${newlst} ${lst} >/dev/null 2>&1; then
289 [ -f ${lst} ] && echo 'configuration updated..' || echo 'shiny configuration..'
291 ${mv} -f ${newlst} ${lst}
292 ${mv} -f ${newh} ${h}
293 ${mv} -f ${newmk} ${mk}
295 ## Compile and link checking ##
305 # (No function since some shells loose non-exported variables in traps)
306 trap "${rm} -f ${lst} ${h} ${mk} ${lib} ${inc} ${src} ${makefile}; exit" 1 2 15
307 trap "${rm} -rf ${tmp0}.* ${tmp0}* ${makefile}" 0
309 exec 5>&2 > ${log} 2>&1
312 # ${src} is only created if WANT_AMALGAMATION
314 ${cat} > ${makefile} << \!
315 .SUFFIXES: .o .c .x .y
319 $(CC) $(XINCS) -E $< >$@
321 $(CC) $(XINCS) -o $@ $< $(XLIBS)
329 printf "*** ${fmt}\\n
" "${@}"
330 printf "${fmt}" "${@}" >&5
334 variable=$1 topic=$2 define=$3
337 msg "checking
${topic} ...
"
338 echo "/* checked
${topic} */" >> ${h}
339 ${rm} -f ${tmp} ${tmp}.o
340 echo '*** test program is'
342 #echo '*** the preprocessor generates'
343 #${make} -f ${makefile} ${tmp}.x
345 echo '*** results are'
349 variable=$1 topic=$2 define=$3
351 _check_preface "${variable}" "${topic}" "${define}"
353 if ${make} -f ${makefile} XINCS="${INCS}" ./${tmp}.o &&
354 [ -f ./${tmp}.o ]; then
356 echo "${define}" >> ${h}
357 eval have_${variable}=yes
360 echo "/* ${define} */" >> ${h}
362 eval unset have_${variable}
368 run=$1 variable=$2 topic=$3 define=$4 libs=$5 incs=$6
370 _check_preface "${variable}" "${topic}" "${define}"
372 if ${make} -f ${makefile} XINCS="${INCS} ${incs}" \
373 XLIBS
="${LIBS} ${libs}" ./${tmp} &&
375 { [ ${run} -eq 0 ] || ./${tmp}; }; then
376 echo "*** adding INCS
<${incs}> LIBS
<${libs}>"
378 echo "${define}" >> ${h}
379 LIBS="${LIBS} ${libs}"
380 echo "${libs}" >> ${lib}
381 INCS="${INCS} ${incs}"
382 echo "${incs}" >> ${inc}
383 eval have_${variable}=yes
387 echo "/* ${define} */" >> ${h}
388 eval unset have_${variable}
394 _link_mayrun 0 "${1}" "${2}" "${3}" "${4}" "${5}"
398 _link_mayrun 1 "${1}" "${2}" "${3}" "${4}" "${5}"
401 # Build a basic set of INCS and LIBS according to user environment.
402 # On pkgsrc(7) systems automatically add /usr/pkg/*
403 if [ -n "${C_INCLUDE_PATH}" ]; then
406 set -- ${C_INCLUDE_PATH}
408 # for i; do -- new in POSIX Issue 7 + TC1
411 [ "${i}" = '/usr/pkg/include' ] && continue
412 INCS="${INCS} -I${i}"
415 [ -d /usr/pkg/include ] && INCS="${INCS} -I/usr
/pkg
/include
"
416 echo "${INCS}" >> ${inc}
418 if [ -n "${LD_LIBRARY_PATH}" ]; then
421 set -- ${LD_LIBRARY_PATH}
423 # for i; do -- new in POSIX Issue 7 + TC1
426 [ "${i}" = '/usr/pkg/lib' ] && continue
427 LIBS="${LIBS} -L${i}"
430 [ -d /usr/pkg/lib ] && LIBS="${LIBS} -L/usr
/pkg
/lib
"
431 echo "${LIBS}" >> ${lib}
435 # Better set _GNU_SOURCE (if we are on Linux only?); 'surprised it did without
436 echo '#define _GNU_SOURCE' >> ${h}
438 if link_check hello 'if a hello world program can be built' << \!
441 int main(int argc, char *argv[])
452 echo >&5 'This oooops is most certainly not related to me.'
453 echo >&5 "Read the
file ${log} and check your compiler environment.
"
454 ${rm} -f ${lst} ${h} ${mk}
458 if link_check termios 'for termios.h and tc*() family' << \!
464 tcsetattr(0, TCSADRAIN | TCSAFLUSH, &tios);
471 echo >&5 'We require termios.h and the tc*() family of functions.'
472 echo >&5 "That much Unix we indulge ourselfs.
"
473 ${rm} -f ${lst} ${h} ${mk}
477 link_check setenv 'for setenv()/unsetenv()' '#define HAVE_SETENV' << \!
481 setenv("s-nail
", "to be made nifty
!", 1);
487 link_check snprintf 'for snprintf()' '#define HAVE_SNPRINTF' << \!
492 snprintf(b, sizeof b, "%s
", "string
");
497 link_check putc_unlocked 'for putc_unlocked()' '#define HAVE_PUTC_UNLOCKED' <<\!
501 putc_unlocked('@', stdout);
506 link_check fchdir 'for fchdir()' '#define HAVE_FCHDIR' << \!
515 link_check pipe2 'for pipe2()' '#define HAVE_PIPE2' << \!
521 pipe2(fds, O_CLOEXEC);
526 link_check mmap 'for mmap()' '#define HAVE_MMAP' << \!
527 #include <sys/types.h>
528 #include <sys/mman.h>
531 mmap(0, 0, 0, 0, 0, 0);
536 link_check mremap 'for mremap()' '#define HAVE_MREMAP' << \!
537 #include <sys/types.h>
538 #include <sys/mman.h>
541 mremap(0, 0, 0, MREMAP_MAYMOVE);
546 link_check setlocale 'for setlocale()' '#define HAVE_SETLOCALE' << \!
550 setlocale(LC_ALL, "");
555 if [ "${have_setlocale}" = yes ]; then
556 link_check c90amend1 'for ISO/IEC 9899:1990/Amendment 1:1995' \
557 '#define HAVE_C90AMEND1' << \!
564 char mbb[MB_LEN_MAX + 1];
569 mbrtowc(&wc, "x
", 1, NULL);
570 (void)wctomb(mbb, wc);
571 return (mblen("\
0", 1) == 0);
575 if [ "${have_c90amend1}" = yes ]; then
576 link_check wcwidth 'for wcwidth()' '#define HAVE_WCWIDTH' << \!
586 link_check nl_langinfo 'for nl_langinfo()' '#define HAVE_NL_LANGINFO' << \!
587 #include <langinfo.h>
592 return (nl_langinfo(CODESET) == NULL);
597 link_check mkstemp 'for mkstemp()' '#define HAVE_MKSTEMP' << \!
606 # Note: run_check, thus we also get only the desired implementation...
607 run_check realpath 'for realpath()' '#define HAVE_REALPATH' << \!
611 char *x = realpath(".
", NULL), *y = realpath("/", NULL);
612 return (x != NULL && y != NULL) ? 0 : 1;
616 link_check wordexp 'for wordexp()' '#define HAVE_WORDEXP' << \!
620 wordexp((char *)0, (wordexp_t *)0, 0);
627 if wantfeat DEBUG; then
628 echo '#define HAVE_DEBUG' >> ${h}
631 if wantfeat AMALGAMATION; then
632 echo '#define HAVE_AMALGAMATION' >> ${h}
635 if nwantfeat NOALLOCA; then
636 # Due to NetBSD PR lib/47120 it seems best not to use non-cc-builtin
637 # versions of alloca(3) since modern compilers just can't be trusted
638 # not to overoptimize and silently break some code
639 link_check alloca 'for __builtin_alloca()' \
640 '#define HAVE_ALLOCA __builtin_alloca' << \!
643 void *vp = __builtin_alloca(1);
649 if nwantfeat NOGETOPT; then
650 link_check getopt 'for getopt()' '#define HAVE_GETOPT' << \!
652 int main(int argc, char **argv)
654 #if defined __GLIBC__ || defined __linux__
655 Argument and option reordering is not a desired feature.
657 getopt(argc, argv, "oPt
");
659 return (((long)optarg + optind) & 0x7F);
666 if wantfeat ICONV; then
667 ${cat} > ${tmp2}.c << \!
673 id = iconv_open("foo
", "bar
");
677 < ${tmp2}.c link_check iconv 'for iconv functionality' \
678 '#define HAVE_ICONV' ||
679 < ${tmp2}.c link_check iconv \
680 'for iconv functionality in libiconv' \
681 '#define HAVE_ICONV' '-liconv'
683 echo '/* WANT_ICONV=0 */' >> ${h}
686 if wantfeat SOCKETS; then
687 compile_check arpa_inet_h 'for <arpa/inet.h>' \
688 '#define HAVE_ARPA_INET_H' << \!
690 #include <sys/types.h>
691 #include <sys/socket.h>
693 #include <netinet/in.h>
694 #include <arpa/inet.h>
697 ${cat} > ${tmp2}.c << \!
699 #include <sys/types.h>
700 #include <sys/socket.h>
702 #include <netinet/in.h>
703 #ifdef HAVE_ARPA_INET_H
704 #include <arpa/inet.h>
710 socket(AF_INET, SOCK_STREAM, 0);
712 gethostbyname("foo
");
717 < ${tmp2}.c link_check sockets 'for sockets in libc' \
718 '#define HAVE_SOCKETS' ||
719 < ${tmp2}.c link_check sockets 'for sockets in libnsl' \
720 '#define HAVE_SOCKETS' '-lnsl' ||
721 < ${tmp2}.c link_check sockets \
722 'for sockets in libsocket and libnsl' \
723 '#define HAVE_SOCKETS' '-lsocket -lnsl' ||
726 # XXX Shouldn't it be a hard error if there is no socket support, then?
729 echo '/* WANT_SOCKETS=0 */' >> ${h}
730 fi # wantfeat SOCKETS
733 link_check setsockopt 'for setsockopt()' '#define HAVE_SETSOCKOPT' << \!
734 #include <sys/socket.h>
739 setsockopt(sockfd, SOL_SOCKET, SO_KEEPALIVE, NULL, 0);
744 wantfeat SOCKETS && [ -n "${have_setsockopt}" ] &&
745 link_check so_sndtimeo 'for SO_SNDTIMEO' '#define HAVE_SO_SNDTIMEO' << \!
746 #include <sys/socket.h>
754 setsockopt(sockfd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof tv);
755 setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof tv);
760 wantfeat SOCKETS && [ -n "${have_setsockopt}" ] &&
761 link_check so_linger 'for SO_LINGER' '#define HAVE_SO_LINGER' << \!
762 #include <sys/socket.h>
770 setsockopt(sockfd, SOL_SOCKET, SO_LINGER, &li, sizeof li);
775 if wantfeat IPV6; then
776 link_check ipv6 'for IPv6 functionality' '#define HAVE_IPV6' << \!
778 #include <sys/types.h>
779 #include <sys/socket.h>
781 #include <netinet/in.h>
782 #ifdef HAVE_ARPA_INET_H
783 #include <arpa/inet.h>
788 struct addrinfo a, *ap;
789 getaddrinfo("foo
", "0", &a, &ap);
794 echo '/* WANT_IPV6=0 */' >> ${h}
797 if wantfeat IMAP; then
798 echo '#define HAVE_IMAP' >> ${h}
800 echo '/* WANT_IMAP=0 */' >> ${h}
803 if wantfeat POP3; then
804 echo '#define HAVE_POP3' >> ${h}
806 echo '/* WANT_POP3=0 */' >> ${h}
809 if wantfeat SMTP; then
810 echo '#define HAVE_SMTP' >> ${h}
812 echo '/* WANT_SMTP=0 */' >> ${h}
815 if wantfeat SSL; then
816 link_check openssl 'for sufficiently recent OpenSSL' \
818 #define HAVE_OPENSSL' '-lssl -lcrypto' << \!
819 #include <openssl/ssl.h>
820 #include <openssl/err.h>
821 #include <openssl/x509v3.h>
822 #include <openssl/x509.h>
823 #include <openssl/rand.h>
825 #if defined OPENSSL_NO_SSL2 && defined OPENSSL_NO_SSL3 &&\
826 defined OPENSSL_NO_TLS1
827 # error We need one of (SSLv2 and) SSLv3 and TLS1.
832 SSLv23_client_method();
833 #ifndef OPENSSL_NO_SSL3
834 SSLv3_client_method();
836 #ifndef OPENSSL_NO_TLS1
837 TLSv1_client_method();
838 # ifdef TLS1_1_VERSION
839 TLSv1_1_client_method();
841 # ifdef TLS1_2_VERSION
842 TLSv1_2_client_method();
845 PEM_read_PrivateKey(0, 0, 0, 0);
850 if [ "${have_openssl}" = 'yes' ]; then
851 compile_check stack_of 'for OpenSSL STACK_OF()' \
852 '#define HAVE_STACK_OF' << \!
853 #include <openssl/ssl.h>
854 #include <openssl/err.h>
855 #include <openssl/x509v3.h>
856 #include <openssl/x509.h>
857 #include <openssl/rand.h>
861 STACK_OF(GENERAL_NAME) *gens = NULL;
862 printf("%p
", gens); /* to make it used */
867 if wantfeat MD5; then
868 run_check openssl_md5 'for MD5 digest in OpenSSL' \
869 '#define HAVE_OPENSSL_MD5' << \!
871 #include <openssl/md5.h>
875 char const dat[] = "abrakadabrafidibus
";
876 char dig[16], hex[16 * 2];
880 memset(dig, 0, sizeof(dig));
881 memset(hex, 0, sizeof(hex));
883 MD5_Update(&ctx, dat, sizeof(dat) - 1);
884 MD5_Final(dig, &ctx);
886 #define hexchar(n) ((n) > 9 ? (n) - 10 + 'a' : (n) + '0')
887 for (i = 0; i < sizeof(hex) / 2; i++) {
889 hex[j] = hexchar((dig[i] & 0xf0) >> 4);
890 hex[++j] = hexchar(dig[i] & 0x0f);
892 return !!memcmp("6d7d0a3d949da2e96f2aa010f65d8326
", hex, sizeof(hex));
898 echo '/* WANT_SSL=0 */' >> ${h}
901 if wantfeat GSSAPI; then
902 ${cat} > ${tmp2}.c << \!
903 #include <gssapi/gssapi.h>
907 gss_import_name(0, 0, GSS_C_NT_HOSTBASED_SERVICE, 0);
908 gss_init_sec_context(0,0,0,0,0,0,0,0,0,0,0,0,0);
912 ${sed} -e '1s/gssapi\///' < ${tmp2}.c > ${tmp3}.c
914 if command -v krb5-config >/dev/null 2>&1; then
915 i=`command -v krb5-config`
916 GSSAPI_LIBS="`CFLAGS= ${i} --libs gssapi`"
917 GSSAPI_INCS="`CFLAGS= ${i} --cflags`"
918 i='for GSSAPI via krb5-config(1)'
920 GSSAPI_LIBS='-lgssapi'
922 i='for GSSAPI in gssapi/gssapi.h, libgssapi'
924 < ${tmp2}.c link_check gssapi \
925 "${i}" '#define HAVE_GSSAPI' \
926 "${GSSAPI_LIBS}" "${GSSAPI_INCS}" ||\
927 < ${tmp3}.c link_check gssapi \
928 'for GSSAPI in gssapi.h, libgssapi' \
930 #define GSSAPI_REG_INCLUDE' \
932 < ${tmp2}.c link_check gssapi 'for GSSAPI in libgssapi_krb5' \
933 '#define HAVE_GSSAPI' \
935 < ${tmp3}.c link_check gssapi \
936 'for GSSAPI in libgssapi, OpenBSD-style (pre 5.3)' \
938 #define GSSAPI_REG_INCLUDE' \
939 '-lgssapi -lkrb5 -lcrypto' \
940 '-I/usr/include/kerberosV' ||\
941 < ${tmp2}.c link_check gssapi 'for GSSAPI in libgss' \
942 '#define HAVE_GSSAPI' \
944 link_check gssapi 'for GSSAPI in libgssapi_krb5, old-style' \
946 #define GSSAPI_OLD_STYLE' \
947 '-lgssapi_krb5' << \!
948 #include <gssapi/gssapi.h>
949 #include <gssapi/gssapi_generic.h>
953 gss_import_name(0, 0, gss_nt_service_name, 0);
954 gss_init_sec_context(0,0,0,0,0,0,0,0,0,0,0,0,0);
959 echo '/* WANT_GSSAPI=0 */' >> ${h}
962 if wantfeat IDNA; then
963 link_check idna 'for GNU Libidn' '#define HAVE_IDNA' '-lidn' << \!
965 #include <idn-free.h>
966 #include <stringprep.h>
969 char *utf8, *idna_ascii, *idna_utf8;
970 utf8 = stringprep_locale_to_utf8("does.this.work
");
971 if (idna_to_ascii_8z(utf8, &idna_ascii, IDNA_USE_STD3_ASCII_RULES)
974 idn_free(idna_ascii);
975 /* (Rather link check only here) */
976 idna_utf8 = stringprep_convert(idna_ascii, "UTF-8
", "de_DE
");
981 echo '/* WANT_IDNA=0 */' >> ${h}
984 if wantfeat REGEX; then
985 link_check regex 'for regular expressions' '#define HAVE_REGEX' << \!
992 if (regcomp(&re, ".
*bsd
", REG_EXTENDED | REG_ICASE | REG_NOSUB) != 0)
994 status = regexec(&re, "plan9
", 0,NULL, 0);
996 return !(status == REG_NOMATCH);
1000 echo '/* WANT_REGEX=0 */' >> ${h}
1003 if wantfeat READLINE; then
1005 link_check readline "for readline
(3) (${1})" \
1006 '#define HAVE_READLINE' "${1}" << \!
1008 #include <readline/history.h>
1009 #include <readline/readline.h>
1018 stifle_history(242);
1019 rl = readline("Enter a line
:");
1023 rl_extend_line_buffer(10);
1024 rl_point = rl_end = 10;
1025 rl_pre_input_hook = (rl_hook_func_t*)NULL;
1026 rl_forced_update_display();
1028 hs = history_get_history_state();
1030 he = history_list();
1033 rl_free_line_state();
1034 rl_cleanup_after_signal();
1035 rl_reset_after_signal();
1041 __edrdlib -lreadline ||
1042 __edrdlib '-lreadline -ltermcap'
1043 [ -n "${have_readline}" ] && WANT_TABEXPAND=1
1046 if wantfeat EDITLINE && [ -z "${have_readline}" ]; then
1048 link_check editline "for editline
(3) (${1})" \
1049 '#define HAVE_EDITLINE' "${1}" << \!
1050 #include <histedit.h>
1051 static char * getprompt(void) { return (char*)"ok
"; }
1054 EditLine *el_el = el_init("TEST
", stdin, stdout, stderr);
1056 History *el_hcom = history_init();
1057 history(el_hcom, &he, H_SETSIZE, 242);
1058 el_set(el_el, EL_SIGNAL, 0);
1059 el_set(el_el, EL_TERMINAL, NULL);
1060 el_set(el_el, EL_HIST, &history, el_hcom);
1061 el_set(el_el, EL_EDITOR, "emacs
");
1062 el_set(el_el, EL_PROMPT, &getprompt);
1063 el_source(el_el, NULL);
1064 history(el_hcom, &he, H_GETSIZE);
1065 history(el_hcom, &he, H_CLEAR);
1067 /* TODO add loader and addfn checks */
1068 history_end(el_hcom);
1075 __edlib '-ledit -ltermcap'
1076 [ -n "${have_editline}" ] && WANT_TABEXPAND=0
1079 if wantfeat NCL && [ -z "${have_editline}" ] && [ -z "${have_readline}" ] &&\
1080 [ -n "${have_c90amend1}" ]; then
1082 echo '#define HAVE_NCL' >> ${h}
1084 echo '/* WANT_{READLINE,EDITLINE,NCL}=0 */' >> ${h}
1087 # Generic have-a-command-line-editor switch for those who need it below
1088 if [ -n "${have_ncl}" ] || [ -n "${have_editline}" ] ||\
1089 [ -n "${have_readline}" ]; then
1093 if [ -n "${have_cle}" ] && wantfeat TABEXPAND; then
1094 echo '#define HAVE_TABEXPAND' >> ${h}
1096 echo '/* WANT_TABEXPAND=0 */' >> ${h}
1099 if [ -n "${have_cle}" ] && wantfeat HISTORY; then
1100 echo '#define HAVE_HISTORY' >> ${h}
1102 echo '/* WANT_HISTORY=0 */' >> ${h}
1105 if wantfeat SPAM; then
1106 echo '#define HAVE_SPAM' >> ${h}
1107 if command -v spamc >/dev/null 2>&1; then
1108 echo "#define SPAMC_PATH \"`command -v spamc`\"" >> ${h}
1111 echo '/* WANT_SPAM=0 */' >> ${h}
1114 if wantfeat DOCSTRINGS
; then
1115 echo '#define HAVE_DOCSTRINGS' >> ${h}
1117 echo '/* WANT_DOCSTRINGS=0 */' >> ${h}
1120 if wantfeat QUOTE_FOLD
&&\
1121 [ -n "${have_c90amend1}" ] && [ -n "${have_wcwidth}" ]; then
1122 echo '#define HAVE_QUOTE_FOLD' >> ${h}
1124 echo '/* WANT_QUOTE_FOLD=0 */' >> ${h}
1127 if wantfeat COLOUR
; then
1128 echo '#define HAVE_COLOUR' >> ${h}
1130 echo '/* WANT_COLOUR=0 */' >> ${h}
1133 if wantfeat IMAP_SEARCH
; then
1134 echo '#define HAVE_IMAP_SEARCH' >> ${h}
1136 echo '/* WANT_IMAP_SEARCH=0 */' >> ${h}
1139 if wantfeat MD5
; then
1140 echo '#define HAVE_MD5' >> ${h}
1142 echo '/* WANT_MD5=0 */' >> ${h}
1147 # Since we cat(1) the content of those to cc/"ld", convert them to single line
1149 < "${1}" > "${2}" ${awk} \
1150 'BEGIN {ORS = " "} /^[^#]/ {print} {next} END {ORS = ""; print "\n"}'
1153 squeeze_em ${inc} ${tmp}
1155 squeeze_em ${lib} ${tmp}
1160 printf '#ifndef _CONFIG_H\n# define _CONFIG_H\n' > ${h}
1161 ${cat} ${tmp} >> ${h}
1163 printf '\n/* The "feature string
", for "simplicity
" and lex.c */\n' >> ${h}
1164 printf '#ifdef _MAIN_SOURCE\n' >> ${h}
1165 printf '# ifdef HAVE_AMALGAMATION\nstatic\n# endif\n' >> ${h}
1166 printf 'char const features[] = "MIME
"\n' >> ${h}
1167 printf '# ifdef HAVE_DOCSTRINGS\n ",DOCSTRINGS
"\n# endif\n' >> ${h}
1168 printf '# ifdef HAVE_ICONV\n ",ICONV
"\n# endif\n' >> ${h}
1169 printf '# ifdef HAVE_SETLOCALE\n ",LOCALES
"\n# endif\n' >> ${h}
1170 printf '# ifdef HAVE_C90AMEND1\n ",MULTIBYTE CHARSETS
"\n# endif\n' >> ${h}
1171 printf '# ifdef HAVE_NL_LANGINFO\n ",TERMINAL CHARSET
"\n# endif\n' >> ${h}
1172 printf '# ifdef HAVE_SOCKETS\n ",NETWORK
"\n# endif\n' >> ${h}
1173 printf '# ifdef HAVE_IPV6\n ",IPv6
"\n# endif\n' >> ${h}
1174 printf '# ifdef HAVE_SSL\n ",S
/MIME
,SSL
/TLS
"\n# endif\n' >> ${h}
1175 printf '# ifdef HAVE_IMAP\n ",IMAP
"\n# endif\n' >> ${h}
1176 printf '# ifdef HAVE_GSSAPI\n ",GSSAPI
"\n# endif\n' >> ${h}
1177 printf '# ifdef HAVE_POP3\n ",POP3
"\n# endif\n' >> ${h}
1178 printf '# ifdef HAVE_SMTP\n ",SMTP
"\n# endif\n' >> ${h}
1179 printf '# ifdef HAVE_SPAM\n ",SPAM
"\n# endif\n' >> ${h}
1180 printf '# ifdef HAVE_IDNA\n ",IDNA
"\n# endif\n' >> ${h}
1181 printf '# ifdef HAVE_IMAP_SEARCH\n ",IMAP-searches
"\n# endif\n' >> ${h}
1182 printf '# ifdef HAVE_REGEX\n ",REGEX
"\n# endif\n' >> ${h}
1183 printf '# ifdef HAVE_READLINE\n ",READLINE
"\n# endif\n' >> ${h}
1184 printf '# ifdef HAVE_EDITLINE\n ",EDITLINE
"\n# endif\n' >> ${h}
1185 printf '# ifdef HAVE_NCL\n ",NCL
"\n# endif\n' >> ${h}
1186 printf '# ifdef HAVE_TABEXPAND\n ",TABEXPAND
"\n# endif\n' >> ${h}
1187 printf '# ifdef HAVE_HISTORY\n ",HISTORY MANAGEMENT
"\n# endif\n' >> ${h}
1188 printf '# ifdef HAVE_QUOTE_FOLD\n ",QUOTE-FOLD
"\n# endif\n' >> ${h}
1189 printf '# ifdef HAVE_COLOUR\n ",COLOUR
"\n# endif\n' >> ${h}
1190 printf '# ifdef HAVE_DEBUG\n ",DEBUG
"\n# endif\n' >> ${h}
1191 printf ';\n#endif /* _MAIN_SOURCE */\n' >> ${h}
1193 printf '#endif /* _CONFIG_H */\n' >> ${h}
1196 # Create the real mk.mk
1197 ${rm} -rf ${tmp0}.* ${tmp0}*
1198 printf 'OBJ_SRC = ' >> ${mk}
1199 if nwantfeat AMALGAMATION; then
1201 echo 'OBJ_DEP =' >> ${mk}
1203 j=`echo "${src}" | sed 's/^.\///'`
1204 echo "${j}" >> ${mk}
1205 printf 'OBJ_DEP = main.c ' >> ${mk}
1206 printf '#define _MAIN_SOURCE\n' >> ${src}
1207 printf '#include "nail.h
"\n#include "main.c
"\n' >> ${src}
1209 if [ "${i}" = "${j}" ] || [ "${i}" = main.c ]; then
1212 printf "${i} " >> ${mk}
1213 printf "#include \"${i}\"\n" >> ${src}
1218 echo "LIBS = `${cat} ${lib}`" >> ${mk}
1219 echo "INCLUDES
= `${cat} ${inc}`" >> ${mk}
1221 ${cat} ./mk-mk.in >> ${mk}
1225 ${cat} > ${tmp2}.c << \!
1227 #ifdef HAVE_NL_LANGINFO
1228 # include <langinfo.h>
1231 :The following optional features are enabled:
1233 : + Character set conversion using iconv()
1235 #ifdef HAVE_SETLOCALE
1236 : + Locale support: Printable characters depend on the environment
1237 # ifdef HAVE_C90AMEND1
1238 : + Multibyte character support
1240 # ifdef HAVE_NL_LANGINFO
1241 : + Automatic detection of terminal character set
1248 : + Support for Internet Protocol v6 (IPv6)
1251 # ifdef HAVE_OPENSSL
1252 : + S/MIME and SSL/TLS using OpenSSL
1259 : + IMAP GSSAPI authentication
1268 : + Interaction with spam filters
1271 : + IDNA (internationalized domain names for applications) support
1273 #ifdef HAVE_IMAP_SEARCH
1274 : + IMAP-style search expressions
1277 : + Regular expression searches
1279 #if defined HAVE_READLINE || defined HAVE_EDITLINE || defined HAVE_NCL
1280 : + Command line editing
1281 # ifdef HAVE_TABEXPAND
1282 : + + Tabulator expansion
1284 # ifdef HAVE_HISTORY
1285 : + + History management
1288 #ifdef HAVE_QUOTE_FOLD
1289 : + Extended *quote-fold*ing
1292 : + Coloured message display (simple)
1295 :The following optional features are disabled:
1297 : - Character set conversion using iconv()
1299 #ifndef HAVE_SETLOCALE
1300 : - Locale support: Only ASCII characters are recognized
1302 # ifndef HAVE_C90AMEND1
1303 : - Multibyte character support
1305 # ifndef HAVE_NL_LANGINFO
1306 : - Automatic detection of terminal character set
1308 #ifndef HAVE_SOCKETS
1312 : - Support for Internet Protocol v6 (IPv6)
1314 #if !defined HAVE_SSL
1315 : - SSL/TLS (network transport authentication and encryption)
1321 : - IMAP GSSAPI authentication
1330 : - Interaction with spam filters
1333 : - IDNA (internationalized domain names for applications) support
1335 #ifndef HAVE_IMAP_SEARCH
1336 : - IMAP-style search expressions
1339 : - Regular expression searches
1341 #if !defined HAVE_READLINE && !defined HAVE_EDITLINE && !defined HAVE_NCL
1342 : - Command line editing and history
1344 #ifndef HAVE_QUOTE_FOLD
1345 : - Extended *quote-fold*ing
1348 : - Coloured message display (simple)
1352 #ifndef HAVE_SNPRINTF
1353 : . The function snprintf() could not be found. mailx will be compiled to use
1354 : sprintf() instead. This might overflow buffers if input values are larger
1355 : than expected. Use the resulting binary with care or update your system
1356 : environment and start the configuration process again.
1359 : . The function fchdir() could not be found. mailx will be compiled to use
1360 : chdir() instead. This is not a problem unless the current working
1361 : directory of mailx is moved while the IMAP cache is used.
1364 : . Using a minimal builtin POSIX-like getopt()
1367 : . Debug enabled binary: not meant to be used by end-users: THANKS!
1372 ${make} -f ${makefile} ${tmp2}.x
1373 < ${tmp2}.x >&5 ${sed} -e '/^[^:]/d; /^$/d; s/^://'
1375 # vim:set fenc=utf-8:s-it-mode