-
Notifications
You must be signed in to change notification settings - Fork 2
/
makeconfig
531 lines (481 loc) · 10.6 KB
/
makeconfig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
#!/bin/sh
#
# Sccsid @(#)makeconfig 1.44 (gritter) 5/26/09
#
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() {
variable=$1
topic=$2
define=$3
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
eval have_$variable=yes
return 0
else
echo "/* $define */" >>$out
msg "no\\n"
eval unset have_$variable
return 1
fi
}
link_check() {
variable=$1
topic=$2
define=$3
libs=$4
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
eval have_$variable=yes
return 0
else
msg "no\\n"
echo "/* $define */" >>$out
eval unset have_$variable
return 1
fi
}
link_check hello '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 <stdio.h>
int main(int argc, char *argv[])
{
puts("hello world");
return 0;
}
!
compile_check alloca_h 'for <alloca.h>' '#define HAVE_ALLOCA_H' <<\!
#include <alloca.h>
!
link_check alloca 'for alloca()' '#define HAVE_ALLOCA' <<\!
#include "rcv.h"
int main(void)
{
alloca(1);
return 0;
}
!
compile_check ssize_t 'for ssize_t' '#define HAVE_SSIZE_T' <<\!
#include <sys/types.h>
#include <unistd.h>
int main(void)
{
ssize_t i = 3;
write(1, "foo", i);
return 0;
}
!
link_check snprintf 'for snprintf()' '#define HAVE_SNPRINTF' <<\!
#include <stdio.h>
int main(void)
{
char b[20];
snprintf(b, sizeof b, "%s", "string");
return 0;
}
!
link_check fchdir 'for fchdir()' '#define HAVE_FCHDIR' <<\!
#include <unistd.h>
int main(void)
{
fchdir(0);
return 0;
}
!
link_check mmap 'for mmap()' '#define HAVE_MMAP' <<\!
#include <sys/types.h>
#include <sys/mman.h>
int main(void)
{
mmap(0, 0, 0, 0, 0, 0);
return 0;
}
!
link_check mremap 'for mremap()' '#define HAVE_MREMAP' <<\!
#include <sys/types.h>
#include <sys/mman.h>
int main(void)
{
mremap(0, 0, 0, MREMAP_MAYMOVE);
return 0;
}
!
cat >$tmp2.c <<\!
#include <iconv.h>
int main(void)
{
iconv_t id;
id = iconv_open("foo", "bar");
return 0;
}
!
<$tmp2.c link_check iconv 'for iconv functionality' '#define HAVE_ICONV' ||
<$tmp2.c link_check iconv 'for iconv functionality in libiconv' \
'#define HAVE_ICONV' '-liconv'
link_check wctype 'for wctype functionality' '#define HAVE_WCTYPE_H' <<\!
#include <wctype.h>
int main(void)
{
iswprint(L'c');
towupper(L'c');
return 0;
}
!
link_check wcwidth 'for wcwidth() ' '#define HAVE_WCWIDTH' <<\!
#include <wchar.h>
int main(void)
{
wcwidth(L'c');
return 0;
}
!
link_check mbtowc 'for mbtowc()' '#define HAVE_MBTOWC' <<\!
#include <stdlib.h>
int main(void)
{
wchar_t wc;
mbtowc(&wc, "x", 1);
return 0;
}
!
link_check setlocale 'for setlocale()' '#define HAVE_SETLOCALE' <<\!
#include <locale.h>
int main(void)
{
setlocale(LC_ALL, "");
return 0;
}
!
link_check nl_langinfo 'for nl_langinfo()' '#define HAVE_NL_LANGINFO' <<\!
#include <langinfo.h>
int main(void)
{
nl_langinfo(DAY_1);
return 0;
}
!
link_check mkstemp 'for mkstemp()' '#define HAVE_MKSTEMP' <<\!
#include <stdlib.h>
int main(void)
{
mkstemp("x");
return 0;
}
!
link_check fpathconf 'for fpathconf()' '#define HAVE_FPATHCONF' <<\!
#include <unistd.h>
int main(void)
{
fpathconf(0, _PC_PATH_MAX);
return 0;
}
!
link_check wordexp 'for wordexp()' '#define HAVE_WORDEXP' <<\!
#include <wordexp.h>
int main(void)
{
wordexp((char *)0, (wordexp_t *)0, 0);
return 0;
}
!
compile_check arpa_inet_h 'for <arpa/inet.h>' '#define HAVE_ARPA_INET_H' <<\!
#include "config.h"
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <netinet/in.h>
#include <arpa/inet.h>
!
cat >$tmp2.c <<\!
#include "config.h"
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <netinet/in.h>
#ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h>
#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 sockets 'for socket functionality in libc' \
'#define HAVE_SOCKETS' ||
<$tmp2.c link_check sockets 'for socket functionality in libnsl' \
'#define HAVE_SOCKETS' '-lnsl' ||
<$tmp2.c link_check sockets \
'for socket functionality in libsocket and libnsl' \
'#define HAVE_SOCKETS' '-lsocket -lnsl'
#link_check ipv6 'for IPv6 functionality' '#define HAVE_IPv6_FUNCS' <<\!
##include "config.h"
##include <sys/types.h>
##include <sys/socket.h>
##include <netdb.h>
##include <netinet/in.h>
##ifdef HAVE_ARPA_INET_H
##include <arpa/inet.h>
##endif /* HAVE_ARPA_INET_H */
#
#int main(void)
#{
# struct addrinfo a, *ap;
# getaddrinfo("foo", "0", &a, &ap);
# return 0;
#}
#!
link_check nss 'for Network Security Services (NSS)' '#define USE_SSL
#define USE_NSS' '-lsmime3 -lnss3 -lssl3 -lnspr4 -lplc4' <<\! || \
link_check openssl 'for sufficiently recent OpenSSL' \
'#define USE_SSL
#define USE_OPENSSL' '-lssl -lcrypto' <<\%
#include <nss.h>
#include <ssl.h>
#include <prinit.h>
#include <prmem.h>
#include <pk11func.h>
#include <prtypes.h>
#include <prerror.h>
#include <secerr.h>
#include <smime.h>
#include <ciferfam.h>
#include <private/pprio.h>
int main(void)
{
PR_ImportTCPSocket(0);
NSS_CMSSignerInfo_AddSMIMECaps(0);
return 0;
}
!
#include <openssl/ssl.h>
#include <openssl/err.h>
#include <openssl/x509v3.h>
#include <openssl/x509.h>
#include <openssl/rand.h>
int main(void)
{
SSLv23_client_method();
PEM_read_PrivateKey(0, 0, 0, 0);
return 0;
}
%
if test x$have_nss = xyes
then
compile_check genname_h 'for genname.h' '#define HAVE_GENNAME_H' <<\!
#include <genname.h>
!
compile_check xconst_h 'for xconst.h' '#define HAVE_XCONST_H' <<\!
#include <xconst.h>
!
compile_check CERTAltNameEncodedContext \
'for CERTAltNameEncodedContext type' \
'#define HAVE_CERTAltNameEncodedContext' <<\!
#include "config.h"
#include <nss.h>
#include <ssl.h>
#include <prinit.h>
#include <prmem.h>
#include <pk11func.h>
#include <prtypes.h>
#include <prerror.h>
#include <secerr.h>
#include <smime.h>
#include <ciferfam.h>
#ifdef HAVE_XCONST_H
#include <xconst.h>
#endif
#ifdef HAVE_GENNAME_H
#include <genname.h>
#endif
#include <private/pprio.h>
CERTAltNameEncodedContext foo;
!
fi
if test x$have_openssl = xyes
then
compile_check stack_of 'for STACK_OF()' '#define HAVE_STACK_OF' <<\!
#include <openssl/ssl.h>
#include <openssl/err.h>
#include <openssl/x509v3.h>
#include <openssl/x509.h>
#include <openssl/rand.h>
int main(void)
{
STACK_OF(GENERAL_NAME) *gens = NULL;
printf("%p", gens); /* to make it used */
SSLv23_client_method();
PEM_read_PrivateKey(0, 0, 0, 0);
return 0;
}
!
fi
cat >$tmp2.c <<\!
#include <gssapi/gssapi.h>
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 gssapi 'for GSSAPI in libgss' \
'#define USE_GSSAPI' '-lgss' ||
<$tmp2.c link_check gssapi 'for GSSAPI in libgssapi_krb5' \
'#define USE_GSSAPI' '-lgssapi_krb5' ||
link_check gssapi 'for GSSAPI in libgssapi_krb5, old-style' \
'#define USE_GSSAPI
#define GSSAPI_OLD_STYLE' '-lgssapi_krb5' <<\! || \
link_check gssapi 'for GSSAPI in libgssapi' \
'#define USE_GSSAPI
#define GSSAPI_REG_INCLUDE' '-lgssapi' <<\%
#include <gssapi/gssapi.h>
#include <gssapi/gssapi_generic.h>
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 <gssapi.h>
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 <langinfo.h>
#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. mailx 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. mailx will be compiled to use
: chdir() instead. This is not a problem unless the current working
: directory of mailx is moved while the IMAP cache is used.
#endif
:
!
(hash cc) && cc -E $tmp2.c | sed '/^[^:]/d; /^$/d; s/^://' >&5
exit 0