#!/bin/sh # # Sccsid @(#)makeconfig 1.40 (gritter) 11/17/04 # tmp=___build$$ tmp2=___tmp$$ out=config.h log=config.log lib=LIBS make="${MAKE-make}" exec 5>&2 >$log 2>&1 rm -f $out $lib echo "\ /* * Auto-generated by $0. * Changes are lost when $0 is run again. */ " >$out echo " # Auto-generated by $0. # Changes are lost when $0 is run again. # # need one non-empty line # to make grep happy ">$lib trap "rm -f $out $lib; exit" 1 2 15 trap "rm -f $tmp.? $tmp $tmp2.? $tmp2" 0 msg() { fmt=$1 shift printf "*** $fmt\\n" "$@" printf "$fmt" "$@" >&5 } compile_check() { topic=$1 define=$2 echo '************************************************************' msg "checking $topic ... " echo "/* checked $topic */" >>$out rm -f $tmp.o echo '*** test program is' tee $tmp.c #echo '*** the preprocessor generates' #$make $tmp.x #cat $tmp.x echo '*** results are' if $make $tmp.o && test -f $tmp.o then msg "okay\\n" echo "$define" >>$out return 0 else echo "/* $define */" >>$out msg "no\\n" return 1 fi } link_check() { topic=$1 define=$2 libs=$3 echo '************************************************************' msg "checking $topic ... " echo "/* checked $topic */" >>$out cp $lib $tmp2 rm -f $tmp $tmp.o echo '*** test program is' tee $tmp.c #echo '*** the preprocessor generates' #$make $tmp.x #cat $tmp.x echo '*** results are' if $make $tmp LIBS="$LIBS $libs" && test -f $tmp then msg "okay\\n" echo "$define" >>$out echo "$libs" >$lib cat $tmp2 >>$lib return 0 else msg "no\\n" echo "/* $define */" >>$out return 1 fi } link_check 'if a hello world program can be built' <<\! || { \ echo 'This problem is most certainly not specific to this software.' >&5; \ echo "Read the file '$log' and check your compiler installation." >&5; \ rm $out; exit 1; \ } #include int main(int argc, char *argv[]) { puts("hello world"); return 0; } ! compile_check 'for ' '#define HAVE_ALLOCA_H' <<\! #include ! link_check 'for alloca()' '#define HAVE_ALLOCA' <<\! #include "rcv.h" int main(void) { alloca(1); return 0; } ! compile_check 'for ssize_t' '#define HAVE_SSIZE_T' <<\! #include #include int main(void) { ssize_t i = 3; write(1, "foo", i); return 0; } ! link_check 'for snprintf()' '#define HAVE_SNPRINTF' <<\! #include int main(void) { char b[20]; snprintf(b, sizeof b, "%s", "string"); return 0; } ! link_check 'for fchdir()' '#define HAVE_FCHDIR' <<\! #include int main(void) { fchdir(0); return 0; } ! link_check 'for mmap()' '#define HAVE_MMAP' <<\! #include #include int main(void) { mmap(0, 0, 0, 0, 0, 0); return 0; } ! link_check 'for mremap()' '#define HAVE_MREMAP' <<\! #include #include int main(void) { mremap(0, 0, 0, MREMAP_MAYMOVE); return 0; } ! cat >$tmp2.c <<\! #include int main(void) { iconv_t id; id = iconv_open("foo", "bar"); return 0; } ! <$tmp2.c link_check 'for iconv functionality' '#define HAVE_ICONV' || <$tmp2.c link_check 'for iconv functionality in libiconv' \ '#define HAVE_ICONV' '-liconv' link_check 'for wctype functionality' '#define HAVE_WCTYPE_H' <<\! #include int main(void) { iswprint(L'c'); towupper(L'c'); return 0; } ! link_check 'for wcwidth() ' '#define HAVE_WCWIDTH' <<\! #include int main(void) { wcwidth(L'c'); return 0; } ! link_check 'for mbtowc()' '#define HAVE_MBTOWC' <<\! #include int main(void) { wchar_t wc; mbtowc(&wc, "x", 1); return 0; } ! link_check 'for setlocale()' '#define HAVE_SETLOCALE' <<\! #include int main(void) { setlocale(LC_ALL, ""); return 0; } ! link_check 'for nl_langinfo()' '#define HAVE_NL_LANGINFO' <<\! #include int main(void) { nl_langinfo(DAY_1); return 0; } ! link_check 'for mkstemp()' '#define HAVE_MKSTEMP' <<\! #include int main(void) { mkstemp("x"); return 0; } ! link_check 'for fpathconf()' '#define HAVE_FPATHCONF' <<\! #include int main(void) { fpathconf(0, _PC_PATH_MAX); return 0; } ! link_check 'for wordexp()' '#define HAVE_WORDEXP' <<\! #include int main(void) { wordexp((char *)0, (wordexp_t *)0, 0); return 0; } ! compile_check 'for ' '#define HAVE_ARPA_INET_H' <<\! #include "config.h" #include #include #include #include #include ! cat >$tmp2.c <<\! #include "config.h" #include #include #include #include #ifdef HAVE_ARPA_INET_H #include #endif /* HAVE_ARPA_INET_H */ int main(void) { struct sockaddr s; socket(AF_INET, SOCK_STREAM, 0); connect(0, &s, 0); gethostbyname("foo"); return 0; } ! <$tmp2.c link_check 'for socket functionality in libc' \ '#define HAVE_SOCKETS' || <$tmp2.c link_check 'for socket functionality in libnsl' \ '#define HAVE_SOCKETS' '-lnsl' || <$tmp2.c link_check \ 'for socket functionality in libsocket and libnsl' \ '#define HAVE_SOCKETS' '-lsocket -lnsl' #link_check 'for IPv6 functionality' '#define HAVE_IPv6_FUNCS' <<\! ##include "config.h" ##include ##include ##include ##include ##ifdef HAVE_ARPA_INET_H ##include ##endif /* HAVE_ARPA_INET_H */ # #int main(void) #{ # struct addrinfo a, *ap; # getaddrinfo("foo", "0", &a, &ap); # return 0; #} #! link_check 'for Network Security Services (NSS)' '#define USE_SSL #define USE_NSS' '-lsmime3 -lnss3 -lssl3 -lnspr4 -lplc4' <<\! || \ link_check 'for sufficiently recent OpenSSL' '#define USE_SSL #define USE_OPENSSL' '-lssl -lcrypto' <<\% #include #include #include #include #include #include #include #include #include #include #include int main(void) { PR_ImportTCPSocket(0); NSS_CMSSignerInfo_AddSMIMECaps(0); return 0; } ! #include #include #include #include #include int main(void) { SSLv23_client_method(); PEM_read_PrivateKey(0, 0, 0, 0); return 0; } % cat >$tmp2.c <<\! #include int main(void) { gss_import_name(0, 0, GSS_C_NT_HOSTBASED_SERVICE, 0); gss_init_sec_context(0,0,0,0,0,0,0,0,0,0,0,0,0); return 0; } ! <$tmp2.c link_check 'for GSSAPI in libgss' '#define USE_GSSAPI' '-lgss' || <$tmp2.c link_check 'for GSSAPI in libgssapi_krb5' \ '#define USE_GSSAPI' '-lgssapi_krb5' || link_check 'for GSSAPI in libgssapi_krb5, old-style' \ '#define USE_GSSAPI #define GSSAPI_OLD_STYLE' '-lgssapi_krb5' <<\! || \ link_check 'for GSSAPI in libgssapi' \ '#define USE_GSSAPI #define GSSAPI_REG_INCLUDE' '-lgssapi' <<\% #include #include int main(void) { gss_import_name(0, 0, gss_nt_service_name, 0); gss_init_sec_context(0,0,0,0,0,0,0,0,0,0,0,0,0); return 0; } ! #include int main(void) { gss_import_name(0, 0, GSS_C_NT_HOSTBASED_SERVICE, 0); gss_init_sec_context(0,0,0,0,0,0,0,0,0,0,0,0,0); return 0; } % cat >$tmp2.c <<\! #include "config.h" #ifdef HAVE_NL_LANGINFO #include #endif : :The following optional features are enabled: #ifdef HAVE_SETLOCALE : + Locale support: Printable characters depend on the environment #if defined (HAVE_MBTOWC) && defined (HAVE_WCTYPE_H) : + Multibyte character support #endif #endif /* HAVE_SETLOCALE */ #ifdef HAVE_ICONV : + Character set conversion using iconv() #endif #if defined (HAVE_SETLOCALE) && defined (HAVE_NL_LANGINFO) && defined (CODESET) : + Automatic detection of terminal character set #endif #ifdef HAVE_SOCKETS : + Networking support (IMAP, POP3, and SMTP) #endif #ifdef USE_GSSAPI : + IMAP GSSAPI authentication #endif #if defined (USE_NSS) : + S/MIME and SSL/TLS using Network Security Services (NSS) #endif #if defined (USE_OPENSSL) : + S/MIME and SSL/TLS using OpenSSL #endif : :The following optional features are disabled: #ifndef HAVE_SETLOCALE : - Locale support: Only ASCII characters are recognized #endif #if !defined (HAVE_SETLOCALE) || !defined (HAVE_MBTOWC) || \ !defined (HAVE_WCTYPE_H) : - Multibyte character support #endif #ifndef HAVE_ICONV : - Character set conversion using iconv() #endif #if !defined (HAVE_SETLOCALE) || !defined (HAVE_NL_LANGINFO) || \ !defined (CODESET) : - Automatic detection of terminal character set #endif #ifndef HAVE_SOCKETS : - Networking support (IMAP, POP3, and SMTP) #endif #ifndef USE_GSSAPI : - IMAP GSSAPI authentication #endif #ifndef USE_SSL : - SSL/TLS (network transport authentication and encryption) #endif : :Remarks: #ifndef HAVE_SNPRINTF : * The function snprintf() could not be found. nail will be compiled to use : sprintf() instead. This might overflow buffers if input values are larger : than expected. Use the resulting binary with care or update your system : environment and start the configuration process again. #endif #ifndef HAVE_FCHDIR : * The function fchdir() could not be found. nail will be compiled to use : chdir() instead. This is not a problem unless nail's current working : directory is moved while the IMAP cache is used. #endif : ! (hash cc) && cc -E $tmp2.c | sed '/^[^:]/d; /^$/d; s/^://' >&5 exit 0