strings.c: fix compiler warnings
[s-mailx.git] / makeconfig
blob84fc749f57dc27970a15766dfa4c110efc1afd66
1 #!/bin/sh
4 # Sccsid @(#)makeconfig 1.44 (gritter) 5/26/09
7 if [ -z "${CONFIG}" ]; then
8 [ -f user.conf ] && . user.conf
9 else
10 case ${CONFIG} in
11 MINIMAL)
12 WANT_JUNK=0 WANT_SOCKET=0
14 NETLESS)
15 WANT_SOCKET=0
17 NETSEND)
18 WANT_JUNK=0 WANT_IMAP=0 WANT_POP3=0
21 echo >&2 "Unknown CONFIG= setting: ${CONFIG}"
22 echo >&2 'Possible values: MINIMAL, NETLESS, NETSEND'
23 exit 1
24 esac
27 wantfeat() {
28 local i
29 eval i=\$WANT_${1}
30 [ -z "${i}" ] && return 0
31 [ "${i}" = "0" ] && return 1
32 return 0
35 if ! wantfeat IMAP && ! wantfeat POP3 && ! wantfeat SMTP; then
36 WANT_SOCKET=0
37 WANT_SSL=0
39 if ! wantfeat IMAP; then
40 WANT_GSSAPI=0
43 tmp=___build$$
44 tmp2=___tmp1$$
45 tmp3=___tmp2$$
46 out=config.h
47 log=config.log
48 lib=LIBS
49 inc=INCS
51 make="${MAKE-make}"
53 exec 5>&2 >$log 2>&1
55 rm -f $out $lib $inc
56 echo "\
58 * Auto-generated by $0.
59 * Changes are lost when $0 is run again.
61 " >$out
62 echo "
63 # Auto-generated by $0.
64 # Changes are lost when $0 is run again.
66 # need one non-empty line
68 # to make grep happy
69 ">$lib
70 echo "
71 # Auto-generated by $0.
72 # Changes are lost when $0 is run again.
74 # need one non-empty line
76 # to make grep happy
77 ">$inc
79 trap "rm -f $out $lib $inc; exit" 1 2 15
80 trap "rm -f $tmp.? $tmp $tmp2.? $tmp2 $tmp3.? $tmp3" 0
82 msg() {
83 fmt=$1
84 shift
85 printf "*** $fmt\\n" "$@"
86 printf "$fmt" "$@" >&5
89 compile_check() {
90 variable=$1
91 topic=$2
92 define=$3
94 echo '************************************************************'
95 msg "checking $topic ... "
96 echo "/* checked $topic */" >>$out
97 rm -f $tmp.o
98 echo '*** test program is'
99 tee $tmp.c
100 #echo '*** the preprocessor generates'
101 #$make $tmp.x
102 #cat $tmp.x
103 echo '*** results are'
104 if $make $tmp.o && test -f $tmp.o
105 then
106 msg "okay\\n"
107 echo "$define" >>$out
108 eval have_$variable=yes
109 return 0
110 else
111 echo "/* $define */" >>$out
112 msg "no\\n"
113 eval unset have_$variable
114 return 1
118 link_check() {
119 variable=$1
120 topic=$2
121 define=$3
122 libs=$4
123 incs=$5
125 echo '************************************************************'
126 msg "checking $topic ... "
127 echo "/* checked $topic */" >>$out
128 rm -f $tmp $tmp.o
129 echo '*** test program is'
130 tee $tmp.c
131 #echo '*** the preprocessor generates'
132 #$make $tmp.x
133 #cat $tmp.x
134 echo '*** results are'
135 if $make $tmp INCLUDES="$INCLUDES $incs" LIBS="$LIBS $libs" &&
136 test -f $tmp
137 then
138 msg "okay\\n"
139 echo "$define" >>$out
140 cp $lib $tmp2
141 echo "$libs" >$lib
142 cat $tmp2 >>$lib
143 cp $inc $tmp2
144 echo "$incs" >$inc
145 cat $tmp2 >>$inc
146 eval have_$variable=yes
147 return 0
148 else
149 msg "no\\n"
150 echo "/* $define */" >>$out
151 eval unset have_$variable
152 return 1
156 link_check hello 'if a hello world program can be built' <<\! || { \
157 echo 'This problem is most certainly not specific to this software.' >&5; \
158 echo "Read the file '$log' and check your compiler installation." >&5; \
159 rm $out; exit 1; \
161 #include <stdio.h>
163 int main(int argc, char *argv[])
165 puts("hello world");
166 return 0;
170 compile_check alloca_h 'for <alloca.h>' '#define HAVE_ALLOCA_H' <<\!
171 #include <alloca.h>
174 link_check alloca 'for alloca()' '#define HAVE_ALLOCA' <<\!
175 #include "rcv.h"
176 int main(void)
178 alloca(1);
179 return 0;
183 compile_check ssize_t 'for ssize_t' '#define HAVE_SSIZE_T' <<\!
184 #include <sys/types.h>
185 #include <unistd.h>
186 int main(void)
188 ssize_t i = 3;
189 write(1, "foo", i);
190 return 0;
194 link_check snprintf 'for snprintf()' '#define HAVE_SNPRINTF' <<\!
195 #include <stdio.h>
196 int main(void)
198 char b[20];
199 snprintf(b, sizeof b, "%s", "string");
200 return 0;
204 link_check fchdir 'for fchdir()' '#define HAVE_FCHDIR' <<\!
205 #include <unistd.h>
206 int main(void)
208 fchdir(0);
209 return 0;
213 link_check mmap 'for mmap()' '#define HAVE_MMAP' <<\!
214 #include <sys/types.h>
215 #include <sys/mman.h>
216 int main(void)
218 mmap(0, 0, 0, 0, 0, 0);
219 return 0;
223 link_check mremap 'for mremap()' '#define HAVE_MREMAP' <<\!
224 #include <sys/types.h>
225 #include <sys/mman.h>
226 int main(void)
228 mremap(0, 0, 0, MREMAP_MAYMOVE);
229 return 0;
233 cat >$tmp2.c <<\!
234 #include <iconv.h>
235 int main(void)
237 iconv_t id;
239 id = iconv_open("foo", "bar");
240 return 0;
243 <$tmp2.c link_check iconv 'for iconv functionality' '#define HAVE_ICONV' ||
244 <$tmp2.c link_check iconv 'for iconv functionality in libiconv' \
245 '#define HAVE_ICONV' '-liconv'
247 link_check wctype 'for wctype functionality' '#define HAVE_WCTYPE_H' <<\!
248 #include <wctype.h>
249 int main(void)
251 iswprint(L'c');
252 towupper(L'c');
253 return 0;
257 link_check wcwidth 'for wcwidth() ' '#define HAVE_WCWIDTH' <<\!
258 #include <wchar.h>
259 int main(void)
261 wcwidth(L'c');
262 return 0;
266 link_check mbtowc 'for mbtowc()' '#define HAVE_MBTOWC' <<\!
267 #include <stdlib.h>
268 int main(void)
270 wchar_t wc;
271 mbtowc(&wc, "x", 1);
272 return 0;
276 link_check setlocale 'for setlocale()' '#define HAVE_SETLOCALE' <<\!
277 #include <locale.h>
278 int main(void)
280 setlocale(LC_ALL, "");
281 return 0;
285 link_check nl_langinfo 'for nl_langinfo()' '#define HAVE_NL_LANGINFO' <<\!
286 #include <langinfo.h>
287 int main(void)
289 nl_langinfo(DAY_1);
290 return 0;
294 link_check mkstemp 'for mkstemp()' '#define HAVE_MKSTEMP' <<\!
295 #include <stdlib.h>
296 int main(void)
298 mkstemp("x");
299 return 0;
303 link_check fpathconf 'for fpathconf()' '#define HAVE_FPATHCONF' <<\!
304 #include <unistd.h>
305 int main(void)
307 fpathconf(0, _PC_PATH_MAX);
308 return 0;
312 link_check wordexp 'for wordexp()' '#define HAVE_WORDEXP' <<\!
313 #include <wordexp.h>
314 int main(void)
316 wordexp((char *)0, (wordexp_t *)0, 0);
317 return 0;
321 ## user.conf added later, indentation not adjusted ##
323 if wantfeat SOCKET; then
325 compile_check arpa_inet_h 'for <arpa/inet.h>' '#define HAVE_ARPA_INET_H' <<\!
326 #include "config.h"
327 #include <sys/types.h>
328 #include <sys/socket.h>
329 #include <netdb.h>
330 #include <netinet/in.h>
331 #include <arpa/inet.h>
334 cat >$tmp2.c <<\!
335 #include "config.h"
336 #include <sys/types.h>
337 #include <sys/socket.h>
338 #include <netdb.h>
339 #include <netinet/in.h>
340 #ifdef HAVE_ARPA_INET_H
341 #include <arpa/inet.h>
342 #endif /* HAVE_ARPA_INET_H */
344 int main(void)
346 struct sockaddr s;
347 socket(AF_INET, SOCK_STREAM, 0);
348 connect(0, &s, 0);
349 gethostbyname("foo");
350 return 0;
354 WANT_SOCKET=1
355 <$tmp2.c link_check sockets 'for socket functionality in libc' \
356 '#define HAVE_SOCKETS' ||
357 <$tmp2.c link_check sockets 'for socket functionality in libnsl' \
358 '#define HAVE_SOCKETS' '-lnsl' ||
359 <$tmp2.c link_check sockets \
360 'for socket functionality in libsocket and libnsl' \
361 '#define HAVE_SOCKETS' '-lsocket -lnsl' ||
362 WANT_SOCKET=0
364 #link_check ipv6 'for IPv6 functionality' '#define HAVE_IPv6_FUNCS' <<\!
365 ##include "config.h"
366 ##include <sys/types.h>
367 ##include <sys/socket.h>
368 ##include <netdb.h>
369 ##include <netinet/in.h>
370 ##ifdef HAVE_ARPA_INET_H
371 ##include <arpa/inet.h>
372 ##endif /* HAVE_ARPA_INET_H */
374 #int main(void)
376 # struct addrinfo a, *ap;
377 # getaddrinfo("foo", "0", &a, &ap);
378 # return 0;
382 [ ${WANT_SOCKET} -eq 1 ] ||
383 WANT_IMAP=0 WANT_POP3=0 WANT_SMTP=0 WANT_SSL=0 WANT_GSSAPI=0
384 if wantfeat IMAP; then
385 echo "#define USE_IMAP" >> $out
386 else
387 echo "/* #define USE_IMAP */" >> $out
389 if wantfeat POP3; then
390 echo "#define USE_POP3" >>$out
391 else
392 echo "/* #define USE_POP3 */" >> $out
394 if wantfeat SMTP; then
395 echo "#define USE_SMTP" >>$out
396 else
397 echo "/* #define USE_SMTP */" >> $out
399 else
400 echo '/* Socket (IMAP/POP3/SMTP) support not configured */' >> $out
401 WANT_IMAP=0 WANT_POP3=0 WANT_SMTP=0 WANT_SSL=0 WANT_GSSAPI=0
402 fi # wantfeat SOCKET
403 if wantfeat SSL; then
405 link_check nss 'for Network Security Services (NSS)' '#define USE_SSL
406 #define USE_NSS' '-lsmime3 -lnss3 -lssl3 -lnspr4 -lplc4' <<\! || \
407 link_check openssl 'for sufficiently recent OpenSSL' \
408 '#define USE_SSL
409 #define USE_OPENSSL' '-lssl -lcrypto' <<\%
410 #include <nss.h>
411 #include <ssl.h>
412 #include <prinit.h>
413 #include <prmem.h>
414 #include <pk11func.h>
415 #include <prtypes.h>
416 #include <prerror.h>
417 #include <secerr.h>
418 #include <smime.h>
419 #include <ciferfam.h>
420 #include <private/pprio.h>
422 int main(void)
424 PR_ImportTCPSocket(0);
425 NSS_CMSSignerInfo_AddSMIMECaps(0);
426 return 0;
429 #include <openssl/ssl.h>
430 #include <openssl/err.h>
431 #include <openssl/x509v3.h>
432 #include <openssl/x509.h>
433 #include <openssl/rand.h>
435 int main(void)
437 SSLv23_client_method();
438 PEM_read_PrivateKey(0, 0, 0, 0);
439 return 0;
442 if test x$have_nss = xyes
443 then
444 compile_check genname_h 'for genname.h' '#define HAVE_GENNAME_H' <<\!
445 #include <genname.h>
447 compile_check xconst_h 'for xconst.h' '#define HAVE_XCONST_H' <<\!
448 #include <xconst.h>
450 compile_check CERTAltNameEncodedContext \
451 'for CERTAltNameEncodedContext type' \
452 '#define HAVE_CERTAltNameEncodedContext' <<\!
453 #include "config.h"
454 #include <nss.h>
455 #include <ssl.h>
456 #include <prinit.h>
457 #include <prmem.h>
458 #include <pk11func.h>
459 #include <prtypes.h>
460 #include <prerror.h>
461 #include <secerr.h>
462 #include <smime.h>
463 #include <ciferfam.h>
464 #ifdef HAVE_XCONST_H
465 #include <xconst.h>
466 #endif
467 #ifdef HAVE_GENNAME_H
468 #include <genname.h>
469 #endif
470 #include <private/pprio.h>
472 CERTAltNameEncodedContext foo;
476 if test x$have_openssl = xyes
477 then
478 compile_check stack_of 'for STACK_OF()' '#define HAVE_STACK_OF' <<\!
479 #include <openssl/ssl.h>
480 #include <openssl/err.h>
481 #include <openssl/x509v3.h>
482 #include <openssl/x509.h>
483 #include <openssl/rand.h>
485 int main(void)
487 STACK_OF(GENERAL_NAME) *gens = NULL;
488 printf("%p", gens); /* to make it used */
489 SSLv23_client_method();
490 PEM_read_PrivateKey(0, 0, 0, 0);
491 return 0;
496 else
497 echo '/* Socket/SSL support not configured */' >> $out
498 fi # wantfeat SSL
499 if wantfeat GSSAPI; then
501 cat >$tmp2.c <<\!
502 #include <gssapi/gssapi.h>
504 int main(void)
506 gss_import_name(0, 0, GSS_C_NT_HOSTBASED_SERVICE, 0);
507 gss_init_sec_context(0,0,0,0,0,0,0,0,0,0,0,0,0);
508 return 0;
512 sed -e '1s/gssapi\///' < $tmp2.c > $tmp3.c
514 <$tmp2.c link_check gssapi 'for GSSAPI in libgss' \
515 '#define USE_GSSAPI' '-lgss' ||
516 <$tmp2.c link_check gssapi 'for GSSAPI in libgssapi_krb5' \
517 '#define USE_GSSAPI' '-lgssapi_krb5' ||
518 link_check gssapi 'for GSSAPI in libgssapi_krb5, old-style' \
519 '#define USE_GSSAPI
520 #define GSSAPI_OLD_STYLE' '-lgssapi_krb5' <<\! || \
521 <$tmp3.c link_check gssapi 'for GSSAPI in libgssapi' \
522 '#define USE_GSSAPI
523 #define GSSAPI_REG_INCLUDE' '-lgssapi' || \
524 <$tmp3.c link_check gssapi \
525 'for GSSAPI in libgssapi, OpenBSD-style' \
526 '#define USE_GSSAPI
527 #define GSSAPI_REG_INCLUDE' \
528 '-lgssapi -lkrb5 -lcrypto' '-I/usr/include/kerberosV'
530 #include <gssapi/gssapi.h>
531 #include <gssapi/gssapi_generic.h>
533 int main(void)
535 gss_import_name(0, 0, gss_nt_service_name, 0);
536 gss_init_sec_context(0,0,0,0,0,0,0,0,0,0,0,0,0);
537 return 0;
541 else
542 echo '/* IMAP/GSSAPI support not configured */' >> $out
543 fi # wantfeat GSSAPI
545 if wantfeat JUNK; then
546 echo "#define USE_JUNK" >>$out
547 else
548 echo "/* #define USE_JUNK */" >> $out
551 cat >$tmp2.c <<\!
552 #include "config.h"
553 #ifdef HAVE_NL_LANGINFO
554 #include <langinfo.h>
555 #endif
557 :The following optional features are enabled:
558 #ifdef HAVE_SETLOCALE
559 : + Locale support: Printable characters depend on the environment
560 #if defined (HAVE_MBTOWC) && defined (HAVE_WCTYPE_H)
561 : + Multibyte character support
562 #endif
563 #endif /* HAVE_SETLOCALE */
564 #ifdef HAVE_ICONV
565 : + Character set conversion using iconv()
566 #endif
567 #if defined (HAVE_SETLOCALE) && defined (HAVE_NL_LANGINFO) && defined (CODESET)
568 : + Automatic detection of terminal character set
569 #endif
570 #ifdef HAVE_SOCKETS
571 # if defined USE_IMAP && defined USE_POP3 && defined USE_SMTP
572 : + Networking support (IMAP, POP3, and SMTP)
573 # else
574 # ifdef USE_IMAP
575 : + Networking support (IMAP)
576 # endif
577 # ifdef USE_POP3
578 : + Networking support (POP3)
579 # endif
580 # ifdef USE_SMTP
581 : + Networking support (SMTP)
582 # endif
583 # endif
584 #endif
585 #ifdef USE_GSSAPI
586 : + IMAP GSSAPI authentication
587 #endif
588 #if defined (USE_NSS)
589 : + S/MIME and SSL/TLS using Network Security Services (NSS)
590 #endif
591 #if defined (USE_OPENSSL)
592 : + S/MIME and SSL/TLS using OpenSSL
593 #endif
594 #ifdef USE_JUNK
595 : + Gunnar Ritter's junk-mail management
596 #endif
598 :The following optional features are disabled:
599 #ifndef HAVE_SETLOCALE
600 : - Locale support: Only ASCII characters are recognized
601 #endif
602 #if !defined (HAVE_SETLOCALE) || !defined (HAVE_MBTOWC) || \
603 !defined (HAVE_WCTYPE_H)
604 : - Multibyte character support
605 #endif
606 #ifndef HAVE_ICONV
607 : - Character set conversion using iconv()
608 #endif
609 #if !defined (HAVE_SETLOCALE) || !defined (HAVE_NL_LANGINFO) || \
610 !defined (CODESET)
611 : - Automatic detection of terminal character set
612 #endif
613 #ifndef HAVE_SOCKETS
614 : - Networking support (IMAP, POP3, and SMTP)
615 #else
616 # ifndef USE_IMAP
617 : - Networking support (IMAP)
618 # endif
619 # ifndef USE_POP3
620 : - Networking support (POP3)
621 # endif
622 # ifndef USE_SMTP
623 : - Networking support (SMTP)
624 # endif
625 #endif
626 #ifndef USE_GSSAPI
627 : - IMAP GSSAPI authentication
628 #endif
629 #ifndef USE_SSL
630 : - SSL/TLS (network transport authentication and encryption)
631 #endif
632 #ifndef USE_JUNK
633 : - Gunnar Ritter's junk-mail management
634 #endif
636 :Remarks:
637 #ifndef HAVE_SNPRINTF
638 : * The function snprintf() could not be found. mailx will be compiled to use
639 : sprintf() instead. This might overflow buffers if input values are larger
640 : than expected. Use the resulting binary with care or update your system
641 : environment and start the configuration process again.
642 #endif
643 #ifndef HAVE_FCHDIR
644 : * The function fchdir() could not be found. mailx will be compiled to use
645 : chdir() instead. This is not a problem unless the current working
646 : directory of mailx is moved while the IMAP cache is used.
647 #endif
651 (hash cc) && cc -E $tmp2.c | sed '/^[^:]/d; /^$/d; s/^://' >&5
653 exit 0