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
23 WANT_READLINE
=0 WANT_EDITLINE
=0
32 WANT_READLINE
=0 WANT_EDITLINE
=0
39 echo >&2 "Unknown CONFIG= setting: ${CONFIG}"
40 echo >&2 'Possible values: MINIMAL, MEDIUM, NETSEND'
47 if nwantfeat SOCKETS
; then
48 WANT_IPV6
=0 WANT_SSL
=0
49 WANT_IMAP
=0 WANT_GSSAPI
=0 WANT_POP3
=0 WANT_SMTP
=0
51 if nwantfeat IMAP
&& nwantfeat POP3
&& nwantfeat SMTP
; then
52 WANT_SOCKETS
=0 WANT_IPV6
=0 WANT_SSL
=0
54 if nwantfeat IMAP
; then
57 # If we don't need MD5 except for producing boundary and message-id strings,
58 # leave it off, plain old srand(3) should be enough for that purpose.
59 if nwantfeat SOCKETS
; then
62 if wantfeat DEBUG
; then
67 # Check out compiler ($CC) and -flags ($CFLAGS)
72 # $CC is overwritten when empty or a default "cc", even without WANT_AUTOCC
74 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 [ "${i}" = 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
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 _CFLAGS
="${_CFLAGS} -Wno-long-long" # ISO C89 has no 'long long'...
122 # elif { i=$ccver; echo "${i}"; } | ${grep} -q -i -e clang; then
124 # optim=-O3 dbgoptim=-O
125 # _CFLAGS='-std=c89 -g -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 -ftrapv ${_CFLAGS}";
137 if [ "${stackprot}" = yes ]; then
138 _CFLAGS
="${_CFLAGS} -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 link_check hello 'if a hello world program can be built' << \! || {\
432 echo >&5 'This oooops is most certainly not related to me.';\
433 echo >&5 "Read the
file ${log} and check your compiler environment.
";\
434 ${rm} -f ${lst} ${h} ${mk};\
439 int main(int argc, char *argv[])
448 link_check termios 'for termios.h and tc*() family' << \! || {\
449 echo >&5 'We require termios.h and the tc*() family of functions.';\
450 echo >&5 "That much Unix we indulge ourselfs.
";\
451 ${rm} -f ${lst} ${h} ${mk};\
459 tcsetattr(0, TCSADRAIN | TCSAFLUSH, &tios);
464 link_check setenv 'for setenv()/unsetenv()' '#define HAVE_SETENV' << \!
468 setenv("s-nail
", "to be made nifty
!", 1);
474 link_check snprintf 'for snprintf()' '#define HAVE_SNPRINTF' << \!
479 snprintf(b, sizeof b, "%s
", "string
");
484 link_check putc_unlocked 'for putc_unlocked()' '#define HAVE_PUTC_UNLOCKED' <<\!
488 putc_unlocked('@', stdout);
493 link_check fchdir 'for fchdir()' '#define HAVE_FCHDIR' << \!
502 link_check mmap 'for mmap()' '#define HAVE_MMAP' << \!
503 #include <sys/types.h>
504 #include <sys/mman.h>
507 mmap(0, 0, 0, 0, 0, 0);
512 link_check mremap 'for mremap()' '#define HAVE_MREMAP' << \!
513 #include <sys/types.h>
514 #include <sys/mman.h>
517 mremap(0, 0, 0, MREMAP_MAYMOVE);
522 link_check setlocale 'for setlocale()' '#define HAVE_SETLOCALE' << \!
526 setlocale(LC_ALL, "");
531 if [ "${have_setlocale}" = yes ]; then
532 link_check c90amend1 'for ISO/IEC 9899:1990/Amendment 1:1995' \
533 '#define HAVE_C90AMEND1' << \!
540 char mbb[MB_LEN_MAX + 1];
545 mbrtowc(&wc, "x
", 1, NULL);
546 (void)wctomb(mbb, wc);
547 return (mblen("\
0", 1) == 0);
551 if [ "${have_c90amend1}" = yes ]; then
552 link_check wcwidth 'for wcwidth()' '#define HAVE_WCWIDTH' << \!
562 link_check nl_langinfo 'for nl_langinfo()' '#define HAVE_NL_LANGINFO' << \!
563 #include <langinfo.h>
568 return (nl_langinfo(CODESET) == NULL);
573 link_check mkstemp 'for mkstemp()' '#define HAVE_MKSTEMP' << \!
582 # Note: run_check, thus we also get only the desired implementation...
583 run_check realpath 'for realpath()' '#define HAVE_REALPATH' << \!
587 char *x = realpath(".
", NULL), *y = realpath("/", NULL);
588 return (x != NULL && y != NULL) ? 0 : 1;
592 link_check wordexp 'for wordexp()' '#define HAVE_WORDEXP' << \!
596 wordexp((char *)0, (wordexp_t *)0, 0);
603 if wantfeat DEBUG; then
604 echo '#define HAVE_DEBUG' >> ${h}
607 if wantfeat AMALGAMATION; then
608 echo '#define HAVE_AMALGAMATION' >> ${h}
611 if nwantfeat NOALLOCA; then
612 # Due to NetBSD PR lib/47120 it seems best not to use non-cc-builtin
613 # versions of alloca(3) since modern compilers just can't be trusted
614 # not to overoptimize and silently break some code
615 link_check alloca 'for __builtin_alloca()' \
616 '#define HAVE_ALLOCA __builtin_alloca' << \!
619 void *vp = __builtin_alloca(1);
625 if nwantfeat NOGETOPT; then
626 link_check getopt 'for getopt()' '#define HAVE_GETOPT' << \!
628 int main(int argc, char **argv)
630 #if defined __GLIBC__ || defined __linux__
631 Argument and option reordering is not a desired feature.
633 getopt(argc, argv, "oPt
");
635 return (((long)optarg + optind) & 0x7F);
642 if wantfeat ICONV; then
643 ${cat} > ${tmp2}.c << \!
649 id = iconv_open("foo
", "bar
");
653 < ${tmp2}.c link_check iconv 'for iconv functionality' \
654 '#define HAVE_ICONV' ||
655 < ${tmp2}.c link_check iconv \
656 'for iconv functionality in libiconv' \
657 '#define HAVE_ICONV' '-liconv'
659 echo '/* WANT_ICONV=0 */' >> ${h}
662 if wantfeat SOCKETS; then
663 compile_check arpa_inet_h 'for <arpa/inet.h>' \
664 '#define HAVE_ARPA_INET_H' << \!
666 #include <sys/types.h>
667 #include <sys/socket.h>
669 #include <netinet/in.h>
670 #include <arpa/inet.h>
673 ${cat} > ${tmp2}.c << \!
675 #include <sys/types.h>
676 #include <sys/socket.h>
678 #include <netinet/in.h>
679 #ifdef HAVE_ARPA_INET_H
680 #include <arpa/inet.h>
686 socket(AF_INET, SOCK_STREAM, 0);
688 gethostbyname("foo
");
693 < ${tmp2}.c link_check sockets 'for sockets in libc' \
694 '#define HAVE_SOCKETS' ||
695 < ${tmp2}.c link_check sockets 'for sockets in libnsl' \
696 '#define HAVE_SOCKETS' '-lnsl' ||
697 < ${tmp2}.c link_check sockets \
698 'for sockets in libsocket and libnsl' \
699 '#define HAVE_SOCKETS' '-lsocket -lnsl' ||
702 # XXX Shouldn't it be a hard error if there is no socket support, then?
705 echo '/* WANT_SOCKETS=0 */' >> ${h}
706 fi # wantfeat SOCKETS
709 link_check setsockopt 'for setsockopt()' '#define HAVE_SETSOCKOPT' << \!
710 #include <sys/socket.h>
715 setsockopt(sockfd, SOL_SOCKET, SO_KEEPALIVE, NULL, 0);
720 wantfeat SOCKETS && [ -n "${have_setsockopt}" ] &&
721 link_check so_sndtimeo 'for SO_SNDTIMEO' '#define HAVE_SO_SNDTIMEO' << \!
722 #include <sys/socket.h>
730 setsockopt(sockfd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof tv);
731 setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof tv);
736 wantfeat SOCKETS && [ -n "${have_setsockopt}" ] &&
737 link_check so_linger 'for SO_LINGER' '#define HAVE_SO_LINGER' << \!
738 #include <sys/socket.h>
746 setsockopt(sockfd, SOL_SOCKET, SO_LINGER, &li, sizeof li);
751 if wantfeat IPV6; then
752 link_check ipv6 'for IPv6 functionality' '#define HAVE_IPV6' << \!
754 #include <sys/types.h>
755 #include <sys/socket.h>
757 #include <netinet/in.h>
758 #ifdef HAVE_ARPA_INET_H
759 #include <arpa/inet.h>
764 struct addrinfo a, *ap;
765 getaddrinfo("foo
", "0", &a, &ap);
770 echo '/* WANT_IPV6=0 */' >> ${h}
773 if wantfeat IMAP; then
774 echo '#define HAVE_IMAP' >> ${h}
776 echo '/* WANT_IMAP=0 */' >> ${h}
779 if wantfeat POP3; then
780 echo '#define HAVE_POP3' >> ${h}
782 echo '/* WANT_POP3=0 */' >> ${h}
785 if wantfeat SMTP; then
786 echo '#define HAVE_SMTP' >> ${h}
788 echo '/* WANT_SMTP=0 */' >> ${h}
791 if wantfeat SSL; then
792 link_check openssl 'for sufficiently recent OpenSSL' \
794 #define HAVE_OPENSSL' '-lssl -lcrypto' << \!
795 #include <openssl/ssl.h>
796 #include <openssl/err.h>
797 #include <openssl/x509v3.h>
798 #include <openssl/x509.h>
799 #include <openssl/rand.h>
801 #if defined OPENSSL_NO_SSL2 && defined OPENSSL_NO_SSL3 &&\
802 defined OPENSSL_NO_TLS1
803 # error We need one of (SSLv2 and) SSLv3 and TLS1.
808 SSLv23_client_method();
809 #ifndef OPENSSL_NO_SSL3
810 SSLv3_client_method();
812 #ifndef OPENSSL_NO_TLS1
813 TLSv1_client_method();
814 # ifdef TLS1_1_VERSION
815 TLSv1_1_client_method();
817 # ifdef TLS1_2_VERSION
818 TLSv1_2_client_method();
821 PEM_read_PrivateKey(0, 0, 0, 0);
826 if [ "${have_openssl}" = 'yes' ]; then
827 compile_check stack_of 'for OpenSSL STACK_OF()' \
828 '#define HAVE_STACK_OF' << \!
829 #include <openssl/ssl.h>
830 #include <openssl/err.h>
831 #include <openssl/x509v3.h>
832 #include <openssl/x509.h>
833 #include <openssl/rand.h>
837 STACK_OF(GENERAL_NAME) *gens = NULL;
838 printf("%p
", gens); /* to make it used */
843 if wantfeat MD5; then
844 run_check openssl_md5 'for MD5 digest in OpenSSL' \
845 '#define HAVE_OPENSSL_MD5' << \!
847 #include <openssl/md5.h>
851 char const dat[] = "abrakadabrafidibus
";
852 char dig[16], hex[16 * 2];
856 memset(dig, 0, sizeof(dig));
857 memset(hex, 0, sizeof(hex));
859 MD5_Update(&ctx, dat, sizeof(dat) - 1);
860 MD5_Final(dig, &ctx);
862 #define hexchar(n) ((n) > 9 ? (n) - 10 + 'a' : (n) + '0')
863 for (i = 0; i < sizeof(hex) / 2; i++) {
865 hex[j] = hexchar((dig[i] & 0xf0) >> 4);
866 hex[++j] = hexchar(dig[i] & 0x0f);
868 return !!memcmp("6d7d0a3d949da2e96f2aa010f65d8326
", hex, sizeof(hex));
874 echo '/* WANT_SSL=0 */' >> ${h}
877 if wantfeat GSSAPI; then
878 ${cat} > ${tmp2}.c << \!
879 #include <gssapi/gssapi.h>
883 gss_import_name(0, 0, GSS_C_NT_HOSTBASED_SERVICE, 0);
884 gss_init_sec_context(0,0,0,0,0,0,0,0,0,0,0,0,0);
888 ${sed} -e '1s/gssapi\///' < ${tmp2}.c > ${tmp3}.c
890 if command -v krb5-config >/dev/null 2>&1; then
891 i=`command -v krb5-config`
892 GSSAPI_LIBS="`CFLAGS= ${i} --libs gssapi`"
893 GSSAPI_INCS="`CFLAGS= ${i} --cflags`"
894 i='for GSSAPI via krb5-config(1)'
896 GSSAPI_LIBS='-lgssapi'
898 i='for GSSAPI in gssapi/gssapi.h, libgssapi'
900 < ${tmp2}.c link_check gssapi \
901 "${i}" '#define HAVE_GSSAPI' \
902 "${GSSAPI_LIBS}" "${GSSAPI_INCS}" ||\
903 < ${tmp3}.c link_check gssapi \
904 'for GSSAPI in gssapi.h, libgssapi' \
906 #define GSSAPI_REG_INCLUDE' \
908 < ${tmp2}.c link_check gssapi 'for GSSAPI in libgssapi_krb5' \
909 '#define HAVE_GSSAPI' \
911 < ${tmp3}.c link_check gssapi \
912 'for GSSAPI in libgssapi, OpenBSD-style (pre 5.3)' \
914 #define GSSAPI_REG_INCLUDE' \
915 '-lgssapi -lkrb5 -lcrypto' \
916 '-I/usr/include/kerberosV' ||\
917 < ${tmp2}.c link_check gssapi 'for GSSAPI in libgss' \
918 '#define HAVE_GSSAPI' \
920 link_check gssapi 'for GSSAPI in libgssapi_krb5, old-style' \
922 #define GSSAPI_OLD_STYLE' \
923 '-lgssapi_krb5' << \!
924 #include <gssapi/gssapi.h>
925 #include <gssapi/gssapi_generic.h>
929 gss_import_name(0, 0, gss_nt_service_name, 0);
930 gss_init_sec_context(0,0,0,0,0,0,0,0,0,0,0,0,0);
935 echo '/* WANT_GSSAPI=0 */' >> ${h}
938 if wantfeat IDNA; then
939 link_check idna 'for GNU Libidn' '#define HAVE_IDNA' '-lidn' << \!
941 #include <idn-free.h>
942 #include <stringprep.h>
945 char *utf8, *idna_ascii, *idna_utf8;
946 utf8 = stringprep_locale_to_utf8("does.this.work
");
947 if (idna_to_ascii_8z(utf8, &idna_ascii, IDNA_USE_STD3_ASCII_RULES)
950 idn_free(idna_ascii);
951 /* (Rather link check only here) */
952 idna_utf8 = stringprep_convert(idna_ascii, "UTF-8
", "de_DE
");
957 echo '/* WANT_IDNA=0 */' >> ${h}
960 if wantfeat REGEX; then
961 link_check regex 'for regular expressions' '#define HAVE_REGEX' << \!
968 if (regcomp(&re, ".
*bsd
", REG_EXTENDED | REG_ICASE | REG_NOSUB) != 0)
970 status = regexec(&re, "plan9
", 0,NULL, 0);
972 return !(status == REG_NOMATCH);
976 echo '/* WANT_REGEX=0 */' >> ${h}
979 if wantfeat READLINE; then
981 link_check readline "for readline
(3) (${1})" \
982 '#define HAVE_READLINE' "${1}" << \!
984 #include <readline/history.h>
985 #include <readline/readline.h>
995 rl = readline("Enter a line
:");
999 rl_extend_line_buffer(10);
1000 rl_point = rl_end = 10;
1001 rl_pre_input_hook = (rl_hook_func_t*)NULL;
1002 rl_forced_update_display();
1004 hs = history_get_history_state();
1006 he = history_list();
1009 rl_free_line_state();
1010 rl_cleanup_after_signal();
1011 rl_reset_after_signal();
1017 __edrdlib -lreadline ||
1018 __edrdlib '-lreadline -ltermcap'
1019 [ -n "${have_readline}" ] && WANT_TABEXPAND=1
1022 if wantfeat EDITLINE && [ -z "${have_readline}" ]; then
1024 link_check editline "for editline
(3) (${1})" \
1025 '#define HAVE_EDITLINE' "${1}" << \!
1026 #include <histedit.h>
1027 static char * getprompt(void) { return (char*)"ok
"; }
1030 EditLine *el_el = el_init("TEST
", stdin, stdout, stderr);
1032 History *el_hcom = history_init();
1033 history(el_hcom, &he, H_SETSIZE, 242);
1034 el_set(el_el, EL_SIGNAL, 0);
1035 el_set(el_el, EL_TERMINAL, NULL);
1036 el_set(el_el, EL_HIST, &history, el_hcom);
1037 el_set(el_el, EL_EDITOR, "emacs
");
1038 el_set(el_el, EL_PROMPT, &getprompt);
1039 el_source(el_el, NULL);
1040 history(el_hcom, &he, H_GETSIZE);
1041 history(el_hcom, &he, H_CLEAR);
1043 /* TODO add loader and addfn checks */
1044 history_end(el_hcom);
1051 __edlib '-ledit -ltermcap'
1052 [ -n "${have_editline}" ] && WANT_TABEXPAND=0
1055 if wantfeat NCL && [ -z "${have_editline}" ] && [ -z "${have_readline}" ] &&\
1056 [ -n "${have_c90amend1}" ]; then
1058 echo '#define HAVE_NCL' >> ${h}
1060 echo '/* WANT_{READLINE,EDITLINE,NCL}=0 */' >> ${h}
1063 # Generic have-a-command-line-editor switch for those who need it below
1064 if [ -n "${have_ncl}" ] || [ -n "${have_editline}" ] ||\
1065 [ -n "${have_readline}" ]; then
1069 if [ -n "${have_cle}" ] && wantfeat TABEXPAND; then
1070 echo '#define HAVE_TABEXPAND' >> ${h}
1072 echo '/* WANT_TABEXPAND=0 */' >> ${h}
1075 if [ -n "${have_cle}" ] && wantfeat HISTORY; then
1076 echo '#define HAVE_HISTORY' >> ${h}
1078 echo '/* WANT_HISTORY=0 */' >> ${h}
1081 if wantfeat SPAM; then
1082 echo '#define HAVE_SPAM' >> ${h}
1083 if command -v spamc >/dev/null 2>&1; then
1084 echo "#define SPAMC_PATH \"`command -v spamc`\"" >> ${h}
1087 echo '/* WANT_SPAM=0 */' >> ${h}
1090 if wantfeat DOCSTRINGS
; then
1091 echo '#define HAVE_DOCSTRINGS' >> ${h}
1093 echo '/* WANT_DOCSTRINGS=0 */' >> ${h}
1096 if wantfeat QUOTE_FOLD
&&\
1097 [ -n "${have_c90amend1}" ] && [ -n "${have_wcwidth}" ]; then
1098 echo '#define HAVE_QUOTE_FOLD' >> ${h}
1100 echo '/* WANT_QUOTE_FOLD=0 */' >> ${h}
1103 if wantfeat COLOUR
; then
1104 echo '#define HAVE_COLOUR' >> ${h}
1106 echo '/* WANT_COLOUR=0 */' >> ${h}
1109 if wantfeat MD5
; then
1110 echo '#define HAVE_MD5' >> ${h}
1112 echo '/* WANT_MD5=0 */' >> ${h}
1117 # Since we cat(1) the content of those to cc/"ld", convert them to single line
1119 < "${1}" > "${2}" ${awk} \
1120 'BEGIN {ORS = " "} /^[^#]/ {print} {next} END {ORS = ""; print "\n"}'
1123 squeeze_em ${inc} ${tmp}
1125 squeeze_em ${lib} ${tmp}
1130 printf '#ifndef _CONFIG_H\n# define _CONFIG_H\n' > ${h}
1131 ${cat} ${tmp} >> ${h}
1133 printf '\n/* The "feature string
", for "simplicity
" and lex.c */\n' >> ${h}
1134 printf '#ifdef _MAIN_SOURCE\n' >> ${h}
1135 printf '# ifdef HAVE_AMALGAMATION\nstatic\n# endif\n' >> ${h}
1136 printf 'char const features[] = "MIME
"\n' >> ${h}
1137 printf '# ifdef HAVE_DOCSTRINGS\n ",DOCSTRINGS
"\n# endif\n' >> ${h}
1138 printf '# ifdef HAVE_ICONV\n ",ICONV
"\n# endif\n' >> ${h}
1139 printf '# ifdef HAVE_SETLOCALE\n ",LOCALES
"\n# endif\n' >> ${h}
1140 printf '# ifdef HAVE_C90AMEND1\n ",MULTIBYTE CHARSETS
"\n# endif\n' >> ${h}
1141 printf '# ifdef HAVE_NL_LANGINFO\n ",TERMINAL CHARSET
"\n# endif\n' >> ${h}
1142 printf '# ifdef HAVE_SOCKETS\n ",NETWORK
"\n# endif\n' >> ${h}
1143 printf '# ifdef HAVE_IPV6\n ",IPv6
"\n# endif\n' >> ${h}
1144 printf '# ifdef HAVE_SSL\n ",S
/MIME
,SSL
/TSL
"\n# endif\n' >> ${h}
1145 printf '# ifdef HAVE_IMAP\n ",IMAP
"\n# endif\n' >> ${h}
1146 printf '# ifdef HAVE_GSSAPI\n ",GSSAPI
"\n# endif\n' >> ${h}
1147 printf '# ifdef HAVE_POP3\n ",POP3
"\n# endif\n' >> ${h}
1148 printf '# ifdef HAVE_SMTP\n ",SMTP
"\n# endif\n' >> ${h}
1149 printf '# ifdef HAVE_SPAM\n ",SPAM
"\n# endif\n' >> ${h}
1150 printf '# ifdef HAVE_IDNA\n ",IDNA
"\n# endif\n' >> ${h}
1151 printf '# ifdef HAVE_REGEX\n ",REGEX
"\n# endif\n' >> ${h}
1152 printf '# ifdef HAVE_READLINE\n ",READLINE
"\n# endif\n' >> ${h}
1153 printf '# ifdef HAVE_EDITLINE\n ",EDITLINE
"\n# endif\n' >> ${h}
1154 printf '# ifdef HAVE_NCL\n ",NCL
"\n# endif\n' >> ${h}
1155 printf '# ifdef HAVE_TABEXPAND\n ",TABEXPAND
"\n# endif\n' >> ${h}
1156 printf '# ifdef HAVE_HISTORY\n ",HISTORY MANAGEMENT
"\n# endif\n' >> ${h}
1157 printf '# ifdef HAVE_QUOTE_FOLD\n ",QUOTE-FOLD
"\n# endif\n' >> ${h}
1158 printf '# ifdef HAVE_COLOUR\n ",COLOUR
"\n# endif\n' >> ${h}
1159 printf '# ifdef HAVE_DEBUG\n ",DEBUG
"\n# endif\n' >> ${h}
1160 printf ';\n#endif /* _MAIN_SOURCE */\n' >> ${h}
1162 printf '#endif /* _CONFIG_H */\n' >> ${h}
1165 # Create the real mk.mk
1166 ${rm} -rf ${tmp0}.* ${tmp0}*
1167 printf 'OBJ_SRC = ' >> ${mk}
1168 if nwantfeat AMALGAMATION; then
1170 echo 'OBJ_DEP =' >> ${mk}
1172 j=`echo "${src}" | sed 's/^.\///'`
1173 echo "${j}" >> ${mk}
1174 printf 'OBJ_DEP = main.c ' >> ${mk}
1175 printf '#define _MAIN_SOURCE\n' >> ${src}
1176 printf '#include "nail.h
"\n#include "main.c
"\n' >> ${src}
1178 if [ "${i}" = "${j}" ] || [ "${i}" = main.c ]; then
1181 printf "${i} " >> ${mk}
1182 printf "#include \"${i}\"\n" >> ${src}
1187 echo "LIBS = `${cat} ${lib}`" >> ${mk}
1188 echo "INCLUDES
= `${cat} ${inc}`" >> ${mk}
1190 ${cat} ./mk-mk.in >> ${mk}
1194 ${cat} > ${tmp2}.c << \!
1196 #ifdef HAVE_NL_LANGINFO
1197 # include <langinfo.h>
1200 :The following optional features are enabled:
1202 : + Character set conversion using iconv()
1204 #ifdef HAVE_SETLOCALE
1205 : + Locale support: Printable characters depend on the environment
1206 # ifdef HAVE_C90AMEND1
1207 : + Multibyte character support
1209 # ifdef HAVE_NL_LANGINFO
1210 : + Automatic detection of terminal character set
1217 : + Support for Internet Protocol v6 (IPv6)
1220 # ifdef HAVE_OPENSSL
1221 : + S/MIME and SSL/TLS using OpenSSL
1228 : + IMAP GSSAPI authentication
1237 : + Interaction with spam filters
1240 : + IDNA (internationalized domain names for applications) support
1243 : + Regular expression searches
1245 #if defined HAVE_READLINE || defined HAVE_EDITLINE || defined HAVE_NCL
1246 : + Command line editing
1247 # ifdef HAVE_TABEXPAND
1248 : + + Tabulator expansion
1250 # ifdef HAVE_HISTORY
1251 : + + History management
1254 #ifdef HAVE_QUOTE_FOLD
1255 : + Extended *quote-fold*ing
1258 : + Coloured message display (simple)
1261 :The following optional features are disabled:
1263 : - Character set conversion using iconv()
1265 #ifndef HAVE_SETLOCALE
1266 : - Locale support: Only ASCII characters are recognized
1268 # ifndef HAVE_C90AMEND1
1269 : - Multibyte character support
1271 # ifndef HAVE_NL_LANGINFO
1272 : - Automatic detection of terminal character set
1274 #ifndef HAVE_SOCKETS
1278 : - Support for Internet Protocol v6 (IPv6)
1280 #if !defined HAVE_SSL
1281 : - SSL/TLS (network transport authentication and encryption)
1287 : - IMAP GSSAPI authentication
1296 : - Interaction with spam filters
1299 : - IDNA (internationalized domain names for applications) support
1302 : - Regular expression searches
1304 #if !defined HAVE_READLINE && !defined HAVE_EDITLINE && !defined HAVE_NCL
1305 : - Command line editing and history
1307 #ifndef HAVE_QUOTE_FOLD
1308 : - Extended *quote-fold*ing
1311 : - Coloured message display (simple)
1315 #ifndef HAVE_SNPRINTF
1316 : . The function snprintf() could not be found. mailx will be compiled to use
1317 : sprintf() instead. This might overflow buffers if input values are larger
1318 : than expected. Use the resulting binary with care or update your system
1319 : environment and start the configuration process again.
1322 : . The function fchdir() could not be found. mailx will be compiled to use
1323 : chdir() instead. This is not a problem unless the current working
1324 : directory of mailx is moved while the IMAP cache is used.
1327 : . Using a minimal builtin POSIX-like getopt()
1330 : . Debug enabled binary: not meant to be used by end-users: THANKS!
1335 ${make} -f ${makefile} ${tmp2}.x
1336 < ${tmp2}.x >&5 ${sed} -e '/^[^:]/d; /^$/d; s/^://'
1338 # vim:set fenc=utf-8:s-it-mode