2 #@ Please see `INSTALL' and `make.rc' instead.
7 # Predefined CONFIG= urations take precedence over anything else
8 if [ -n "${CONFIG}" ]; then
16 WANT_READLINE
=0 WANT_EDITLINE
=0 WANT_NCL
=0
28 WANT_READLINE
=0 WANT_EDITLINE
=0 WANT_NCL
=1
29 WANT_HISTORY
=1 WANT_TABEXPAND
=0
38 WANT_IPV6
=1 WANT_SSL
=1 WANT_SMTP
=require WANT_POP3
=0 WANT_IMAP
=0
39 WANT_GSSAPI
=1 WANT_NETRC
=1 WANT_AGENT
=1
43 WANT_READLINE
=0 WANT_EDITLINE
=0 WANT_NCL
=1
44 WANT_HISTORY
=1 WANT_TABEXPAND
=0
53 WANT_IPV6
=1 WANT_SSL
=1 WANT_SMTP
=1 WANT_POP3
=1 WANT_IMAP
=1
54 WANT_GSSAPI
=1 WANT_NETRC
=1 WANT_AGENT
=1
58 WANT_READLINE
=0 WANT_EDITLINE
=0 WANT_NCL
=1
59 WANT_HISTORY
=1 WANT_TABEXPAND
=1
66 echo >&2 "Unknown CONFIG= setting: ${CONFIG}"
67 echo >&2 'Possible values: MINIMAL, MEDIUM, NETSEND, MAXIMAL'
74 if feat_no SOCKETS
; then
75 if feat_require SMTP
; then
76 msg
"ERROR: need SOCKETS for required feature SMTP\\n"
79 if feat_require POP3
; then
80 msg
"ERROR: need SOCKETS for required feature POP3\\n"
83 if feat_require IMAP
; then
84 msg
"ERROR: need SOCKETS for required feature IMAP\\n"
87 WANT_IPV6
=0 WANT_SSL
=0
88 WANT_SMTP
=0 WANT_POP3
=0 WANT_IMAP
=0 WANT_GSSAPI
=0
89 WANT_NETRC
=0 WANT_AGENT
=0
91 if feat_no SMTP
&& feat_no POP3
&& feat_no IMAP
; then
92 WANT_SOCKETS
=0 WANT_IPV6
=0 WANT_SSL
=0 WANT_NETRC
=0 WANT_AGENT
=0
94 if feat_no SMTP
&& feat_no IMAP
; then
97 if feat_no READLINE
&& feat_no EDITLINE
&& feat_no NCL
; then
98 WANT_HISTORY
=0 WANT_TABEXPAND
=0
100 # If we don't need MD5 except for producing boundary and message-id strings,
101 # leave it off, plain old srand(3) should be enough for that purpose.
102 if feat_no SOCKETS
; then
105 if feat_yes DEBUG
; then
106 WANT_NOALLOCA
=1 WANT_DEVEL
=1
110 # Check out compiler ($CC) and -flags ($CFLAGS)
112 # $CC is overwritten when empty or a default "cc", even without WANT_AUTOCC
113 optim
= dbgoptim
= _CFLAGS
=
114 if [ -z "${CC}" ] ||
[ "${CC}" = cc
]; then
115 if { CC
="`command -v clang`"; }; then
117 elif { CC
="`command -v gcc`"; }; then
119 elif { CC
="`command -v c89`"; }; then
120 [ "`uname -s`" = UnixWare
] && _CFLAGS
=-v optim
=-O dbgoptim
=
121 elif { CC
="`command -v c99`"; }; then
125 msg
' I cannot find a compiler!'
126 msg
' Neither of clang(1), gcc(1), c89(1) and c99(1).'
127 msg
' Please set the CC environment variable, maybe CFLAGS also.'
133 ccver
=`${CC} --version 2>/dev/null`
135 if { i
=${ccver}; echo "${i}"; } |
${grep} -q -i -e gcc
-e clang
; then
136 #if echo "${i}" | ${grep} -q -i -e gcc -e 'clang version 1'; then
137 optim
=-O2 dbgoptim
=-O
139 _CFLAGS
="${_CFLAGS} -std=c89 -Wall -Wextra -pedantic"
140 _CFLAGS
="${_CFLAGS} -fno-unwind-tables -fno-asynchronous-unwind-tables"
141 _CFLAGS
="${_CFLAGS} -fstrict-aliasing"
142 _CFLAGS
="${_CFLAGS} -Wbad-function-cast -Wcast-align -Wcast-qual"
143 _CFLAGS
="${_CFLAGS} -Winit-self -Wmissing-prototypes"
144 _CFLAGS
="${_CFLAGS} -Wshadow -Wunused -Wwrite-strings"
145 _CFLAGS
="${_CFLAGS} -Wno-long-long" # ISO C89 has no 'long long'...
146 if { i
=${ccver}; echo "${i}"; } |
${grep} -q -e 'clang version 1'; then
147 _CFLAGS
="${_CFLAGS} -Wstrict-overflow=5"
149 _CFLAGS
="${_CFLAGS} -fstrict-overflow -Wstrict-overflow=5"
150 if feat_yes AMALGAMATION
&& feat_no DEBUG
; then
151 _CFLAGS
="${_CFLAGS} -Wno-unused-function"
153 if { i
=${ccver}; echo "${i}"; } |
${grep} -q -i -e clang
; then
154 _CFLAGS
="${_CFLAGS} -Wno-unused-result" # TODO handle the right way
157 if feat_yes AMALGAMATION
; then
158 _CFLAGS
="${_CFLAGS} -pipe"
160 # elif { i=${ccver}; echo "${i}"; } | ${grep} -q -i -e clang; then
161 # optim=-O3 dbgoptim=-O
163 # _CFLAGS='-std=c89 -Weverything -Wno-long-long'
164 # if feat_yes AMALGAMATION; then
165 # _CFLAGS="${_CFLAGS} -pipe"
167 elif [ -z "${optim}" ]; then
168 optim
=-O1 dbgoptim
=-O
171 if feat_no DEBUG
; then
172 _CFLAGS
="${optim} -DNDEBUG ${_CFLAGS}"
174 _CFLAGS
="${dbgoptim} -g ${_CFLAGS}";
175 if [ "${stackprot}" = yes ]; then
176 _CFLAGS
="${_CFLAGS} -ftrapv -fstack-protector-all "
177 _CFLAGS
="${_CFLAGS} -Wstack-protector -D_FORTIFY_SOURCE=2"
180 _CFLAGS
="${_CFLAGS} ${ADDCFLAGS}"
181 # XXX -Wl,-z,relro -Wl,-z,now -Wl,-z,noexecstack: need detection
182 _LDFLAGS
="${_LDFLAGS} ${ADDLDFLAGS}" # XXX -Wl,--sort-common,[-O1]
183 export _CFLAGS _LDFLAGS
185 # $CFLAGS and $LDFLAGS are only overwritten if explicitly wanted
186 if feat_yes AUTOCC
; then
189 export CFLAGS LDFLAGS
196 ## - Heirloom sh(1) (and same origin) have _sometimes_ problems with ': >'
197 ## redirection, so use "printf '' >" instead
199 ## Very first: we undergo several states regarding I/O redirection etc.,
200 ## but need to deal with option updates from within all. Since all the
201 ## option stuff should be above the scissor line, define utility functions
202 ## and redefine them as necessary.
203 ## And, since we have those functions, simply use them for whatever
212 printf >&2 "${fmt}\\n" "${@}"
215 ## First of all, create new configuration and check wether it changed ##
222 newlst
=.
/config.lst-new
223 newmk
=.
/config.mk-new
228 # We need some standard utilities
231 n
=${1} i=${2} opt=${3:-0}
232 # Evaluate, just in case user comes in with shell snippets (..well..)
234 if type "${i}" >/dev
/null
2>&1; then
238 if [ ${opt} -eq 0 ]; then
239 msg
"ERROR: no trace of the utility \`${n}'\\n"
245 # Check those tools right now that we need before including $rc
246 check_tool
rm "${rm:-`command -v rm`}"
247 check_tool
sed "${sed:-`command -v sed`}"
249 # Include $rc, but only take from it what wasn't overwritten by the user from
250 # within the command line or from a chosen fixed CONFIG=
251 # Note we leave alone the values
252 trap "${rm} -f ${tmp}; exit" 1 2 15
253 trap "${rm} -f ${tmp}" 0
256 < ${rc} ${sed} -e '/^[ \t]*#/d' -e '/^$/d' -e 's/[ \t]*$//' |
258 i
="`echo ${line} | ${sed} -e 's/=.*$//'`"
259 eval j
="\$${i}" jx="\${${i}+x}"
260 if [ -n "${j}" ] ||
[ "${jx}" = x
]; then
263 j
="`echo ${line} | ${sed} -e 's/^[^=]*=//' -e 's/^\"*//' -e 's/\"*$//'`"
267 # Reread the mixed version right now
270 check_tool
awk "${awk:-`command -v awk`}"
271 check_tool
cat "${cat:-`command -v cat`}"
272 check_tool
chmod "${chmod:-`command -v chmod`}"
273 check_tool
cp "${cp:-`command -v cp`}"
274 check_tool
cmp "${cmp:-`command -v cmp`}"
275 check_tool
grep "${grep:-`command -v grep`}"
276 check_tool mkdir
"${mkdir:-`command -v mkdir`}"
277 check_tool
mv "${mv:-`command -v mv`}"
278 # rm(1), sed(1) above
279 check_tool
tee "${tee:-`command -v tee`}"
281 check_tool
make "${MAKE:-`command -v make`}"
282 check_tool strip
"${STRIP:-`command -v strip`}" 1
285 # Update WANT_ options now, in order to get possible inter-dependencies right
288 [ "x${1}" = x0 ] || [ "x${1}" = xfalse ] || [ "x${1}" = xno
]
292 [ "x${1}" = x1 ] || [ "x${1}" = xtrue ] || [ "x${1}" = xyes
] ||
293 [ "x${1}" = xrequire
]
297 [ "x${1}" = xrequire
]
302 i
="`echo ${i} | tr '[A-Z]' '[a-z]'`"
303 if feat_val_no
"${i}"; then
305 elif feat_val_yes
"${i}"; then
308 msg
"ERROR: ${1}: allowed: 0/false/no or 1/true/yes/require, got: ${i}\\n"
318 _feat_check
${1} && return 1
324 i
="`echo ${i} | tr '[A-Z]' '[a-z]'`"
325 [ "x${i}" = xrequire
]
330 # (No functions since some shells loose non-exported variables in traps)
331 trap "${rm} -f ${tmp} ${newlst} ${newmk} ${newh}; exit" 1 2 15
332 trap "${rm} -f ${tmp} ${newlst} ${newmk} ${newh}" 0
334 # Our configuration options may at this point still contain shell snippets,
335 # we need to evaluate them in order to get them expanded, and we need those
336 # evaluated values not only in our new configuration file, but also at hand..
337 ${rm} -f ${newlst} ${newmk} ${newh}
338 exec 5<&0 6>&1 <${tmp} >${newlst}
340 i
=`echo ${line} | ${sed} -e 's/=.*$//'`
342 if echo "${i}" |
grep -e '^WANT_' >/dev
/null
2>&1; then
343 if [ -z "${j}" ] || feat_val_no
"${j}"; then
345 printf "/*#define ${i}*/\n" >> ${newh}
346 elif feat_val_yes
"${j}"; then
347 if feat_val_require
"${j}"; then
352 printf "#define ${i}\n" >> ${newh}
354 msg
"ERROR: internal error -42\\n"
358 printf "#define ${i} \"${j}\"\n" >> ${newh}
360 printf "${i} = ${j}\n" >> ${newmk}
364 exec 0<&5 1<&6 5<&- 6<&-
366 printf "#define UAGENT \"${SID}${NAIL}\"\n" >> ${newh}
367 printf "UAGENT
= ${SID}${NAIL}\n" >> ${newmk}
371 printf "CC = ${CC}\n" >> ${newmk}
372 printf "CC=${CC}\n" >> ${newlst}
374 printf "_CFLAGS = ${_CFLAGS}\nCFLAGS = ${CFLAGS}\n" >> ${newmk}
375 printf "_CFLAGS
=${_CFLAGS}\nCFLAGS=${CFLAGS}\n" >> ${newlst}
377 printf "_LDFLAGS = ${_LDFLAGS}\nLDFLAGS = ${LDFLAGS}\n" >> ${newmk}
378 printf "_LDFLAGS
=${_LDFLAGS}\nLDFLAGS=${LDFLAGS}\n" >> ${newlst}
380 printf "AWK = ${awk}\nCMP = ${cmp}\nCHMOD = ${chmod}\nCP = ${cp}\n" >> ${newmk}
381 printf "AWK
=${awk}\nCMP=${cmp}\nCHMOD=${chmod}\nCP=${cp}\n" >> ${newlst}
383 printf "GREP = ${grep}\nMKDIR = ${mkdir}\nRM = ${rm}\nSED = ${sed}\n" \
385 printf "GREP=${grep}\nMKDIR=${mkdir}\nRM=${rm}\nSED=${sed}\n" >> ${newlst}
387 printf "STRIP
= ${strip}\nHAVE_STRIP = ${HAVE_STRIP}\n" >> ${newmk}
388 printf "STRIP=${strip}\nHAVE_STRIP=${HAVE_STRIP}\n" >> ${newlst}
390 # Build a basic set of INCS and LIBS according to user environment.
391 # On pkgsrc(7) systems automatically add /usr/pkg/*
392 if [ -n "${C_INCLUDE_PATH}" ]; then
395 set -- ${C_INCLUDE_PATH}
397 # for i; do -- new in POSIX Issue 7 + TC1
400 [ "${i}" = /usr/pkg/include ] && continue
401 INCS="${INCS} -I${i}"
404 [ -d /usr/pkg/include ] && INCS="${INCS} -I/usr
/pkg
/include
"
405 printf "INCS
=${INCS}\n" >> ${newlst}
407 if [ -n "${LD_LIBRARY_PATH}" ]; then
410 set -- ${LD_LIBRARY_PATH}
412 # for i; do -- new in POSIX Issue 7 + TC1
415 [ "${i}" = /usr/pkg/lib ] && continue
416 LIBS="${LIBS} -L${i}"
419 [ -d /usr/pkg/lib ] && LIBS="${LIBS} -L/usr
/pkg
/lib
"
420 printf "LIBS
=${LIBS}\n" >> ${newlst}
422 # Now finally check wether we already have a configuration and if so, wether
423 # all those parameters are still the same.. or something has actually changed
424 if [ -f ${lst} ] && ${cmp} ${newlst} ${lst} >/dev/null 2>&1; then
427 [ -f ${lst} ] && echo 'configuration updated..' || echo 'shiny configuration..'
429 # Time to redefine helper 1
431 ${rm} -f ${lst} ${h} ${mk}
435 ${mv} -f ${newlst} ${lst}
436 ${mv} -f ${newh} ${h}
437 ${mv} -f ${newmk} ${mk}
439 ## Compile and link checking ##
449 # (No function since some shells loose non-exported variables in traps)
450 trap "${rm} -f ${lst} ${h} ${mk} ${lib} ${inc} ${src} ${makefile}; exit" 1 2 15
451 trap "${rm} -f ${tmp0}.* ${tmp0}* ${makefile}" 0
453 # Time to redefine helper 2
457 printf "*** ${fmt}\\n
" "${@}"
458 printf "${fmt}" "${@}" >&5
461 exec 5>&2 > ${log} 2>&1
463 echo "${LIBS}" > ${lib}
464 echo "${INCS}" > ${inc}
465 # ${src} is only created if WANT_AMALGAMATION
467 ${cat} > ${makefile} << \!
468 .SUFFIXES: .o .c .x .y
472 $(CC) $(XINCS) -E $< >$@
474 $(CC) $(XINCS) -o $@ $< $(XLIBS)
479 variable=$1 topic=$2 define=$3
482 msg "checking
${topic} ...
"
483 echo "/* checked
${topic} */" >> ${h}
484 ${rm} -f ${tmp} ${tmp}.o
485 echo '*** test program is'
487 #echo '*** the preprocessor generates'
488 #${make} -f ${makefile} ${tmp}.x
490 echo '*** results are'
494 variable=$1 topic=$2 define=$3
496 _check_preface "${variable}" "${topic}" "${define}"
498 if ${make} -f ${makefile} XINCS="${INCS}" ./${tmp}.o &&
499 [ -f ./${tmp}.o ]; then
501 echo "${define}" >> ${h}
502 eval have_${variable}=yes
505 echo "/* ${define} */" >> ${h}
507 eval unset have_${variable}
513 run=$1 variable=$2 topic=$3 define=$4 libs=$5 incs=$6
515 _check_preface "${variable}" "${topic}" "${define}"
517 if ${make} -f ${makefile} XINCS="${INCS} ${incs}" \
518 XLIBS
="${LIBS} ${libs}" ./${tmp} &&
520 { [ ${run} -eq 0 ] || ./${tmp}; }; then
521 echo "*** adding INCS
<${incs}> LIBS
<${libs}>"
523 echo "${define}" >> ${h}
524 LIBS="${LIBS} ${libs}"
525 echo "${libs}" >> ${lib}
526 INCS="${INCS} ${incs}"
527 echo "${incs}" >> ${inc}
528 eval have_${variable}=yes
532 echo "/* ${define} */" >> ${h}
533 eval unset have_${variable}
539 _link_mayrun 0 "${1}" "${2}" "${3}" "${4}" "${5}"
543 _link_mayrun 1 "${1}" "${2}" "${3}" "${4}" "${5}"
546 feat_bail_required() {
547 if feat_require ${1}; then
548 msg "ERROR
: feature WANT_
${1} is required but not available
\\n
"
552 option_update # XXX this is rather useless here (dependency chain..)
557 # Better set _GNU_SOURCE (if we are on Linux only?); 'surprised it did without!
558 echo '#define _GNU_SOURCE' >> ${h}
560 if link_check hello 'if a hello world program can be built' << \!
563 int main(int argc, char *argv[])
574 echo >&5 'This oooops is most certainly not related to me.'
575 echo >&5 "Read the
file ${log} and check your compiler environment.
"
579 if link_check termios 'for termios.h and tc*() family' << \!
585 tcsetattr(0, TCSADRAIN | TCSAFLUSH, &tios);
592 echo >&5 'We require termios.h and the tc*() family of functions.'
593 echo >&5 "That much Unix we indulge ourselfs.
"
597 link_check setenv 'for setenv()/unsetenv()' '#define HAVE_SETENV' << \!
601 setenv("s-nail
", "to be made nifty
!", 1);
607 link_check snprintf 'for snprintf()' '#define HAVE_SNPRINTF' << \!
612 snprintf(b, sizeof b, "%s
", "string
");
617 link_check putc_unlocked 'for putc_unlocked()' '#define HAVE_PUTC_UNLOCKED' <<\!
621 putc_unlocked('@', stdout);
626 link_check fchdir 'for fchdir()' '#define HAVE_FCHDIR' << \!
635 link_check pipe2 'for pipe2()' '#define HAVE_PIPE2' << \!
641 pipe2(fds, O_CLOEXEC);
646 link_check mmap 'for mmap()' '#define HAVE_MMAP' << \!
647 #include <sys/types.h>
648 #include <sys/mman.h>
651 mmap(0, 0, 0, 0, 0, 0);
656 link_check mremap 'for mremap()' '#define HAVE_MREMAP' << \!
657 #include <sys/types.h>
658 #include <sys/mman.h>
661 mremap(0, 0, 0, MREMAP_MAYMOVE);
666 link_check setlocale 'for setlocale()' '#define HAVE_SETLOCALE' << \!
670 setlocale(LC_ALL, "");
675 if [ "${have_setlocale}" = yes ]; then
676 link_check c90amend1 'for ISO/IEC 9899:1990/Amendment 1:1995' \
677 '#define HAVE_C90AMEND1' << \!
684 char mbb[MB_LEN_MAX + 1];
689 mbrtowc(&wc, "x
", 1, NULL);
691 return (mblen("\
0", 1) == 0);
695 if [ "${have_c90amend1}" = yes ]; then
696 link_check wcwidth 'for wcwidth()' '#define HAVE_WCWIDTH' << \!
706 link_check nl_langinfo 'for nl_langinfo()' '#define HAVE_NL_LANGINFO' << \!
707 #include <langinfo.h>
712 return (nl_langinfo(CODESET) == NULL);
717 link_check mkstemp 'for mkstemp()' '#define HAVE_MKSTEMP' << \!
726 # Note: run_check, thus we also get only the desired implementation...
727 run_check realpath 'for realpath()' '#define HAVE_REALPATH' << \!
731 char *x = realpath(".
", NULL), *y = realpath("/", NULL);
732 return (x != NULL && y != NULL) ? 0 : 1;
736 link_check wordexp 'for wordexp()' '#define HAVE_WORDEXP' << \!
740 wordexp((char*)0, (wordexp_t*)0, 0);
747 if feat_yes DEBUG; then
748 echo '#define HAVE_DEBUG' >> ${h}
751 if feat_yes AMALGAMATION; then
752 echo '#define HAVE_AMALGAMATION' >> ${h}
755 if feat_no NOALLOCA; then
756 # Due to NetBSD PR lib/47120 it seems best not to use non-cc-builtin
757 # versions of alloca(3) since modern compilers just can't be trusted
758 # not to overoptimize and silently break some code
759 link_check alloca 'for __builtin_alloca()' \
760 '#define HAVE_ALLOCA __builtin_alloca' << \!
763 void *vp = __builtin_alloca(1);
769 if feat_yes DEVEL; then
770 echo '#define HAVE_DEVEL' >> ${h}
773 if feat_yes NYD2; then
774 echo '#define HAVE_NYD2' >> ${h}
779 if feat_yes ICONV; then
780 ${cat} > ${tmp2}.c << \!
786 id = iconv_open("foo
", "bar
");
790 < ${tmp2}.c link_check iconv 'for iconv functionality' \
791 '#define HAVE_ICONV' ||
792 < ${tmp2}.c link_check iconv \
793 'for iconv functionality in libiconv' \
794 '#define HAVE_ICONV' '-liconv' ||
795 feat_bail_required ICONV
797 echo '/* WANT_ICONV=0 */' >> ${h}
800 if feat_yes SOCKETS; then
801 compile_check arpa_inet_h 'for <arpa/inet.h>' \
802 '#define HAVE_ARPA_INET_H' << \!
804 #include <sys/types.h>
805 #include <sys/socket.h>
807 #include <netinet/in.h>
808 #include <arpa/inet.h>
811 ${cat} > ${tmp2}.c << \!
813 #include <sys/types.h>
814 #include <sys/socket.h>
816 #include <netinet/in.h>
817 #ifdef HAVE_ARPA_INET_H
818 #include <arpa/inet.h>
824 socket(AF_INET, SOCK_STREAM, 0);
826 gethostbyname("foo
");
831 < ${tmp2}.c link_check sockets 'for sockets in libc' \
832 '#define HAVE_SOCKETS' ||
833 < ${tmp2}.c link_check sockets 'for sockets in libnsl' \
834 '#define HAVE_SOCKETS' '-lnsl' ||
835 < ${tmp2}.c link_check sockets \
836 'for sockets in libsocket and libnsl' \
837 '#define HAVE_SOCKETS' '-lsocket -lnsl' ||
838 feat_bail_required SOCKETS
840 echo '/* WANT_SOCKETS=0 */' >> ${h}
841 fi # feat_yes SOCKETS
844 link_check setsockopt 'for setsockopt()' '#define HAVE_SETSOCKOPT' << \!
845 #include <sys/socket.h>
850 setsockopt(sockfd, SOL_SOCKET, SO_KEEPALIVE, NULL, 0);
855 feat_yes SOCKETS && [ -n "${have_setsockopt}" ] &&
856 link_check so_sndtimeo 'for SO_SNDTIMEO' '#define HAVE_SO_SNDTIMEO' << \!
857 #include <sys/socket.h>
865 setsockopt(sockfd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof tv);
866 setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof tv);
871 feat_yes SOCKETS && [ -n "${have_setsockopt}" ] &&
872 link_check so_linger 'for SO_LINGER' '#define HAVE_SO_LINGER' << \!
873 #include <sys/socket.h>
881 setsockopt(sockfd, SOL_SOCKET, SO_LINGER, &li, sizeof li);
886 if feat_yes IPV6; then
887 if link_check ipv6 'for IPv6 functionality' '#define HAVE_IPV6' << \!
889 #include <sys/types.h>
890 #include <sys/socket.h>
892 #include <netinet/in.h>
893 #ifdef HAVE_ARPA_INET_H
894 #include <arpa/inet.h>
899 struct addrinfo a, *ap;
900 getaddrinfo("foo
", "0", &a, &ap);
907 feat_bail_required IPV6
910 echo '/* WANT_IPV6=0 */' >> ${h}
913 if feat_yes SSL; then
914 if link_check openssl 'for sufficiently recent OpenSSL' \
916 #define HAVE_OPENSSL' '-lssl -lcrypto' << \!
917 #include <openssl/ssl.h>
918 #include <openssl/err.h>
919 #include <openssl/x509v3.h>
920 #include <openssl/x509.h>
921 #include <openssl/rand.h>
923 #if defined OPENSSL_NO_SSL2 && defined OPENSSL_NO_SSL3 &&\
924 defined OPENSSL_NO_TLS1
925 # error We need one of (SSLv2 and) SSLv3 and TLS1.
930 SSLv23_client_method();
931 #ifndef OPENSSL_NO_SSL3
932 SSLv3_client_method();
934 #ifndef OPENSSL_NO_TLS1
935 TLSv1_client_method();
936 # ifdef TLS1_1_VERSION
937 TLSv1_1_client_method();
939 # ifdef TLS1_2_VERSION
940 TLSv1_2_client_method();
943 PEM_read_PrivateKey(0, 0, 0, 0);
950 feat_bail_required SSL
953 if [ "${have_openssl}" = 'yes' ]; then
954 compile_check stack_of 'for OpenSSL STACK_OF()' \
955 '#define HAVE_OPENSSL_STACK_OF' << \!
956 #include <openssl/ssl.h>
957 #include <openssl/err.h>
958 #include <openssl/x509v3.h>
959 #include <openssl/x509.h>
960 #include <openssl/rand.h>
964 STACK_OF(GENERAL_NAME) *gens = NULL;
965 printf("%p
", gens); /* to make it used */
970 link_check rand_egd 'for OpenSSL RAND_egd()' \
971 '#define HAVE_OPENSSL_RAND_EGD' '-lssl -lcrypto' << \!
972 #include <openssl/rand.h>
976 return RAND_egd("some.where
") > 0;
980 if feat_yes MD5 && feat_no NOEXTMD5; then
981 run_check openssl_md5 'for MD5 digest in OpenSSL' \
982 '#define HAVE_OPENSSL_MD5' << \!
984 #include <openssl/md5.h>
988 char const dat[] = "abrakadabrafidibus
";
989 char dig[16], hex[16 * 2];
993 memset(dig, 0, sizeof(dig));
994 memset(hex, 0, sizeof(hex));
996 MD5_Update(&ctx, dat, sizeof(dat) - 1);
997 MD5_Final(dig, &ctx);
999 #define hexchar(n) ((n) > 9 ? (n) - 10 + 'a' : (n) + '0')
1000 for (i = 0; i < sizeof(hex) / 2; i++) {
1002 hex[j] = hexchar((dig[i] & 0xf0) >> 4);
1003 hex[++j] = hexchar(dig[i] & 0x0f);
1005 return !!memcmp("6d7d0a3d949da2e96f2aa010f65d8326
", hex, sizeof(hex));
1008 fi # feat_yes MD5 && feat_no NOEXTMD5
1011 echo '/* WANT_SSL=0 */' >> ${h}
1014 if feat_yes SMTP; then
1015 echo '#define HAVE_SMTP' >> ${h}
1017 echo '/* WANT_SMTP=0 */' >> ${h}
1020 if feat_yes POP3; then
1021 echo '#define HAVE_POP3' >> ${h}
1023 echo '/* WANT_POP3=0 */' >> ${h}
1026 if feat_yes IMAP; then
1027 echo '#define HAVE_IMAP' >> ${h}
1029 echo '/* WANT_IMAP=0 */' >> ${h}
1032 if feat_yes GSSAPI; then
1033 ${cat} > ${tmp2}.c << \!
1034 #include <gssapi/gssapi.h>
1038 gss_import_name(0, 0, GSS_C_NT_HOSTBASED_SERVICE, 0);
1039 gss_init_sec_context(0,0,0,0,0,0,0,0,0,0,0,0,0);
1043 ${sed} -e '1s/gssapi\///' < ${tmp2}.c > ${tmp3}.c
1045 if command -v krb5-config >/dev/null 2>&1; then
1046 i=`command -v krb5-config`
1047 GSS_LIBS="`CFLAGS= ${i} --libs gssapi`"
1048 GSS_INCS="`CFLAGS= ${i} --cflags`"
1049 i='for GSS-API via krb5-config(1)'
1053 i='for GSS-API in gssapi/gssapi.h, libgssapi'
1055 if < ${tmp2}.c link_check gss \
1056 "${i}" '#define HAVE_GSSAPI' "${GSS_LIBS}" "${GSS_INCS}" ||\
1057 < ${tmp3}.c link_check gss \
1058 'for GSS-API in gssapi.h, libgssapi' \
1059 '#define HAVE_GSSAPI
1060 #define GSSAPI_REG_INCLUDE' \
1062 < ${tmp2}.c link_check gss 'for GSS-API in libgssapi_krb5' \
1063 '#define HAVE_GSSAPI' \
1065 < ${tmp3}.c link_check gss \
1066 'for GSS-API in libgssapi, OpenBSD-style (pre 5.3)' \
1067 '#define HAVE_GSSAPI
1068 #define GSS_REG_INCLUDE' \
1069 '-lgssapi -lkrb5 -lcrypto' \
1070 '-I/usr/include/kerberosV' ||\
1071 < ${tmp2}.c link_check gss 'for GSS-API in libgss' \
1072 '#define HAVE_GSSAPI' \
1074 link_check gss 'for GSS-API in libgssapi_krb5, old-style' \
1075 '#define HAVE_GSSAPI
1076 #define GSSAPI_OLD_STYLE' \
1077 '-lgssapi_krb5' << \!
1078 #include <gssapi/gssapi.h>
1079 #include <gssapi/gssapi_generic.h>
1083 gss_import_name(0, 0, gss_nt_service_name, 0);
1084 gss_init_sec_context(0,0,0,0,0,0,0,0,0,0,0,0,0);
1091 feat_bail_required GSSAPI
1094 echo '/* WANT_GSSAPI=0 */' >> ${h}
1095 fi # feat_yes GSSAPI
1097 if feat_yes NETRC; then
1098 echo '#define HAVE_NETRC' >> ${h}
1100 echo '/* WANT_NETRC=0 */' >> ${h}
1103 if feat_yes AGENT; then
1104 echo '#define HAVE_AGENT' >> ${h}
1106 echo '/* WANT_AGENT=0 */' >> ${h}
1109 if feat_yes IDNA; then
1110 if link_check idna 'for GNU Libidn' '#define HAVE_IDNA' '-lidn' << \!
1112 #include <idn-free.h>
1113 #include <stringprep.h>
1116 char *utf8, *idna_ascii, *idna_utf8;
1117 utf8 = stringprep_locale_to_utf8("does.this.work
");
1118 if (idna_to_ascii_8z(utf8, &idna_ascii, IDNA_USE_STD3_ASCII_RULES)
1121 idn_free(idna_ascii);
1122 /* (Rather link check only here) */
1123 idna_utf8 = stringprep_convert(idna_ascii, "UTF-8
", "de_DE
");
1130 feat_bail_required IDNA
1133 echo '/* WANT_IDNA=0 */' >> ${h}
1136 if feat_yes IMAP_SEARCH; then
1137 echo '#define HAVE_IMAP_SEARCH' >> ${h}
1139 echo '/* WANT_IMAP_SEARCH=0 */' >> ${h}
1142 if feat_yes REGEX; then
1143 if link_check regex 'for regular expressions' '#define HAVE_REGEX' << \!
1150 if (regcomp(&re, ".
*bsd
", REG_EXTENDED | REG_ICASE | REG_NOSUB) != 0)
1152 status = regexec(&re, "plan9
", 0,NULL, 0);
1154 return !(status == REG_NOMATCH);
1160 feat_bail_required REGEX
1163 echo '/* WANT_REGEX=0 */' >> ${h}
1166 if feat_yes READLINE; then
1168 link_check readline "for readline
(3) (${1})" \
1169 '#define HAVE_READLINE' "${1}" << \!
1171 #include <readline/history.h>
1172 #include <readline/readline.h>
1181 stifle_history(242);
1182 rl = readline("Enter a line
:");
1186 rl_extend_line_buffer(10);
1187 rl_point = rl_end = 10;
1188 rl_pre_input_hook = (rl_hook_func_t*)NULL;
1189 rl_forced_update_display();
1191 hs = history_get_history_state();
1193 he = history_list();
1196 rl_free_line_state();
1197 rl_cleanup_after_signal();
1198 rl_reset_after_signal();
1204 __edrdlib -lreadline ||
1205 __edrdlib '-lreadline -ltermcap' || feat_bail_required READLINE
1206 [ -n "${have_readline}" ] && WANT_TABEXPAND=1
1209 if feat_yes EDITLINE && [ -z "${have_readline}" ]; then
1211 link_check editline "for editline
(3) (${1})" \
1212 '#define HAVE_EDITLINE' "${1}" << \!
1213 #include <histedit.h>
1214 static char * getprompt(void) { return (char*)"ok
"; }
1217 EditLine *el_el = el_init("TEST
", stdin, stdout, stderr);
1219 History *el_hcom = history_init();
1220 history(el_hcom, &he, H_SETSIZE, 242);
1221 el_set(el_el, EL_SIGNAL, 0);
1222 el_set(el_el, EL_TERMINAL, NULL);
1223 el_set(el_el, EL_HIST, &history, el_hcom);
1224 el_set(el_el, EL_EDITOR, "emacs
");
1225 el_set(el_el, EL_PROMPT, &getprompt);
1226 el_source(el_el, NULL);
1227 history(el_hcom, &he, H_GETSIZE);
1228 history(el_hcom, &he, H_CLEAR);
1230 /* TODO add loader and addfn checks */
1231 history_end(el_hcom);
1238 __edlib '-ledit -ltermcap' || feat_bail_required EDITLINE
1239 [ -n "${have_editline}" ] && WANT_TABEXPAND=0
1242 if feat_yes NCL && [ -z "${have_editline}" ] && [ -z "${have_readline}" ] &&\
1243 [ -n "${have_c90amend1}" ]; then
1245 echo '#define HAVE_NCL' >> ${h}
1247 feat_bail_required NCL
1248 echo '/* WANT_{READLINE,EDITLINE,NCL}=0 */' >> ${h}
1251 # Generic have-a-command-line-editor switch for those who need it below
1252 if [ -n "${have_ncl}" ] || [ -n "${have_editline}" ] ||\
1253 [ -n "${have_readline}" ]; then
1257 if [ -n "${have_cle}" ] && feat_yes HISTORY; then
1258 echo '#define HAVE_HISTORY' >> ${h}
1260 echo '/* WANT_HISTORY=0 */' >> ${h}
1263 if [ -n "${have_cle}" ] && feat_yes TABEXPAND; then
1264 echo '#define HAVE_TABEXPAND' >> ${h}
1266 echo '/* WANT_TABEXPAND=0 */' >> ${h}
1269 if feat_yes SPAM; then
1270 echo '#define HAVE_SPAM' >> ${h}
1271 if command -v spamc >/dev/null 2>&1; then
1272 echo "#define SPAMC_PATH \"`command -v spamc`\"" >> ${h}
1275 echo '/* WANT_SPAM=0 */' >> ${h}
1278 if feat_yes DOCSTRINGS
; then
1279 echo '#define HAVE_DOCSTRINGS' >> ${h}
1281 echo '/* WANT_DOCSTRINGS=0 */' >> ${h}
1284 if feat_yes QUOTE_FOLD
&&\
1285 [ -n "${have_c90amend1}" ] && [ -n "${have_wcwidth}" ]; then
1286 echo '#define HAVE_QUOTE_FOLD' >> ${h}
1288 echo '/* WANT_QUOTE_FOLD=0 */' >> ${h}
1291 if feat_yes COLOUR
; then
1292 echo '#define HAVE_COLOUR' >> ${h}
1294 echo '/* WANT_COLOUR=0 */' >> ${h}
1297 if feat_yes MD5
; then
1298 echo '#define HAVE_MD5' >> ${h}
1300 echo '/* WANT_MD5=0 */' >> ${h}
1305 # Since we cat(1) the content of those to cc/"ld", convert them to single line
1307 < "${1}" > "${2}" ${awk} \
1308 'BEGIN {ORS = " "} /^[^#]/ {print} {next} END {ORS = ""; print "\n"}'
1311 squeeze_em ${inc} ${tmp}
1313 squeeze_em ${lib} ${tmp}
1318 printf '#ifndef _CONFIG_H\n# define _CONFIG_H\n' > ${h}
1319 ${cat} ${tmp} >> ${h}
1321 printf '\n/* The "feature string
", for "simplicity
" and lex.c */\n' >> ${h}
1322 printf '#ifdef _MAIN_SOURCE\n' >> ${h}
1323 printf '# ifdef HAVE_AMALGAMATION\nstatic\n# endif\n' >> ${h}
1324 printf 'char const features[] = "MIME
"\n' >> ${h}
1325 printf '# ifdef HAVE_SETLOCALE\n ",LOCALES
"\n# endif\n' >> ${h}
1326 printf '# ifdef HAVE_C90AMEND1\n ",MULTIBYTE CHARSETS
"\n# endif\n' >> ${h}
1327 printf '# ifdef HAVE_NL_LANGINFO\n ",TERMINAL CHARSET
"\n# endif\n' >> ${h}
1328 printf '# ifdef HAVE_ICONV\n ",ICONV
"\n# endif\n' >> ${h}
1329 printf '# ifdef HAVE_SOCKETS\n ",NETWORK
"\n# endif\n' >> ${h}
1330 printf '# ifdef HAVE_IPV6\n ",IPv6
"\n# endif\n' >> ${h}
1331 printf '# ifdef HAVE_SSL\n ",S
/MIME
,SSL
/TLS
"\n# endif\n' >> ${h}
1332 printf '# ifdef HAVE_SMTP\n ",SMTP
"\n# endif\n' >> ${h}
1333 printf '# ifdef HAVE_POP3\n ",POP3
"\n# endif\n' >> ${h}
1334 printf '# ifdef HAVE_IMAP\n ",IMAP
"\n# endif\n' >> ${h}
1335 printf '# ifdef HAVE_GSSAPI\n ",GSS-API
"\n# endif\n' >> ${h}
1336 printf '# ifdef HAVE_NETRC\n ",NETRC
"\n# endif\n' >> ${h}
1337 printf '# ifdef HAVE_AGENT\n ",AGENT
"\n# endif\n' >> ${h}
1338 printf '# ifdef HAVE_IDNA\n ",IDNA
"\n# endif\n' >> ${h}
1339 printf '# ifdef HAVE_IMAP_SEARCH\n ",IMAP-searches
"\n# endif\n' >> ${h}
1340 printf '# ifdef HAVE_REGEX\n ",REGEX
"\n# endif\n' >> ${h}
1341 printf '# ifdef HAVE_READLINE\n ",READLINE
"\n# endif\n' >> ${h}
1342 printf '# ifdef HAVE_EDITLINE\n ",EDITLINE
"\n# endif\n' >> ${h}
1343 printf '# ifdef HAVE_NCL\n ",NCL
"\n# endif\n' >> ${h}
1344 printf '# ifdef HAVE_TABEXPAND\n ",TABEXPAND
"\n# endif\n' >> ${h}
1345 printf '# ifdef HAVE_HISTORY\n ",HISTORY
"\n# endif\n' >> ${h}
1346 printf '# ifdef HAVE_SPAM\n ",SPAM
"\n# endif\n' >> ${h}
1347 printf '# ifdef HAVE_DOCSTRINGS\n ",DOCSTRINGS
"\n# endif\n' >> ${h}
1348 printf '# ifdef HAVE_QUOTE_FOLD\n ",QUOTE-FOLD
"\n# endif\n' >> ${h}
1349 printf '# ifdef HAVE_COLOUR\n ",COLOUR
"\n# endif\n' >> ${h}
1350 printf '# ifdef HAVE_DEBUG\n ",DEBUG
"\n# endif\n' >> ${h}
1351 printf ';\n#endif /* _MAIN_SOURCE */\n' >> ${h}
1353 printf '#endif /* _CONFIG_H */\n' >> ${h}
1356 # Create the real mk.mk
1357 ${rm} -rf ${tmp0}.* ${tmp0}*
1358 printf 'OBJ_SRC = ' >> ${mk}
1359 if feat_no AMALGAMATION; then
1361 echo 'OBJ_DEP =' >> ${mk}
1363 j=`echo "${src}" | sed 's/^.\///'`
1364 echo "${j}" >> ${mk}
1365 printf 'OBJ_DEP = main.c ' >> ${mk}
1366 printf '#define _MAIN_SOURCE\n' >> ${src}
1367 printf '#include "nail.h
"\n#include "main.c
"\n' >> ${src}
1369 if [ "${i}" = "${j}" ] || [ "${i}" = main.c ]; then
1372 printf "${i} " >> ${mk}
1373 printf "#include \"${i}\"\n" >> ${src}
1378 echo "LIBS = `${cat} ${lib}`" >> ${mk}
1379 echo "INCLUDES
= `${cat} ${inc}`" >> ${mk}
1381 ${cat} ./mk-mk.in >> ${mk}
1385 ${cat} > ${tmp2}.c << \!
1387 #ifdef HAVE_NL_LANGINFO
1388 # include <langinfo.h>
1391 :The following optional features are enabled:
1392 #ifdef HAVE_SETLOCALE
1393 : + Locale support: Printable characters depend on the environment
1394 # ifdef HAVE_C90AMEND1
1395 : + Multibyte character support
1397 # ifdef HAVE_NL_LANGINFO
1398 : + Automatic detection of terminal character set
1402 : + Character set conversion using iconv()
1408 : + Support for Internet Protocol v6 (IPv6)
1411 # ifdef HAVE_OPENSSL
1412 : + S/MIME and SSL/TLS (OpenSSL)
1425 : + GSS-API authentication
1428 : + .netrc file support
1431 : + Password query through agent
1434 : + IDNA (internationalized domain names for applications) support
1436 #ifdef HAVE_IMAP_SEARCH
1437 : + IMAP-style search expressions
1440 : + Regular expression support (searches, conditional expressions etc.)
1442 #if defined HAVE_READLINE || defined HAVE_EDITLINE || defined HAVE_NCL
1443 : + Command line editing
1444 # ifdef HAVE_TABEXPAND
1445 : + + Tabulator expansion
1447 # ifdef HAVE_HISTORY
1448 : + + History management
1452 : + Interaction with spam filters
1454 #ifdef HAVE_DOCSTRINGS
1455 : + Documentation summary strings
1457 #ifdef HAVE_QUOTE_FOLD
1458 : + Extended *quote-fold*ing
1461 : + Coloured message display (simple)
1464 :The following optional features are disabled:
1465 #ifndef HAVE_SETLOCALE
1466 : - Locale support: Only ASCII characters are recognized
1468 # ifndef HAVE_C90AMEND1
1469 : - Multibyte character support
1471 # ifndef HAVE_NL_LANGINFO
1472 : - Automatic detection of terminal character set
1475 : - Character set conversion using iconv()
1477 #ifndef HAVE_SOCKETS
1481 : - Support for Internet Protocol v6 (IPv6)
1484 : - S/MIME and SSL/TLS
1496 : - GSS-API authentication
1499 : - .netrc file support
1502 : - Password query through agent
1505 : - IDNA (internationalized domain names for applications) support
1507 #ifndef HAVE_IMAP_SEARCH
1508 : - IMAP-style search expressions
1511 : - Regular expression support
1513 #if !defined HAVE_READLINE && !defined HAVE_EDITLINE && !defined HAVE_NCL
1514 : - Command line editing and history
1517 : - Interaction with spam filters
1519 #ifndef HAVE_DOCSTRINGS
1520 : - Documentation summary strings
1522 #ifndef HAVE_QUOTE_FOLD
1523 : - Extended *quote-fold*ing
1526 : - Coloured message display (simple)
1530 #ifndef HAVE_SNPRINTF
1531 : . The function snprintf() could not be found. We will use and internal
1532 : sprintf() instead. This might overflow buffers if input values are larger
1533 : than expected. Use the resulting binary with care or update your system
1534 : environment and start the configuration process again.
1537 : . The function fchdir() could not be found. We will use chdir()
1538 : instead. This is not a problem unless the current working
1539 : directory of mailx is moved while the IMAP cache is used.
1542 : . Debug enabled binary: not meant to be used by end-users: THANKS!
1547 ${make} -f ${makefile} ${tmp2}.x
1548 < ${tmp2}.x >&5 ${sed} -e '/^[^:]/d; /^$/d; s/^://'