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
22 WANT_READLINE
=0 WANT_EDITLINE
=0
30 WANT_READLINE
=0 WANT_EDITLINE
=0
36 echo >&2 "Unknown CONFIG= setting: ${CONFIG}"
37 echo >&2 'Possible values: MINIMAL, MEDIUM, NETSEND'
44 if nwantfeat SOCKETS
; then
45 WANT_IPV6
=0 WANT_SSL
=0
46 WANT_IMAP
=0 WANT_GSSAPI
=0 WANT_POP3
=0 WANT_SMTP
=0
48 if nwantfeat IMAP
&& nwantfeat POP3
&& nwantfeat SMTP
; then
49 WANT_SOCKETS
=0 WANT_IPV6
=0 WANT_SSL
=0
51 if nwantfeat IMAP
; then
54 # If we don't need MD5 except for producing boundary and message-id strings,
55 # leave it off, plain old srand(3) should be enough for that purpose.
56 if nwantfeat SOCKETS
; then
59 if wantfeat DEBUG
; then
64 # Check out compiler ($CC) and -flags ($CFLAGS)
69 # $CC is overwritten when empty or a default "cc", even without WANT_AUTOCC
70 if [ -z "${CC}" ] ||
[ "${CC}" = cc
]; then
72 if { CC
="`command -v clang`"; }; then
74 elif { CC
="`command -v gcc`"; }; then
76 elif { CC
="`command -v c89`"; }; then
77 [ "${i}" = UnixWare
] && _CFLAGS
='-v -O'
78 elif { CC
="`command -v c99`"; }; then
82 echo >&2 ' I cannot find a compiler!'
83 echo >&2 ' Neither of clang(1), gcc(1), c89(1) and c99(1).'
84 echo >&2 ' Please set the CC environment variable, maybe CFLAGS also.'
90 ccver
=`${CC} --version 2>/dev/null`
92 if { i
=$ccver; echo "${i}"; } |
${grep} -q -i -e gcc
-e clang
; then
93 #if echo "${i}" | ${grep} -q -i -e gcc -e 'clang version 1'; then
95 _CFLAGS
='-std=c89 -O2'
96 _CFLAGS
="${_CFLAGS} -Wall -Wextra -pedantic"
97 _CFLAGS
="${_CFLAGS} -fno-unwind-tables -fno-asynchronous-unwind-tables"
98 _CFLAGS
="${_CFLAGS} -fstrict-aliasing"
99 _CFLAGS
="${_CFLAGS} -Wbad-function-cast -Wcast-align -Wcast-qual"
100 _CFLAGS
="${_CFLAGS} -Winit-self -Wshadow -Wunused -Wwrite-strings"
101 if { i
=$ccver; echo "${i}"; } |
${grep} -q -e 'clang version 1'; then
104 _CFLAGS
="${_CFLAGS} -fstrict-overflow -Wstrict-overflow=5"
105 if wantfeat AMALGAMATION
&& nwantfeat DEBUG
; then
106 _CFLAGS
="${_CFLAGS} -Wno-unused-function"
108 if { i
=$ccver; echo "${i}"; } |
${grep} -q -i -e clang
; then
109 _CFLAGS
="${_CFLAGS} -Wno-unused-result" # TODO handle the right way
112 _CFLAGS
="${_CFLAGS} -Wno-long-long" # ISO C89 has no 'long long'...
113 # elif { i=$ccver; echo "${i}"; } | ${grep} -q -i -e clang; then
115 # _CFLAGS='-std=c89 -O3 -g -Weverything -Wno-long-long'
116 elif [ -z "${_CFLAGS}" ]; then
120 if nwantfeat DEBUG
; then
121 _CFLAGS
="${_CFLAGS} -DNDEBUG"
123 _CFLAGS
="${_CFLAGS} -g";
124 if [ "${stackprot}" = yes ]; then
125 _CFLAGS
="${_CFLAGS} -fstack-protector-all "
126 _CFLAGS
="${_CFLAGS} -Wstack-protector -D_FORTIFY_SOURCE=2"
129 _CFLAGS
="${_CFLAGS} ${ADDCFLAGS}"
130 _LDFLAGS
="${_LDFLAGS} ${ADDLDFLAGS}" # XXX -Wl,--sort-common,[-O1]
131 export _CFLAGS _LDFLAGS
133 # $CFLAGS and $LDFLAGS are only overwritten if explicitly wanted
134 if wantfeat AUTOCC
; then
137 export CFLAGS LDFLAGS
144 ## - Heirloom sh(1) (and same origin) have problems with ': >' redirection,
145 ## so use "printf '' >" instead
146 ## - Heirloom sh(1) and maybe more execute loops with redirection in a subshell
147 ## (but don't export eval's from within), therefore we need to (re)include
148 ## variable assignments at toplevel instead (via reading temporary files)
150 ## First of all, create new configuration and check wether it changed ##
157 newlst
=.
/config.lst-new
158 newmk
=.
/config.mk-new
163 # We need some standard utilities
166 n
=$1 i
=$2 opt
=${3:-0}
167 if type "${i}" >/dev
/null
2>&1; then
171 if [ ${opt} -eq 0 ]; then
172 echo >&2 "ERROR: no trace of the utility \`${n}'"
178 # Check those tools right now that we need before including ${conf}
179 check_tool
rm "${rm:-`command -pv rm`}"
180 check_tool
sed "${sed:-`command -pv sed`}"
182 # Only incorporate what wasn't overwritten from command line / CONFIG
183 trap "${rm} -f ${tmp}; exit" 1 2 15
184 trap "${rm} -f ${tmp}" 0
187 < ${conf} ${sed} -e '/^[ \t]*#/d' -e '/^$/d' -e 's/[ \t]*$//' |
189 i
=`echo ${line} | ${sed} -e 's/=.*$//'`
190 eval j
=\$
${i} jx=\${${i}+x}
191 if [ -n "${j}" ] ||
[ "${jx}" = x
]; then
198 check_tool
awk "${awk:-`command -pv awk`}"
199 check_tool
cat "${cat:-`command -pv cat`}"
200 check_tool
chmod "${chmod:-`command -pv chmod`}"
201 check_tool
cp "${cp:-`command -pv cp`}"
202 check_tool
cmp "${cmp:-`command -pv cmp`}"
203 check_tool
grep "${grep:-`command -pv grep`}"
204 check_tool mkdir
"${mkdir:-`command -pv mkdir`}"
205 check_tool
mv "${mv:-`command -pv mv`}"
206 # rm(1), sed(1) above
207 check_tool
tee "${tee:-`command -pv tee`}"
209 check_tool
make "${MAKE:-`command -pv make`}"
210 check_tool strip
"${STRIP:-`command -pv strip`}" 1
224 # (No function since some shells loose non-exported variables in traps)
225 trap "${rm} -f ${tmp} ${newlst} ${newmk} ${newh}; exit" 1 2 15
226 trap "${rm} -f ${tmp} ${newlst} ${newmk} ${newh}" 0
227 ${rm} -f ${newlst} ${newmk} ${newh}
229 # (Could: use FD redirection, add eval(1) and don't re-'. ./${newlst}')
231 i
=`echo ${line} | ${sed} -e 's/=.*$//'`
233 if [ -z "${j}" ] ||
[ "${j}" = 0 ]; then
234 printf "/*#define ${i}*/\n" >> ${newh}
235 elif [ "${j}" = 1 ]; then
236 printf "#define ${i}\n" >> ${newh}
238 printf "#define ${i} \"${j}\"\n" >> ${newh}
240 printf "${i} = ${j}\n" >> ${newmk}
241 printf "${i}=\"${j}\"\n"
242 done < ${tmp} > ${newlst}
245 printf "#define UAGENT \"${SID}${NAIL}\"\n" >> ${newh}
246 printf "UAGENT
= ${SID}${NAIL}\n" >> ${newmk}
250 printf "CC = ${CC}\n" >> ${newmk}
251 printf "_CFLAGS = ${_CFLAGS}\nCFLAGS = ${CFLAGS}\n" >> ${newmk}
252 printf "_LDFLAGS
= ${_LDFLAGS}\nLDFLAGS = ${LDFLAGS}\n" >> ${newmk}
253 printf "AWK = ${awk}\nCMP = ${cmp}\nCHMOD = ${chmod}\nCP = ${cp}\n" >> ${newmk}
254 printf "MKDIR
= ${mkdir}\nRM = ${rm}\nSED = ${sed}\n" >> ${newmk}
255 printf "STRIP = ${strip}\nHAVE_STRIP = ${HAVE_STRIP}\n" >> ${newmk}
256 # (We include the cc(1)/ld(1) environment only for update detection..)
257 printf "CC
=\"${CC}\"\n" >> ${newlst}
258 printf "_CFLAGS
=\"${_CFLAGS}\"\nCFLAGS=\"${CFLAGS}\"\n" >> ${newlst}
259 printf "_LDFLAGS=\"${_LDFLAGS}\"\nLDFLAGS=\"${LDFLAGS}\"\n" >> ${newlst}
260 printf "AWK
=${awk}\nCMP=${cmp}\nCHMOD=${chmod}\nCP=${cp}\n" >> ${newlst}
261 printf "MKDIR=${mkdir}\nRM=${rm}\nSED=${sed}\n" >> ${newlst}
262 printf "STRIP
=${strip}\nHAVE_STRIP=${HAVE_STRIP}\n" >> ${newlst}
264 if [ -f ${lst} ] && ${cmp} ${newlst} ${lst} >/dev
/null
2>&1; then
267 [ -f ${lst} ] && echo 'configuration updated..' ||
echo 'shiny configuration..'
269 ${mv} -f ${newlst} ${lst}
270 ${mv} -f ${newh} ${h}
271 ${mv} -f ${newmk} ${mk}
273 ## Compile and link checking ##
283 # (No function since some shells loose non-exported variables in traps)
284 trap "${rm} -f ${lst} ${h} ${mk} ${lib} ${inc} ${src} ${makefile}; exit" 1 2 15
285 trap "${rm} -rf ${tmp0}.* ${tmp0}* ${makefile}" 0
287 exec 5>&2 > ${log} 2>&1
290 # ${src} is only created if WANT_AMALGAMATION
292 ${cat} > ${makefile} << \
!
293 .SUFFIXES
: .o .c .x .y
297 $
(CC
) $
(XINCS
) -E $
< >$@
299 $
(CC
) $
(XINCS
) -o $@ $
< $
(XLIBS
)
307 printf "*** ${fmt}\\n" "${@}"
308 printf "${fmt}" "${@}" >&5
312 variable
=$1 topic
=$2 define
=$3
315 msg
"checking ${topic} ... "
316 echo "/* checked ${topic} */" >> ${h}
317 ${rm} -f ${tmp} ${tmp}.o
318 echo '*** test program is'
320 #echo '*** the preprocessor generates'
321 #${make} -f ${makefile} ${tmp}.x
323 echo '*** results are'
327 variable
=$1 topic
=$2 define
=$3
329 _check_preface
"${variable}" "${topic}" "${define}"
331 if ${make} -f ${makefile} XINCS="${INCS}" ./${tmp}.o
&&
332 [ -f .
/${tmp}.o
]; then
334 echo "${define}" >> ${h}
335 eval have_
${variable}=yes
338 echo "/* ${define} */" >> ${h}
340 eval unset have_
${variable}
346 run
=$1 variable
=$2 topic
=$3 define
=$4 libs
=$5 incs
=$6
348 _check_preface
"${variable}" "${topic}" "${define}"
350 if ${make} -f ${makefile} XINCS="${INCS} ${incs}" \
351 XLIBS="${LIBS} ${libs}" ./${tmp} &&
353 { [ ${run} -eq 0 ] || ./${tmp}; }; then
354 echo "*** adding INCS<${incs}> LIBS<${libs}>"
356 echo "${define}" >> ${h}
357 LIBS
="${LIBS} ${libs}"
358 echo "${libs}" >> ${lib}
359 INCS
="${INCS} ${incs}"
360 echo "${incs}" >> ${inc}
361 eval have_
${variable}=yes
365 echo "/* ${define} */" >> ${h}
366 eval unset have_
${variable}
372 _link_mayrun
0 "${1}" "${2}" "${3}" "${4}" "${5}"
376 _link_mayrun
1 "${1}" "${2}" "${3}" "${4}" "${5}"
379 # Build a basic set of INCS and LIBS according to user environment.
380 # On pkgsrc(7) systems automatically add /usr/pkg/*
381 if [ -n "${C_INCLUDE_PATH}" ]; then
384 set -- ${C_INCLUDE_PATH}
386 # for i; do -- new in POSIX Issue 7 + TC1
389 [ "${i}" = '/usr/pkg/include' ] && continue
390 INCS
="${INCS} -I${i}"
393 [ -d /usr
/pkg
/include
] && INCS
="${INCS} -I/usr/pkg/include"
394 echo "${INCS}" >> ${inc}
396 if [ -n "${LD_LIBRARY_PATH}" ]; then
399 set -- ${LD_LIBRARY_PATH}
401 # for i; do -- new in POSIX Issue 7 + TC1
404 [ "${i}" = '/usr/pkg/lib' ] && continue
405 LIBS
="${LIBS} -L${i}"
408 [ -d /usr
/pkg
/lib
] && LIBS
="${LIBS} -L/usr/pkg/lib"
409 echo "${LIBS}" >> ${lib}
413 # Better set _GNU_SOURCE (if we are on Linux only?); 'surprised it did without
414 echo '#define _GNU_SOURCE' >> ${h}
416 link_check hello
'if a hello world program can be built' << \
! ||
{\
417 echo >&5 'This oooops is most certainly not related to me.';\
418 echo >&5 "Read the file ${log} and check your compiler environment.";\
419 ${rm} -f ${lst} ${h} ${mk};\
424 int main
(int argc
, char
*argv
[])
433 link_check termios
'for termios.h and tc*() family' << \
! ||
{\
434 echo >&5 'We require termios.h and the tc*() family of functions.';\
435 echo >&5 "That much Unix we indulge ourselfs.";\
436 ${rm} -f ${lst} ${h} ${mk};\
444 tcsetattr
(0, TCSADRAIN | TCSAFLUSH
, &tios
);
449 link_check snprintf
'for snprintf()' '#define HAVE_SNPRINTF' << \
!
454 snprintf
(b
, sizeof b
, "%s", "string");
459 link_check putc_unlocked
'for putc_unlocked()' '#define HAVE_PUTC_UNLOCKED' <<\
!
463 putc_unlocked
('@', stdout
);
468 link_check fchdir
'for fchdir()' '#define HAVE_FCHDIR' << \
!
477 link_check mmap
'for mmap()' '#define HAVE_MMAP' << \
!
478 #include <sys/types.h>
479 #include <sys/mman.h>
482 mmap
(0, 0, 0, 0, 0, 0);
487 link_check mremap
'for mremap()' '#define HAVE_MREMAP' << \
!
488 #include <sys/types.h>
489 #include <sys/mman.h>
492 mremap
(0, 0, 0, MREMAP_MAYMOVE
);
497 link_check setlocale
'for setlocale()' '#define HAVE_SETLOCALE' << \
!
501 setlocale
(LC_ALL
, "");
506 if [ "${have_setlocale}" = yes ]; then
507 link_check c90amend1
'for ISO/IEC 9899:1990/Amendment 1:1995' \
508 '#define HAVE_C90AMEND1' << \
!
515 char mbb
[MB_LEN_MAX
+ 1];
520 mbrtowc
(&wc, "x", 1, NULL
);
521 (void
)wctomb
(mbb
, wc);
522 return (mblen
("\0", 1) == 0);
526 if [ "${have_c90amend1}" = yes ]; then
527 link_check wcwidth
'for wcwidth()' '#define HAVE_WCWIDTH' << \
!
537 link_check nl_langinfo
'for nl_langinfo()' '#define HAVE_NL_LANGINFO' << \
!
538 #include <langinfo.h>
543 return (nl_langinfo
(CODESET
) == NULL
);
548 link_check mkstemp
'for mkstemp()' '#define HAVE_MKSTEMP' << \
!
557 # Note: run_check, thus we also get only the desired implementation...
558 run_check realpath
'for realpath()' '#define HAVE_REALPATH' << \
!
562 char
*x
= realpath
(".", NULL
), *y
= realpath
("/", NULL
);
563 return (x
!= NULL
&& y
!= NULL
) ?
0 : 1;
567 link_check wordexp
'for wordexp()' '#define HAVE_WORDEXP' << \
!
571 wordexp
((char
*)0, (wordexp_t
*)0, 0);
578 if wantfeat DEBUG
; then
579 echo '#define HAVE_DEBUG' >> ${h}
582 if wantfeat AMALGAMATION
; then
583 echo '#define HAVE_AMALGAMATION' >> ${h}
586 if nwantfeat NOALLOCA
; then
587 # Due to NetBSD PR lib/47120 it seems best not to use non-cc-builtin
588 # versions of alloca(3) since modern compilers just can't be trusted
589 # not to overoptimize and silently break some code
590 link_check alloca
'for __builtin_alloca()' \
591 '#define HAVE_ALLOCA __builtin_alloca' << \
!
594 void
*vp
= __builtin_alloca
(1);
600 if nwantfeat NOGETOPT
; then
601 link_check getopt
'for getopt()' '#define HAVE_GETOPT' << \
!
603 int main
(int argc
, char
**argv
)
605 #if defined __GLIBC__ || defined __linux__
606 Argument and option reordering is not a desired feature.
608 getopt
(argc
, argv
, "oPt");
610 return (((long
)optarg
+ optind
) & 0x7F);
617 if wantfeat ICONV
; then
618 ${cat} > ${tmp2}.c
<< \
!
624 id
= iconv_open
("foo", "bar");
628 < ${tmp2}.c link_check
iconv 'for iconv functionality' \
629 '#define HAVE_ICONV' ||
630 < ${tmp2}.c link_check
iconv \
631 'for iconv functionality in libiconv' \
632 '#define HAVE_ICONV' '-liconv'
634 echo '/* WANT_ICONV=0 */' >> ${h}
637 if wantfeat SOCKETS
; then
638 compile_check arpa_inet_h
'for <arpa/inet.h>' \
639 '#define HAVE_ARPA_INET_H' << \
!
641 #include <sys/types.h>
642 #include <sys/socket.h>
644 #include <netinet/in.h>
645 #include <arpa/inet.h>
648 ${cat} > ${tmp2}.c
<< \
!
650 #include <sys/types.h>
651 #include <sys/socket.h>
653 #include <netinet/in.h>
654 #ifdef HAVE_ARPA_INET_H
655 #include <arpa/inet.h>
661 socket
(AF_INET
, SOCK_STREAM
, 0);
663 gethostbyname
("foo");
668 < ${tmp2}.c link_check sockets
'for sockets in libc' \
669 '#define HAVE_SOCKETS' ||
670 < ${tmp2}.c link_check sockets
'for sockets in libnsl' \
671 '#define HAVE_SOCKETS' '-lnsl' ||
672 < ${tmp2}.c link_check sockets \
673 'for sockets in libsocket and libnsl' \
674 '#define HAVE_SOCKETS' '-lsocket -lnsl' ||
677 # XXX Shouldn't it be a hard error if there is no socket support, then?
680 echo '/* WANT_SOCKETS=0 */' >> ${h}
681 fi # wantfeat SOCKETS
684 link_check setsockopt
'for setsockopt()' '#define HAVE_SETSOCKOPT' << \
!
685 #include <sys/socket.h>
690 setsockopt
(sockfd
, SOL_SOCKET
, SO_KEEPALIVE
, NULL
, 0);
695 wantfeat SOCKETS
&& [ -n "${have_setsockopt}" ] &&
696 link_check so_sndtimeo
'for SO_SNDTIMEO' '#define HAVE_SO_SNDTIMEO' << \
!
697 #include <sys/socket.h>
705 setsockopt
(sockfd
, SOL_SOCKET
, SO_SNDTIMEO
, &tv
, sizeof tv
);
706 setsockopt
(sockfd
, SOL_SOCKET
, SO_RCVTIMEO
, &tv
, sizeof tv
);
711 wantfeat SOCKETS
&& [ -n "${have_setsockopt}" ] &&
712 link_check so_linger
'for SO_LINGER' '#define HAVE_SO_LINGER' << \
!
713 #include <sys/socket.h>
721 setsockopt
(sockfd
, SOL_SOCKET
, SO_LINGER
, &li
, sizeof li
);
726 if wantfeat IPV6
; then
727 link_check ipv6
'for IPv6 functionality' '#define HAVE_IPV6' << \
!
729 #include <sys/types.h>
730 #include <sys/socket.h>
732 #include <netinet/in.h>
733 #ifdef HAVE_ARPA_INET_H
734 #include <arpa/inet.h>
739 struct addrinfo a
, *ap
;
740 getaddrinfo
("foo", "0", &a
, &ap
);
745 echo '/* WANT_IPV6=0 */' >> ${h}
748 if wantfeat IMAP
; then
749 echo '#define HAVE_IMAP' >> ${h}
751 echo '/* WANT_IMAP=0 */' >> ${h}
754 if wantfeat POP3
; then
755 echo '#define HAVE_POP3' >> ${h}
757 echo '/* WANT_POP3=0 */' >> ${h}
760 if wantfeat SMTP
; then
761 echo '#define HAVE_SMTP' >> ${h}
763 echo '/* WANT_SMTP=0 */' >> ${h}
766 if wantfeat SSL
; then
767 link_check openssl
'for sufficiently recent OpenSSL' \
769 #define HAVE_OPENSSL' '-lssl -lcrypto' << \
!
770 #include <openssl/ssl.h>
771 #include <openssl/err.h>
772 #include <openssl/x509v3.h>
773 #include <openssl/x509.h>
774 #include <openssl/rand.h>
776 #if defined OPENSSL_NO_SSL2 && defined OPENSSL_NO_SSL3 &&\
777 defined OPENSSL_NO_TLS1
778 # error We need one of (SSLv2 and) SSLv3 and TLS1.
783 SSLv23_client_method
();
784 #ifndef OPENSSL_NO_SSL3
785 SSLv3_client_method
();
787 #ifndef OPENSSL_NO_TLS1
788 TLSv1_client_method
();
789 # ifdef TLS1_1_VERSION
790 TLSv1_1_client_method
();
792 # ifdef TLS1_2_VERSION
793 TLSv1_2_client_method
();
796 PEM_read_PrivateKey
(0, 0, 0, 0);
801 if [ "${have_openssl}" = 'yes' ]; then
802 compile_check stack_of
'for OpenSSL STACK_OF()' \
803 '#define HAVE_STACK_OF' << \
!
804 #include <openssl/ssl.h>
805 #include <openssl/err.h>
806 #include <openssl/x509v3.h>
807 #include <openssl/x509.h>
808 #include <openssl/rand.h>
812 STACK_OF
(GENERAL_NAME
) *gens
= NULL
;
813 printf("%p", gens
); /* to
make it used
*/
818 run_check openssl_md5
'for MD5 digest in OpenSSL' \
819 '#define HAVE_OPENSSL_MD5' << \
!
821 #include <openssl/md5.h>
825 char const dat
[] = "abrakadabrafidibus";
826 char
dig[16], hex
[16 * 2];
830 memset
(dig, 0, sizeof
(dig));
831 memset
(hex
, 0, sizeof
(hex
));
833 MD5_Update
(&ctx
, dat
, sizeof
(dat
) - 1);
834 MD5_Final
(dig, &ctx
);
836 #define hexchar(n) ((n)>9 ? (n)-10+'a' : (n)+'0')
837 for (i
= 0; i
< sizeof
(hex
) / 2; i
++) {
839 hex[j] = hexchar((dig[i] & 0xf0) >> 4);
840 hex[++j] = hexchar(dig[i] & 0x0f);
842 return !!memcmp("6d7d0a3d949da2e96f2aa010f65d8326", hex, sizeof(hex));
848 echo '/* WANT_SSL=0 */' >> ${h}
851 if wantfeat GSSAPI; then
852 ${cat} > ${tmp2}.c << \!
853 #include <gssapi/gssapi.h>
857 gss_import_name(0, 0, GSS_C_NT_HOSTBASED_SERVICE, 0);
858 gss_init_sec_context(0,0,0,0,0,0,0,0,0,0,0,0,0);
862 ${sed} -e '1s/gssapi\///' < ${tmp2}.c > ${tmp3}.c
864 if command -v krb5-config >/dev/null 2>&1; then
865 i
=`command -v krb5-config`
866 GSSAPI_LIBS
="`CFLAGS= ${i} --libs gssapi`"
867 GSSAPI_INCS
="`CFLAGS= ${i} --cflags`"
868 i
='for GSSAPI via krb5-config(1)'
870 GSSAPI_LIBS
='-lgssapi'
872 i
='for GSSAPI in gssapi/gssapi.h, libgssapi'
874 < ${tmp2}.c link_check gssapi \
875 "${i}" '#define HAVE_GSSAPI' \
876 "${GSSAPI_LIBS}" "${GSSAPI_INCS}" ||\
877 < ${tmp3}.c link_check gssapi \
878 'for GSSAPI in gssapi.h, libgssapi' \
880 #define GSSAPI_REG_INCLUDE' \
882 < ${tmp2}.c link_check gssapi
'for GSSAPI in libgssapi_krb5' \
883 '#define HAVE_GSSAPI' \
885 < ${tmp3}.c link_check gssapi \
886 'for GSSAPI in libgssapi, OpenBSD-style (pre 5.3)' \
888 #define GSSAPI_REG_INCLUDE' \
889 '-lgssapi -lkrb5 -lcrypto' \
890 '-I/usr/include/kerberosV' ||\
891 < ${tmp2}.c link_check gssapi
'for GSSAPI in libgss' \
892 '#define HAVE_GSSAPI' \
894 link_check gssapi
'for GSSAPI in libgssapi_krb5, old-style' \
896 #define GSSAPI_OLD_STYLE' \
897 '-lgssapi_krb5' << \
!
898 #include <gssapi/gssapi.h>
899 #include <gssapi/gssapi_generic.h>
903 gss_import_name
(0, 0, gss_nt_service_name
, 0);
904 gss_init_sec_context
(0,0,0,0,0,0,0,0,0,0,0,0,0);
909 echo '/* WANT_GSSAPI=0 */' >> ${h}
912 if wantfeat IDNA
; then
913 link_check idna
'for GNU Libidn' '#define HAVE_IDNA' '-lidn' << \
!
915 #include <stringprep.h>
918 char
*utf8
, *idna_ascii
, *idna_utf8
;
919 utf8
= stringprep_locale_to_utf8
("does.this.work");
920 if (idna_to_ascii_8z
(utf8
, &idna_ascii
, IDNA_USE_STD3_ASCII_RULES
)
923 /* (Rather link check only here
) */
924 idna_utf8
= stringprep_convert
(idna_ascii
, "UTF-8", "de_DE");
929 echo '/* WANT_IDNA=0 */' >> ${h}
932 if wantfeat REGEX
; then
933 link_check regex
'for regular expressions' '#define HAVE_REGEX' << \
!
940 if (regcomp
(&re
, ".*bsd", REG_EXTENDED | REG_ICASE | REG_NOSUB
) != 0)
942 status
= regexec
(&re
, "plan9", 0,NULL
, 0);
944 return !(status
== REG_NOMATCH
);
948 echo '/* WANT_REGEX=0 */' >> ${h}
951 if wantfeat READLINE
; then
953 link_check readline
"for readline(3) (${1})" \
954 '#define HAVE_READLINE' "${1}" << \
!
956 #include <readline/history.h>
957 #include <readline/readline.h>
964 rl
= readline
("Enter a line:");
968 rl_extend_line_buffer
(10);
969 rl_point
= rl_end
= 10;
970 rl_pre_input_hook
= (rl_hook_func_t
*)NULL
;
971 rl_forced_update_display
();
973 rl_free_line_state
();
974 rl_cleanup_after_signal
();
975 rl_reset_after_signal
();
981 __edrdlib
-lreadline ||
982 __edrdlib
'-lreadline -ltermcap'
983 [ -n "${have_readline}" ] && WANT_TABEXPAND
=1
986 if wantfeat EDITLINE
&& [ -z "${have_readline}" ]; then
988 link_check editline
"for editline(3) (${1})" \
989 '#define HAVE_EDITLINE' "${1}" << \
!
990 #include <histedit.h>
991 static char
* getprompt
(void
) { return (char
*)"ok"; }
995 EditLine
*el_el
= el_init
("TEST", stdin
, stdout
, stderr
);
996 History
*el_hcom
= history_init
();
997 history(el_hcom
, &he
, H_SETSIZE
, 242);
998 el_set
(el_el
, EL_SIGNAL
, 0);
999 el_set
(el_el
, EL_TERMINAL
, NULL
);
1000 el_set
(el_el
, EL_HIST
, &history, el_hcom
);
1001 el_set
(el_el
, EL_EDITOR
, "emacs");
1002 el_set
(el_el
, EL_PROMPT
, &getprompt
);
1003 el_source
(el_el
, NULL
);
1005 /* TODO add loader and addfn checks
*/
1006 history_end
(el_hcom
);
1013 __edlib
'-ledit -ltermcap'
1014 [ -n "${have_editline}" ] && WANT_TABEXPAND
=0
1017 if wantfeat NCL
&& [ -z "${have_editline}" ] && [ -z "${have_readline}" ] &&\
1018 [ -n "${have_c90amend1}" ]; then
1020 echo '#define HAVE_NCL' >> ${h}
1022 echo '/* WANT_{READLINE,EDITLINE,NCL}=0 */' >> ${h}
1025 if [ -n "${have_ncl}" ] ||
[ -n "${have_editline}" ] ||\
1026 [ -n "${have_readline}" ]; then
1030 if [ -n "${have_cle}" ] && wantfeat TABEXPAND
; then
1031 echo '#define HAVE_TABEXPAND' >> ${h}
1033 echo '/* WANT_TABEXPAND=0 */' >> ${h}
1036 if [ -n "${have_cle}" ] && wantfeat HISTORY
; then
1037 echo '#define HAVE_HISTORY' >> ${h}
1039 echo '/* WANT_HISTORY=0 */' >> ${h}
1042 if wantfeat QUOTE_FOLD
&&\
1043 [ -n "${have_c90amend1}" ] && [ -n "${have_wcwidth}" ]; then
1044 echo '#define HAVE_QUOTE_FOLD' >> ${h}
1046 echo '/* WANT_QUOTE_FOLD=0 */' >> ${h}
1049 if wantfeat DOCSTRINGS
; then
1050 echo '#define HAVE_DOCSTRINGS' >> ${h}
1052 echo '/* WANT_DOCSTRINGS=0 */' >> ${h}
1055 if wantfeat SPAM
; then
1056 echo '#define HAVE_SPAM' >> ${h}
1057 if command -v spamc
>/dev
/null
2>&1; then
1058 echo "#define SPAMC_PATH \"`command -v spamc`\"" >> ${h}
1061 echo '/* WANT_SPAM=0 */' >> ${h}
1064 if wantfeat MD5
; then
1065 echo '#define HAVE_MD5' >> ${h}
1067 echo '/* WANT_MD5=0 */' >> ${h}
1072 # Since we cat(1) the content of those to cc/"ld", convert them to single line
1074 < "${1}" > "${2}" ${awk} \
1075 'BEGIN {ORS = " "} /^[^#]/ {print} {next} END {ORS = ""; print "\n"}'
1078 squeeze_em ${inc} ${tmp}
1080 squeeze_em ${lib} ${tmp}
1085 printf '#ifndef _CONFIG_H\n# define _CONFIG_H\n' > ${h}
1086 ${cat} ${tmp} >> ${h}
1088 printf '\n/* The "feature string
", for "simplicity
" and lex.c */\n' >> ${h}
1089 printf '#ifdef _MAIN_SOURCE\n' >> ${h}
1090 printf '# ifdef HAVE_AMALGAMATION\nstatic\n# endif\n' >> ${h}
1091 printf 'char const features[] = "MIME
"\n' >> ${h}
1092 printf '# ifdef HAVE_DOCSTRINGS\n ",DOCSTRINGS
"\n# endif\n' >> ${h}
1093 printf '# ifdef HAVE_ICONV\n ",ICONV
"\n# endif\n' >> ${h}
1094 printf '# ifdef HAVE_SETLOCALE\n ",LOCALES
"\n# endif\n' >> ${h}
1095 printf '# ifdef HAVE_C90AMEND1\n ",MULTIBYTE CHARSETS
"\n# endif\n' >> ${h}
1096 printf '# ifdef HAVE_NL_LANGINFO\n ",TERMINAL CHARSET
"\n# endif\n' >> ${h}
1097 printf '# ifdef HAVE_SOCKETS\n ",NETWORK
"\n# endif\n' >> ${h}
1098 printf '# ifdef HAVE_IPV6\n ",IPv6
"\n# endif\n' >> ${h}
1099 printf '# ifdef HAVE_SSL\n ",S
/MIME
,SSL
/TSL
"\n# endif\n' >> ${h}
1100 printf '# ifdef HAVE_IMAP\n ",IMAP
"\n# endif\n' >> ${h}
1101 printf '# ifdef HAVE_GSSAPI\n ",GSSAPI
"\n# endif\n' >> ${h}
1102 printf '# ifdef HAVE_POP3\n ",POP3
"\n# endif\n' >> ${h}
1103 printf '# ifdef HAVE_SMTP\n ",SMTP
"\n# endif\n' >> ${h}
1104 printf '# ifdef HAVE_SPAM\n ",SPAM
"\n# endif\n' >> ${h}
1105 printf '# ifdef HAVE_IDNA\n ",IDNA
"\n# endif\n' >> ${h}
1106 printf '# ifdef HAVE_REGEX\n ",REGEX
"\n# endif\n' >> ${h}
1107 printf '# ifdef HAVE_READLINE\n ",READLINE
"\n# endif\n' >> ${h}
1108 printf '# ifdef HAVE_EDITLINE\n ",EDITLINE
"\n# endif\n' >> ${h}
1109 printf '# ifdef HAVE_NCL\n ",NCL
"\n# endif\n' >> ${h}
1110 printf '# ifdef HAVE_TABEXPAND\n ",TABEXPAND
"\n# endif\n' >> ${h}
1111 printf '# ifdef HAVE_HISTORY\n ",HISTORY MANAGEMENT
"\n# endif\n' >> ${h}
1112 printf '# ifdef HAVE_QUOTE_FOLD\n ",QUOTE-FOLD
"\n# endif\n' >> ${h}
1113 printf '# ifdef HAVE_DEBUG\n ",DEBUG
"\n# endif\n' >> ${h}
1114 printf ';\n#endif /* _MAIN_SOURCE */\n' >> ${h}
1116 printf '#endif /* _CONFIG_H */\n' >> ${h}
1119 # Create the real mk.mk
1120 ${rm} -rf ${tmp0}.* ${tmp0}*
1121 printf 'OBJ_SRC = ' >> ${mk}
1122 if nwantfeat AMALGAMATION; then
1124 echo 'OBJ_DEP =' >> ${mk}
1126 j=`echo "${src}" | sed 's/^.\///'`
1127 echo "${j}" >> ${mk}
1128 printf 'OBJ_DEP = main.c ' >> ${mk}
1129 printf '#define _MAIN_SOURCE\n' >> ${src}
1130 printf '#include "nail.h
"\n#include "main.c
"\n' >> ${src}
1132 if [ "${i}" = "${j}" ] || [ "${i}" = main.c ]; then
1135 printf "${i} " >> ${mk}
1136 printf "#include \"${i}\"\n" >> ${src}
1141 echo "LIBS = `${cat} ${lib}`" >> ${mk}
1142 echo "INCLUDES
= `${cat} ${inc}`" >> ${mk}
1144 ${cat} ./mk-mk.in >> ${mk}
1148 ${cat} > ${tmp2}.c << \!
1150 #ifdef HAVE_NL_LANGINFO
1151 # include <langinfo.h>
1154 :The following optional features are enabled:
1156 : + Character set conversion using iconv()
1158 #ifdef HAVE_SETLOCALE
1159 : + Locale support: Printable characters depend on the environment
1160 # ifdef HAVE_C90AMEND1
1161 : + Multibyte character support
1163 # ifdef HAVE_NL_LANGINFO
1164 : + Automatic detection of terminal character set
1171 : + Support for Internet Protocol v6 (IPv6)
1174 # ifdef HAVE_OPENSSL
1175 : + S/MIME and SSL/TLS using OpenSSL
1182 : + IMAP GSSAPI authentication
1191 : + Interaction with spam filters
1194 : + IDNA (internationalized domain names for applications) support
1197 : + Regular expression searches
1199 #if defined HAVE_READLINE || defined HAVE_EDITLINE || defined HAVE_NCL
1200 : + Command line editing
1201 # ifdef HAVE_TABEXPAND
1202 : + + Tabulator expansion
1204 # ifdef HAVE_HISTORY
1205 : + + History management
1208 #ifdef HAVE_QUOTE_FOLD
1209 : + Extended *quote-fold*ing
1212 :The following optional features are disabled:
1214 : - Character set conversion using iconv()
1216 #ifndef HAVE_SETLOCALE
1217 : - Locale support: Only ASCII characters are recognized
1219 # ifndef HAVE_C90AMEND1
1220 : - Multibyte character support
1222 # ifndef HAVE_NL_LANGINFO
1223 : - Automatic detection of terminal character set
1225 #ifndef HAVE_SOCKETS
1229 : - Support for Internet Protocol v6 (IPv6)
1231 #if !defined HAVE_SSL
1232 : - SSL/TLS (network transport authentication and encryption)
1238 : - IMAP GSSAPI authentication
1247 : - Interaction with spam filters
1250 : - IDNA (internationalized domain names for applications) support
1253 : - Regular expression searches
1255 #if !defined HAVE_READLINE && !defined HAVE_EDITLINE && !defined HAVE_NCL
1256 : - Command line editing and history
1258 #ifndef HAVE_QUOTE_FOLD
1259 : - Extended *quote-fold*ing
1263 #ifndef HAVE_SNPRINTF
1264 : . The function snprintf() could not be found. mailx will be compiled to use
1265 : sprintf() instead. This might overflow buffers if input values are larger
1266 : than expected. Use the resulting binary with care or update your system
1267 : environment and start the configuration process again.
1270 : . The function fchdir() could not be found. mailx will be compiled to use
1271 : chdir() instead. This is not a problem unless the current working
1272 : directory of mailx is moved while the IMAP cache is used.
1275 : . Using a minimal builtin POSIX-like getopt()
1278 : . Debug enabled binary: not meant to be used by end-users: THANKS!
1283 ${make} -f ${makefile} ${tmp2}.x
1284 < ${tmp2}.x >&5 ${sed} -e '/^[^:]/d; /^$/d; s/^://'
1286 # vim:set fenc=utf-8:s-it-mode