NYD: attachments.c
[s-mailx.git] / mk-conf.sh
blobc169b5d24bda340e01ef86bb3b1922a67a7309cd
1 #!/bin/sh -
2 #@ Please see `INSTALL' and `conf.rc' instead.
4 LC_ALL=C
5 export LC_ALL
7 # Predefined CONFIG= urations take precedence over anything else
8 if [ -n "${CONFIG}" ]; then
9 case ${CONFIG} in
10 MINIMAL)
11 WANT_SOCKETS=0
12 WANT_IDNA=0
13 WANT_READLINE=0 WANT_EDITLINE=0 WANT_NCL=0
14 WANT_REGEX=0
15 WANT_SPAM=0
16 WANT_DOCSTRINGS=0
17 WANT_QUOTE_FOLD=0
18 WANT_COLOUR=0
20 MEDIUM)
21 WANT_SOCKETS=0
22 WANT_IDNA=0
23 WANT_READLINE=0 WANT_EDITLINE=0
24 WANT_REGEX=0
25 WANT_SPAM=0
26 WANT_QUOTE_FOLD=0
27 WANT_COLOUR=0
29 NETSEND)
30 WANT_IMAP=0
31 WANT_POP3=0
32 WANT_READLINE=0 WANT_EDITLINE=0
33 WANT_REGEX=0
34 WANT_SPAM=0
35 WANT_QUOTE_FOLD=0
36 WANT_COLOUR=0
39 echo >&2 "Unknown CONFIG= setting: ${CONFIG}"
40 echo >&2 'Possible values: MINIMAL, MEDIUM, NETSEND'
41 exit 1
42 esac
45 # Inter-relationships
46 option_update() {
47 if nwantfeat SOCKETS; then
48 WANT_IPV6=0 WANT_SSL=0
49 WANT_IMAP=0 WANT_GSSAPI=0 WANT_POP3=0 WANT_SMTP=0
51 if nwantfeat IMAP && nwantfeat POP3 && nwantfeat SMTP; then
52 WANT_SOCKETS=0 WANT_IPV6=0 WANT_SSL=0
54 if nwantfeat IMAP; then
55 WANT_GSSAPI=0
57 # If we don't need MD5 except for producing boundary and message-id strings,
58 # leave it off, plain old srand(3) should be enough for that purpose.
59 if nwantfeat SOCKETS; then
60 WANT_MD5=0
62 if wantfeat DEBUG; then
63 WANT_NOALLOCA=1
67 # Check out compiler ($CC) and -flags ($CFLAGS)
68 compiler_flags() {
69 i=`uname -s`
70 _CFLAGS=
72 # $CC is overwritten when empty or a default "cc", even without WANT_AUTOCC
73 optim= dbgoptim=
74 if [ -z "${CC}" ] || [ "${CC}" = cc ]; then
75 _CFLAGS=
76 if { CC="`command -v clang`"; }; then
78 elif { CC="`command -v gcc`"; }; then
80 elif { CC="`command -v c89`"; }; then
81 [ "${i}" = UnixWare ] && _CFLAGS=-v optim=-O dbgoptim=
82 elif { CC="`command -v c99`"; }; then
84 else
85 echo >&2 'ERROR'
86 echo >&2 ' I cannot find a compiler!'
87 echo >&2 ' Neither of clang(1), gcc(1), c89(1) and c99(1).'
88 echo >&2 ' Please set the CC environment variable, maybe CFLAGS also.'
89 exit 1
92 export CC
94 ccver=`${CC} --version 2>/dev/null`
95 stackprot=no
96 if { i=$ccver; echo "${i}"; } | ${grep} -q -i -e gcc -e clang; then
97 #if echo "${i}" | ${grep} -q -i -e gcc -e 'clang version 1'; then
98 optim=-O2 dbgoptim=-O
99 stackprot=yes
100 _CFLAGS='-std=c89'
101 _CFLAGS="${_CFLAGS} -Wall -Wextra -pedantic"
102 _CFLAGS="${_CFLAGS} -fno-unwind-tables -fno-asynchronous-unwind-tables"
103 _CFLAGS="${_CFLAGS} -fstrict-aliasing"
104 _CFLAGS="${_CFLAGS} -Wbad-function-cast -Wcast-align -Wcast-qual"
105 _CFLAGS="${_CFLAGS} -Winit-self -Wmissing-prototypes"
106 _CFLAGS="${_CFLAGS} -Wshadow -Wunused -Wwrite-strings"
107 if { i=$ccver; echo "${i}"; } | ${grep} -q -e 'clang version 1'; then
109 else
110 _CFLAGS="${_CFLAGS} -fstrict-overflow -Wstrict-overflow=5"
111 if wantfeat AMALGAMATION && nwantfeat DEBUG; then
112 _CFLAGS="${_CFLAGS} -Wno-unused-function"
114 if { i=$ccver; echo "${i}"; } | ${grep} -q -i -e clang; then
115 _CFLAGS="${_CFLAGS} -Wno-unused-result" # TODO handle the right way
118 _CFLAGS="${_CFLAGS} -Wno-long-long" # ISO C89 has no 'long long'...
119 # elif { i=$ccver; echo "${i}"; } | ${grep} -q -i -e clang; then
120 # stackprot=yes
121 # optim=-O3 dbgoptim=-O
122 # _CFLAGS='-std=c89 -g -Weverything -Wno-long-long'
123 elif [ -z "${optim}" ]; then
124 optim=-O1 dbgoptim=-O
127 if nwantfeat DEBUG; then
128 _CFLAGS="${optim} -DNDEBUG ${_CFLAGS}"
129 else
130 _CFLAGS="${dbgoptim} -g -ftrapv ${_CFLAGS}";
131 if [ "${stackprot}" = yes ]; then
132 _CFLAGS="${_CFLAGS} -fstack-protector-all "
133 _CFLAGS="${_CFLAGS} -Wstack-protector -D_FORTIFY_SOURCE=2"
136 _CFLAGS="${_CFLAGS} ${ADDCFLAGS}"
137 # XXX -Wl,-z,relro -Wl,-z,now -Wl,-z,noexecstack: need detection
138 _LDFLAGS="${_LDFLAGS} ${ADDLDFLAGS}" # XXX -Wl,--sort-common,[-O1]
139 export _CFLAGS _LDFLAGS
141 # $CFLAGS and $LDFLAGS are only overwritten if explicitly wanted
142 if wantfeat AUTOCC; then
143 CFLAGS=$_CFLAGS
144 LDFLAGS=$_LDFLAGS
145 export CFLAGS LDFLAGS
149 ## -- >8 -- 8< -- ##
151 ## Notes:
152 ## - Heirloom sh(1) (and same origin) have problems with ': >' redirection,
153 ## so use "printf '' >" instead
154 ## - Heirloom sh(1) and maybe more execute loops with redirection in a subshell
155 ## (but don't export eval's from within), therefore we need to (re)include
156 ## variable assignments at toplevel instead (via reading temporary files)
158 ## First of all, create new configuration and check wether it changed ##
160 conf=./conf.rc
161 lst=./config.lst
162 h=./config.h
163 mk=./mk.mk
165 newlst=./config.lst-new
166 newmk=./config.mk-new
167 newh=./config.h-new
168 tmp0=___tmp
169 tmp=./${tmp0}1$$
171 # We need some standard utilities
172 unset -f command
173 check_tool() {
174 n=$1 i=$2 opt=${3:-0}
175 if type "${i}" >/dev/null 2>&1; then
176 eval ${n}=${i}
177 return 1
179 if [ ${opt} -eq 0 ]; then
180 echo >&2 "ERROR: no trace of the utility \`${n}'"
181 exit 1
183 return 0
186 # Check those tools right now that we need before including ${conf}
187 check_tool rm "${rm:-`command -v rm`}"
188 check_tool sed "${sed:-`command -v sed`}"
190 # Only incorporate what wasn't overwritten from command line / CONFIG
191 trap "${rm} -f ${tmp}; exit" 1 2 15
192 trap "${rm} -f ${tmp}" 0
193 ${rm} -f ${tmp}
195 < ${conf} ${sed} -e '/^[ \t]*#/d' -e '/^$/d' -e 's/[ \t]*$//' |
196 while read line; do
197 i=`echo ${line} | ${sed} -e 's/=.*$//'`
198 eval j=\$${i} jx=\${${i}+x}
199 if [ -n "${j}" ] || [ "${jx}" = x ]; then
200 line="${i}=\"${j}\""
202 echo ${line}
203 done > ${tmp}
204 . ./${tmp}
206 check_tool awk "${awk:-`command -v awk`}"
207 check_tool cat "${cat:-`command -v cat`}"
208 check_tool chmod "${chmod:-`command -v chmod`}"
209 check_tool cp "${cp:-`command -v cp`}"
210 check_tool cmp "${cmp:-`command -v cmp`}"
211 check_tool grep "${grep:-`command -v grep`}"
212 check_tool mkdir "${mkdir:-`command -v mkdir`}"
213 check_tool mv "${mv:-`command -v mv`}"
214 # rm(1), sed(1) above
215 check_tool tee "${tee:-`command -v tee`}"
217 check_tool make "${MAKE:-`command -v make`}"
218 check_tool strip "${STRIP:-`command -v strip`}" 1
219 HAVE_STRIP=${?}
221 wantfeat() {
222 eval i=\$WANT_${1}
223 [ "${i}" = "1" ]
225 nwantfeat() {
226 eval i=\$WANT_${1}
227 [ "${i}" != "1" ]
230 option_update
232 # (No function since some shells loose non-exported variables in traps)
233 trap "${rm} -f ${tmp} ${newlst} ${newmk} ${newh}; exit" 1 2 15
234 trap "${rm} -f ${tmp} ${newlst} ${newmk} ${newh}" 0
235 ${rm} -f ${newlst} ${newmk} ${newh}
237 # (Could: use FD redirection, add eval(1) and don't re-'. ./${newlst}')
238 while read line; do
239 i=`echo ${line} | ${sed} -e 's/=.*$//'`
240 eval j=\$${i}
241 if [ -z "${j}" ] || [ "${j}" = 0 ]; then
242 printf "/*#define ${i}*/\n" >> ${newh}
243 elif [ "${j}" = 1 ]; then
244 printf "#define ${i}\n" >> ${newh}
245 else
246 printf "#define ${i} \"${j}\"\n" >> ${newh}
248 printf "${i} = ${j}\n" >> ${newmk}
249 printf "${i}=\"${j}\"\n"
250 done < ${tmp} > ${newlst}
251 . ./${newlst}
253 printf "#define UAGENT \"${SID}${NAIL}\"\n" >> ${newh}
254 printf "UAGENT = ${SID}${NAIL}\n" >> ${newmk}
256 compiler_flags
258 printf "CC = ${CC}\n" >> ${newmk}
259 printf "_CFLAGS = ${_CFLAGS}\nCFLAGS = ${CFLAGS}\n" >> ${newmk}
260 printf "_LDFLAGS = ${_LDFLAGS}\nLDFLAGS = ${LDFLAGS}\n" >> ${newmk}
261 printf "AWK = ${awk}\nCMP = ${cmp}\nCHMOD = ${chmod}\nCP = ${cp}\n" >> ${newmk}
262 printf "GREP = ${grep}\nMKDIR = ${mkdir}\nRM = ${rm}\nSED = ${sed}\n" \
263 >> ${newmk}
264 printf "STRIP = ${strip}\nHAVE_STRIP = ${HAVE_STRIP}\n" >> ${newmk}
265 # (We include the cc(1)/ld(1) environment only for update detection..)
266 printf "CC=\"${CC}\"\n" >> ${newlst}
267 printf "_CFLAGS=\"${_CFLAGS}\"\nCFLAGS=\"${CFLAGS}\"\n" >> ${newlst}
268 printf "_LDFLAGS=\"${_LDFLAGS}\"\nLDFLAGS=\"${LDFLAGS}\"\n" >> ${newlst}
269 printf "AWK=${awk}\nCMP=${cmp}\nCHMOD=${chmod}\nCP=${cp}\n" >> ${newlst}
270 printf "GREP=${grep}\nMKDIR=${mkdir}\nRM=${rm}\nSED=${sed}\n" >> ${newlst}
271 printf "STRIP=${strip}\nHAVE_STRIP=${HAVE_STRIP}\n" >> ${newlst}
273 if [ -f ${lst} ] && ${cmp} ${newlst} ${lst} >/dev/null 2>&1; then
274 exit 0
276 [ -f ${lst} ] && echo 'configuration updated..' || echo 'shiny configuration..'
278 ${mv} -f ${newlst} ${lst}
279 ${mv} -f ${newh} ${h}
280 ${mv} -f ${newmk} ${mk}
282 ## Compile and link checking ##
284 tmp2=./${tmp0}2$$
285 tmp3=./${tmp0}3$$
286 log=./config.log
287 lib=./config.lib
288 inc=./config.inc
289 src=./config.c
290 makefile=./config.mk
292 # (No function since some shells loose non-exported variables in traps)
293 trap "${rm} -f ${lst} ${h} ${mk} ${lib} ${inc} ${src} ${makefile}; exit" 1 2 15
294 trap "${rm} -rf ${tmp0}.* ${tmp0}* ${makefile}" 0
296 exec 5>&2 > ${log} 2>&1
297 printf '' > ${lib}
298 printf '' > ${inc}
299 # ${src} is only created if WANT_AMALGAMATION
300 ${rm} -f ${src}
301 ${cat} > ${makefile} << \!
302 .SUFFIXES: .o .c .x .y
303 .c.o:
304 $(CC) $(XINCS) -c $<
305 .c.x:
306 $(CC) $(XINCS) -E $< >$@
308 $(CC) $(XINCS) -o $@ $< $(XLIBS)
309 .y: ;
312 msg() {
313 fmt=$1
315 shift
316 printf "*** ${fmt}\\n" "${@}"
317 printf "${fmt}" "${@}" >&5
320 _check_preface() {
321 variable=$1 topic=$2 define=$3
323 echo '**********'
324 msg "checking ${topic} ... "
325 echo "/* checked ${topic} */" >> ${h}
326 ${rm} -f ${tmp} ${tmp}.o
327 echo '*** test program is'
328 ${tee} ${tmp}.c
329 #echo '*** the preprocessor generates'
330 #${make} -f ${makefile} ${tmp}.x
331 #${cat} ${tmp}.x
332 echo '*** results are'
335 compile_check() {
336 variable=$1 topic=$2 define=$3
338 _check_preface "${variable}" "${topic}" "${define}"
340 if ${make} -f ${makefile} XINCS="${INCS}" ./${tmp}.o &&
341 [ -f ./${tmp}.o ]; then
342 msg "yes\\n"
343 echo "${define}" >> ${h}
344 eval have_${variable}=yes
345 return 0
346 else
347 echo "/* ${define} */" >> ${h}
348 msg "no\\n"
349 eval unset have_${variable}
350 return 1
354 _link_mayrun() {
355 run=$1 variable=$2 topic=$3 define=$4 libs=$5 incs=$6
357 _check_preface "${variable}" "${topic}" "${define}"
359 if ${make} -f ${makefile} XINCS="${INCS} ${incs}" \
360 XLIBS="${LIBS} ${libs}" ./${tmp} &&
361 [ -f ./${tmp} ] &&
362 { [ ${run} -eq 0 ] || ./${tmp}; }; then
363 echo "*** adding INCS<${incs}> LIBS<${libs}>"
364 msg "yes\\n"
365 echo "${define}" >> ${h}
366 LIBS="${LIBS} ${libs}"
367 echo "${libs}" >> ${lib}
368 INCS="${INCS} ${incs}"
369 echo "${incs}" >> ${inc}
370 eval have_${variable}=yes
371 return 0
372 else
373 msg "no\\n"
374 echo "/* ${define} */" >> ${h}
375 eval unset have_${variable}
376 return 1
380 link_check() {
381 _link_mayrun 0 "${1}" "${2}" "${3}" "${4}" "${5}"
384 run_check() {
385 _link_mayrun 1 "${1}" "${2}" "${3}" "${4}" "${5}"
388 # Build a basic set of INCS and LIBS according to user environment.
389 # On pkgsrc(7) systems automatically add /usr/pkg/*
390 if [ -n "${C_INCLUDE_PATH}" ]; then
391 i=${IFS}
392 IFS=:
393 set -- ${C_INCLUDE_PATH}
394 IFS=${i}
395 # for i; do -- new in POSIX Issue 7 + TC1
396 for i
398 [ "${i}" = '/usr/pkg/include' ] && continue
399 INCS="${INCS} -I${i}"
400 done
402 [ -d /usr/pkg/include ] && INCS="${INCS} -I/usr/pkg/include"
403 echo "${INCS}" >> ${inc}
405 if [ -n "${LD_LIBRARY_PATH}" ]; then
406 i=${IFS}
407 IFS=:
408 set -- ${LD_LIBRARY_PATH}
409 IFS=${i}
410 # for i; do -- new in POSIX Issue 7 + TC1
411 for i
413 [ "${i}" = '/usr/pkg/lib' ] && continue
414 LIBS="${LIBS} -L${i}"
415 done
417 [ -d /usr/pkg/lib ] && LIBS="${LIBS} -L/usr/pkg/lib"
418 echo "${LIBS}" >> ${lib}
422 # Better set _GNU_SOURCE (if we are on Linux only?); 'surprised it did without
423 echo '#define _GNU_SOURCE' >> ${h}
425 link_check hello 'if a hello world program can be built' << \! || {\
426 echo >&5 'This oooops is most certainly not related to me.';\
427 echo >&5 "Read the file ${log} and check your compiler environment.";\
428 ${rm} -f ${lst} ${h} ${mk};\
429 exit 1;\
431 #include <stdio.h>
433 int main(int argc, char *argv[])
435 (void)argc;
436 (void)argv;
437 puts("hello world");
438 return 0;
442 link_check termios 'for termios.h and tc*() family' << \! || {\
443 echo >&5 'We require termios.h and the tc*() family of functions.';\
444 echo >&5 "That much Unix we indulge ourselfs.";\
445 ${rm} -f ${lst} ${h} ${mk};\
446 exit 1;\
448 #include <termios.h>
449 int main(void)
451 struct termios tios;
452 tcgetattr(0, &tios);
453 tcsetattr(0, TCSADRAIN | TCSAFLUSH, &tios);
454 return 0;
458 link_check setenv 'for setenv()/unsetenv()' '#define HAVE_SETENV' << \!
459 #include <stdlib.h>
460 int main(void)
462 setenv("s-nail", "to be made nifty!", 1);
463 unsetenv("s-nail");
464 return 0;
468 link_check snprintf 'for snprintf()' '#define HAVE_SNPRINTF' << \!
469 #include <stdio.h>
470 int main(void)
472 char b[20];
473 snprintf(b, sizeof b, "%s", "string");
474 return 0;
478 link_check putc_unlocked 'for putc_unlocked()' '#define HAVE_PUTC_UNLOCKED' <<\!
479 #include <stdio.h>
480 int main(void)
482 putc_unlocked('@', stdout);
483 return 0;
487 link_check fchdir 'for fchdir()' '#define HAVE_FCHDIR' << \!
488 #include <unistd.h>
489 int main(void)
491 fchdir(0);
492 return 0;
496 link_check mmap 'for mmap()' '#define HAVE_MMAP' << \!
497 #include <sys/types.h>
498 #include <sys/mman.h>
499 int main(void)
501 mmap(0, 0, 0, 0, 0, 0);
502 return 0;
506 link_check mremap 'for mremap()' '#define HAVE_MREMAP' << \!
507 #include <sys/types.h>
508 #include <sys/mman.h>
509 int main(void)
511 mremap(0, 0, 0, MREMAP_MAYMOVE);
512 return 0;
516 link_check setlocale 'for setlocale()' '#define HAVE_SETLOCALE' << \!
517 #include <locale.h>
518 int main(void)
520 setlocale(LC_ALL, "");
521 return 0;
525 if [ "${have_setlocale}" = yes ]; then
526 link_check c90amend1 'for ISO/IEC 9899:1990/Amendment 1:1995' \
527 '#define HAVE_C90AMEND1' << \!
528 #include <limits.h>
529 #include <stdlib.h>
530 #include <wchar.h>
531 #include <wctype.h>
532 int main(void)
534 char mbb[MB_LEN_MAX + 1];
535 wchar_t wc;
536 iswprint(L'c');
537 towupper(L'c');
538 mbtowc(&wc, "x", 1);
539 mbrtowc(&wc, "x", 1, NULL);
540 (void)wctomb(mbb, wc);
541 return (mblen("\0", 1) == 0);
545 if [ "${have_c90amend1}" = yes ]; then
546 link_check wcwidth 'for wcwidth()' '#define HAVE_WCWIDTH' << \!
547 #include <wchar.h>
548 int main(void)
550 wcwidth(L'c');
551 return 0;
556 link_check nl_langinfo 'for nl_langinfo()' '#define HAVE_NL_LANGINFO' << \!
557 #include <langinfo.h>
558 #include <stdlib.h>
559 int main(void)
561 nl_langinfo(DAY_1);
562 return (nl_langinfo(CODESET) == NULL);
565 fi # have_setlocale
567 link_check mkstemp 'for mkstemp()' '#define HAVE_MKSTEMP' << \!
568 #include <stdlib.h>
569 int main(void)
571 mkstemp("x");
572 return 0;
576 # Note: run_check, thus we also get only the desired implementation...
577 run_check realpath 'for realpath()' '#define HAVE_REALPATH' << \!
578 #include <stdlib.h>
579 int main(void)
581 char *x = realpath(".", NULL), *y = realpath("/", NULL);
582 return (x != NULL && y != NULL) ? 0 : 1;
586 link_check wordexp 'for wordexp()' '#define HAVE_WORDEXP' << \!
587 #include <wordexp.h>
588 int main(void)
590 wordexp((char *)0, (wordexp_t *)0, 0);
591 return 0;
597 if wantfeat DEBUG; then
598 echo '#define HAVE_DEBUG' >> ${h}
601 if wantfeat AMALGAMATION; then
602 echo '#define HAVE_AMALGAMATION' >> ${h}
605 if nwantfeat NOALLOCA; then
606 # Due to NetBSD PR lib/47120 it seems best not to use non-cc-builtin
607 # versions of alloca(3) since modern compilers just can't be trusted
608 # not to overoptimize and silently break some code
609 link_check alloca 'for __builtin_alloca()' \
610 '#define HAVE_ALLOCA __builtin_alloca' << \!
611 int main(void)
613 void *vp = __builtin_alloca(1);
614 return (!! vp);
619 if nwantfeat NOGETOPT; then
620 link_check getopt 'for getopt()' '#define HAVE_GETOPT' << \!
621 #include <unistd.h>
622 int main(int argc, char **argv)
624 #if defined __GLIBC__ || defined __linux__
625 Argument and option reordering is not a desired feature.
626 #else
627 getopt(argc, argv, "oPt");
628 #endif
629 return (((long)optarg + optind) & 0x7F);
636 if wantfeat ICONV; then
637 ${cat} > ${tmp2}.c << \!
638 #include <iconv.h>
639 int main(void)
641 iconv_t id;
643 id = iconv_open("foo", "bar");
644 return 0;
647 < ${tmp2}.c link_check iconv 'for iconv functionality' \
648 '#define HAVE_ICONV' ||
649 < ${tmp2}.c link_check iconv \
650 'for iconv functionality in libiconv' \
651 '#define HAVE_ICONV' '-liconv'
652 else
653 echo '/* WANT_ICONV=0 */' >> ${h}
654 fi # wantfeat ICONV
656 if wantfeat SOCKETS; then
657 compile_check arpa_inet_h 'for <arpa/inet.h>' \
658 '#define HAVE_ARPA_INET_H' << \!
659 #include "config.h"
660 #include <sys/types.h>
661 #include <sys/socket.h>
662 #include <netdb.h>
663 #include <netinet/in.h>
664 #include <arpa/inet.h>
667 ${cat} > ${tmp2}.c << \!
668 #include "config.h"
669 #include <sys/types.h>
670 #include <sys/socket.h>
671 #include <netdb.h>
672 #include <netinet/in.h>
673 #ifdef HAVE_ARPA_INET_H
674 #include <arpa/inet.h>
675 #endif
677 int main(void)
679 struct sockaddr s;
680 socket(AF_INET, SOCK_STREAM, 0);
681 connect(0, &s, 0);
682 gethostbyname("foo");
683 return 0;
687 < ${tmp2}.c link_check sockets 'for sockets in libc' \
688 '#define HAVE_SOCKETS' ||
689 < ${tmp2}.c link_check sockets 'for sockets in libnsl' \
690 '#define HAVE_SOCKETS' '-lnsl' ||
691 < ${tmp2}.c link_check sockets \
692 'for sockets in libsocket and libnsl' \
693 '#define HAVE_SOCKETS' '-lsocket -lnsl' ||
694 WANT_SOCKETS=0
696 # XXX Shouldn't it be a hard error if there is no socket support, then?
697 option_update
698 else
699 echo '/* WANT_SOCKETS=0 */' >> ${h}
700 fi # wantfeat SOCKETS
702 wantfeat SOCKETS &&
703 link_check setsockopt 'for setsockopt()' '#define HAVE_SETSOCKOPT' << \!
704 #include <sys/socket.h>
705 #include <stdlib.h>
706 int main(void)
708 int sockfd = 3;
709 setsockopt(sockfd, SOL_SOCKET, SO_KEEPALIVE, NULL, 0);
710 return 0;
714 wantfeat SOCKETS && [ -n "${have_setsockopt}" ] &&
715 link_check so_sndtimeo 'for SO_SNDTIMEO' '#define HAVE_SO_SNDTIMEO' << \!
716 #include <sys/socket.h>
717 #include <stdlib.h>
718 int main(void)
720 struct timeval tv;
721 int sockfd = 3;
722 tv.tv_sec = 42;
723 tv.tv_usec = 21;
724 setsockopt(sockfd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof tv);
725 setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof tv);
726 return 0;
730 wantfeat SOCKETS && [ -n "${have_setsockopt}" ] &&
731 link_check so_linger 'for SO_LINGER' '#define HAVE_SO_LINGER' << \!
732 #include <sys/socket.h>
733 #include <stdlib.h>
734 int main(void)
736 struct linger li;
737 int sockfd = 3;
738 li.l_onoff = 1;
739 li.l_linger = 42;
740 setsockopt(sockfd, SOL_SOCKET, SO_LINGER, &li, sizeof li);
741 return 0;
745 if wantfeat IPV6; then
746 link_check ipv6 'for IPv6 functionality' '#define HAVE_IPV6' << \!
747 #include "config.h"
748 #include <sys/types.h>
749 #include <sys/socket.h>
750 #include <netdb.h>
751 #include <netinet/in.h>
752 #ifdef HAVE_ARPA_INET_H
753 #include <arpa/inet.h>
754 #endif
756 int main(void)
758 struct addrinfo a, *ap;
759 getaddrinfo("foo", "0", &a, &ap);
760 return 0;
763 else
764 echo '/* WANT_IPV6=0 */' >> ${h}
765 fi # wantfeat IPV6
767 if wantfeat IMAP; then
768 echo '#define HAVE_IMAP' >> ${h}
769 else
770 echo '/* WANT_IMAP=0 */' >> ${h}
773 if wantfeat POP3; then
774 echo '#define HAVE_POP3' >> ${h}
775 else
776 echo '/* WANT_POP3=0 */' >> ${h}
779 if wantfeat SMTP; then
780 echo '#define HAVE_SMTP' >> ${h}
781 else
782 echo '/* WANT_SMTP=0 */' >> ${h}
785 if wantfeat SSL; then
786 link_check openssl 'for sufficiently recent OpenSSL' \
787 '#define HAVE_SSL
788 #define HAVE_OPENSSL' '-lssl -lcrypto' << \!
789 #include <openssl/ssl.h>
790 #include <openssl/err.h>
791 #include <openssl/x509v3.h>
792 #include <openssl/x509.h>
793 #include <openssl/rand.h>
795 #if defined OPENSSL_NO_SSL2 && defined OPENSSL_NO_SSL3 &&\
796 defined OPENSSL_NO_TLS1
797 # error We need one of (SSLv2 and) SSLv3 and TLS1.
798 #endif
800 int main(void)
802 SSLv23_client_method();
803 #ifndef OPENSSL_NO_SSL3
804 SSLv3_client_method();
805 #endif
806 #ifndef OPENSSL_NO_TLS1
807 TLSv1_client_method();
808 # ifdef TLS1_1_VERSION
809 TLSv1_1_client_method();
810 # endif
811 # ifdef TLS1_2_VERSION
812 TLSv1_2_client_method();
813 # endif
814 #endif
815 PEM_read_PrivateKey(0, 0, 0, 0);
816 return 0;
820 if [ "${have_openssl}" = 'yes' ]; then
821 compile_check stack_of 'for OpenSSL STACK_OF()' \
822 '#define HAVE_STACK_OF' << \!
823 #include <openssl/ssl.h>
824 #include <openssl/err.h>
825 #include <openssl/x509v3.h>
826 #include <openssl/x509.h>
827 #include <openssl/rand.h>
829 int main(void)
831 STACK_OF(GENERAL_NAME) *gens = NULL;
832 printf("%p", gens); /* to make it used */
833 return 0;
837 if wantfeat MD5; then
838 run_check openssl_md5 'for MD5 digest in OpenSSL' \
839 '#define HAVE_OPENSSL_MD5' << \!
840 #include <string.h>
841 #include <openssl/md5.h>
843 int main(void)
845 char const dat[] = "abrakadabrafidibus";
846 char dig[16], hex[16 * 2];
847 MD5_CTX ctx;
848 size_t i, j;
850 memset(dig, 0, sizeof(dig));
851 memset(hex, 0, sizeof(hex));
852 MD5_Init(&ctx);
853 MD5_Update(&ctx, dat, sizeof(dat) - 1);
854 MD5_Final(dig, &ctx);
856 #define hexchar(n) ((n) > 9 ? (n) - 10 + 'a' : (n) + '0')
857 for (i = 0; i < sizeof(hex) / 2; i++) {
858 j = i << 1;
859 hex[j] = hexchar((dig[i] & 0xf0) >> 4);
860 hex[++j] = hexchar(dig[i] & 0x0f);
862 return !!memcmp("6d7d0a3d949da2e96f2aa010f65d8326", hex, sizeof(hex));
865 fi # wantfeat MD5
867 else
868 echo '/* WANT_SSL=0 */' >> ${h}
869 fi # wantfeat SSL
871 if wantfeat GSSAPI; then
872 ${cat} > ${tmp2}.c << \!
873 #include <gssapi/gssapi.h>
875 int main(void)
877 gss_import_name(0, 0, GSS_C_NT_HOSTBASED_SERVICE, 0);
878 gss_init_sec_context(0,0,0,0,0,0,0,0,0,0,0,0,0);
879 return 0;
882 ${sed} -e '1s/gssapi\///' < ${tmp2}.c > ${tmp3}.c
884 if command -v krb5-config >/dev/null 2>&1; then
885 i=`command -v krb5-config`
886 GSSAPI_LIBS="`CFLAGS= ${i} --libs gssapi`"
887 GSSAPI_INCS="`CFLAGS= ${i} --cflags`"
888 i='for GSSAPI via krb5-config(1)'
889 else
890 GSSAPI_LIBS='-lgssapi'
891 GSSAPI_INCS=
892 i='for GSSAPI in gssapi/gssapi.h, libgssapi'
894 < ${tmp2}.c link_check gssapi \
895 "${i}" '#define HAVE_GSSAPI' \
896 "${GSSAPI_LIBS}" "${GSSAPI_INCS}" ||\
897 < ${tmp3}.c link_check gssapi \
898 'for GSSAPI in gssapi.h, libgssapi' \
899 '#define HAVE_GSSAPI
900 #define GSSAPI_REG_INCLUDE' \
901 '-lgssapi' ||\
902 < ${tmp2}.c link_check gssapi 'for GSSAPI in libgssapi_krb5' \
903 '#define HAVE_GSSAPI' \
904 '-lgssapi_krb5' ||\
905 < ${tmp3}.c link_check gssapi \
906 'for GSSAPI in libgssapi, OpenBSD-style (pre 5.3)' \
907 '#define HAVE_GSSAPI
908 #define GSSAPI_REG_INCLUDE' \
909 '-lgssapi -lkrb5 -lcrypto' \
910 '-I/usr/include/kerberosV' ||\
911 < ${tmp2}.c link_check gssapi 'for GSSAPI in libgss' \
912 '#define HAVE_GSSAPI' \
913 '-lgss' ||\
914 link_check gssapi 'for GSSAPI in libgssapi_krb5, old-style' \
915 '#define HAVE_GSSAPI
916 #define GSSAPI_OLD_STYLE' \
917 '-lgssapi_krb5' << \!
918 #include <gssapi/gssapi.h>
919 #include <gssapi/gssapi_generic.h>
921 int main(void)
923 gss_import_name(0, 0, gss_nt_service_name, 0);
924 gss_init_sec_context(0,0,0,0,0,0,0,0,0,0,0,0,0);
925 return 0;
928 else
929 echo '/* WANT_GSSAPI=0 */' >> ${h}
930 fi # wantfeat GSSAPI
932 if wantfeat IDNA; then
933 link_check idna 'for GNU Libidn' '#define HAVE_IDNA' '-lidn' << \!
934 #include <idna.h>
935 #include <stringprep.h>
936 int main(void)
938 char *utf8, *idna_ascii, *idna_utf8;
939 utf8 = stringprep_locale_to_utf8("does.this.work");
940 if (idna_to_ascii_8z(utf8, &idna_ascii, IDNA_USE_STD3_ASCII_RULES)
941 != IDNA_SUCCESS)
942 return 1;
943 /* (Rather link check only here) */
944 idna_utf8 = stringprep_convert(idna_ascii, "UTF-8", "de_DE");
945 return 0;
948 else
949 echo '/* WANT_IDNA=0 */' >> ${h}
952 if wantfeat REGEX; then
953 link_check regex 'for regular expressions' '#define HAVE_REGEX' << \!
954 #include <regex.h>
955 #include <stdlib.h>
956 int main(void)
958 int status;
959 regex_t re;
960 if (regcomp(&re, ".*bsd", REG_EXTENDED | REG_ICASE | REG_NOSUB) != 0)
961 return 1;
962 status = regexec(&re, "plan9", 0,NULL, 0);
963 regfree(&re);
964 return !(status == REG_NOMATCH);
967 else
968 echo '/* WANT_REGEX=0 */' >> ${h}
971 if wantfeat READLINE; then
972 __edrdlib() {
973 link_check readline "for readline(3) (${1})" \
974 '#define HAVE_READLINE' "${1}" << \!
975 #include <stdio.h>
976 #include <readline/history.h>
977 #include <readline/readline.h>
978 int main(void)
980 char *rl;
981 HISTORY_STATE *hs;
982 HIST_ENTRY **he;
983 int i;
984 using_history();
985 read_history("");
986 stifle_history(242);
987 rl = readline("Enter a line:");
988 if (rl && *rl)
989 add_history(rl);
990 write_history("");
991 rl_extend_line_buffer(10);
992 rl_point = rl_end = 10;
993 rl_pre_input_hook = (rl_hook_func_t*)NULL;
994 rl_forced_update_display();
995 clear_history();
996 hs = history_get_history_state();
997 i = hs->length;
998 he = history_list();
999 if (i > 0)
1000 rl = he[0]->line;
1001 rl_free_line_state();
1002 rl_cleanup_after_signal();
1003 rl_reset_after_signal();
1004 return 0;
1009 __edrdlib -lreadline ||
1010 __edrdlib '-lreadline -ltermcap'
1011 [ -n "${have_readline}" ] && WANT_TABEXPAND=1
1014 if wantfeat EDITLINE && [ -z "${have_readline}" ]; then
1015 __edlib() {
1016 link_check editline "for editline(3) (${1})" \
1017 '#define HAVE_EDITLINE' "${1}" << \!
1018 #include <histedit.h>
1019 static char * getprompt(void) { return (char*)"ok"; }
1020 int main(void)
1022 EditLine *el_el = el_init("TEST", stdin, stdout, stderr);
1023 HistEvent he;
1024 History *el_hcom = history_init();
1025 history(el_hcom, &he, H_SETSIZE, 242);
1026 el_set(el_el, EL_SIGNAL, 0);
1027 el_set(el_el, EL_TERMINAL, NULL);
1028 el_set(el_el, EL_HIST, &history, el_hcom);
1029 el_set(el_el, EL_EDITOR, "emacs");
1030 el_set(el_el, EL_PROMPT, &getprompt);
1031 el_source(el_el, NULL);
1032 history(el_hcom, &he, H_GETSIZE);
1033 history(el_hcom, &he, H_CLEAR);
1034 el_end(el_el);
1035 /* TODO add loader and addfn checks */
1036 history_end(el_hcom);
1037 return 0;
1042 __edlib -ledit ||
1043 __edlib '-ledit -ltermcap'
1044 [ -n "${have_editline}" ] && WANT_TABEXPAND=0
1047 if wantfeat NCL && [ -z "${have_editline}" ] && [ -z "${have_readline}" ] &&\
1048 [ -n "${have_c90amend1}" ]; then
1049 have_ncl=1
1050 echo '#define HAVE_NCL' >> ${h}
1051 else
1052 echo '/* WANT_{READLINE,EDITLINE,NCL}=0 */' >> ${h}
1055 # Generic have-a-command-line-editor switch for those who need it below
1056 if [ -n "${have_ncl}" ] || [ -n "${have_editline}" ] ||\
1057 [ -n "${have_readline}" ]; then
1058 have_cle=1
1061 if [ -n "${have_cle}" ] && wantfeat TABEXPAND; then
1062 echo '#define HAVE_TABEXPAND' >> ${h}
1063 else
1064 echo '/* WANT_TABEXPAND=0 */' >> ${h}
1067 if [ -n "${have_cle}" ] && wantfeat HISTORY; then
1068 echo '#define HAVE_HISTORY' >> ${h}
1069 else
1070 echo '/* WANT_HISTORY=0 */' >> ${h}
1073 if wantfeat SPAM; then
1074 echo '#define HAVE_SPAM' >> ${h}
1075 if command -v spamc >/dev/null 2>&1; then
1076 echo "#define SPAMC_PATH \"`command -v spamc`\"" >> ${h}
1078 else
1079 echo '/* WANT_SPAM=0 */' >> ${h}
1082 if wantfeat DOCSTRINGS; then
1083 echo '#define HAVE_DOCSTRINGS' >> ${h}
1084 else
1085 echo '/* WANT_DOCSTRINGS=0 */' >> ${h}
1088 if wantfeat QUOTE_FOLD &&\
1089 [ -n "${have_c90amend1}" ] && [ -n "${have_wcwidth}" ]; then
1090 echo '#define HAVE_QUOTE_FOLD' >> ${h}
1091 else
1092 echo '/* WANT_QUOTE_FOLD=0 */' >> ${h}
1095 if wantfeat COLOUR; then
1096 echo '#define HAVE_COLOUR' >> ${h}
1097 else
1098 echo '/* WANT_COLOUR=0 */' >> ${h}
1101 if wantfeat MD5; then
1102 echo '#define HAVE_MD5' >> ${h}
1103 else
1104 echo '/* WANT_MD5=0 */' >> ${h}
1107 ## Summarizing ##
1109 # Since we cat(1) the content of those to cc/"ld", convert them to single line
1110 squeeze_em() {
1111 < "${1}" > "${2}" ${awk} \
1112 'BEGIN {ORS = " "} /^[^#]/ {print} {next} END {ORS = ""; print "\n"}'
1114 ${rm} -f ${tmp}
1115 squeeze_em ${inc} ${tmp}
1116 ${mv} ${tmp} ${inc}
1117 squeeze_em ${lib} ${tmp}
1118 ${mv} ${tmp} ${lib}
1120 # config.h
1121 ${mv} ${h} ${tmp}
1122 printf '#ifndef _CONFIG_H\n# define _CONFIG_H\n' > ${h}
1123 ${cat} ${tmp} >> ${h}
1125 printf '\n/* The "feature string", for "simplicity" and lex.c */\n' >> ${h}
1126 printf '#ifdef _MAIN_SOURCE\n' >> ${h}
1127 printf '# ifdef HAVE_AMALGAMATION\nstatic\n# endif\n' >> ${h}
1128 printf 'char const features[] = "MIME"\n' >> ${h}
1129 printf '# ifdef HAVE_DOCSTRINGS\n ",DOCSTRINGS"\n# endif\n' >> ${h}
1130 printf '# ifdef HAVE_ICONV\n ",ICONV"\n# endif\n' >> ${h}
1131 printf '# ifdef HAVE_SETLOCALE\n ",LOCALES"\n# endif\n' >> ${h}
1132 printf '# ifdef HAVE_C90AMEND1\n ",MULTIBYTE CHARSETS"\n# endif\n' >> ${h}
1133 printf '# ifdef HAVE_NL_LANGINFO\n ",TERMINAL CHARSET"\n# endif\n' >> ${h}
1134 printf '# ifdef HAVE_SOCKETS\n ",NETWORK"\n# endif\n' >> ${h}
1135 printf '# ifdef HAVE_IPV6\n ",IPv6"\n# endif\n' >> ${h}
1136 printf '# ifdef HAVE_SSL\n ",S/MIME,SSL/TSL"\n# endif\n' >> ${h}
1137 printf '# ifdef HAVE_IMAP\n ",IMAP"\n# endif\n' >> ${h}
1138 printf '# ifdef HAVE_GSSAPI\n ",GSSAPI"\n# endif\n' >> ${h}
1139 printf '# ifdef HAVE_POP3\n ",POP3"\n# endif\n' >> ${h}
1140 printf '# ifdef HAVE_SMTP\n ",SMTP"\n# endif\n' >> ${h}
1141 printf '# ifdef HAVE_SPAM\n ",SPAM"\n# endif\n' >> ${h}
1142 printf '# ifdef HAVE_IDNA\n ",IDNA"\n# endif\n' >> ${h}
1143 printf '# ifdef HAVE_REGEX\n ",REGEX"\n# endif\n' >> ${h}
1144 printf '# ifdef HAVE_READLINE\n ",READLINE"\n# endif\n' >> ${h}
1145 printf '# ifdef HAVE_EDITLINE\n ",EDITLINE"\n# endif\n' >> ${h}
1146 printf '# ifdef HAVE_NCL\n ",NCL"\n# endif\n' >> ${h}
1147 printf '# ifdef HAVE_TABEXPAND\n ",TABEXPAND"\n# endif\n' >> ${h}
1148 printf '# ifdef HAVE_HISTORY\n ",HISTORY MANAGEMENT"\n# endif\n' >> ${h}
1149 printf '# ifdef HAVE_QUOTE_FOLD\n ",QUOTE-FOLD"\n# endif\n' >> ${h}
1150 printf '# ifdef HAVE_COLOUR\n ",COLOUR"\n# endif\n' >> ${h}
1151 printf '# ifdef HAVE_DEBUG\n ",DEBUG"\n# endif\n' >> ${h}
1152 printf ';\n#endif /* _MAIN_SOURCE */\n' >> ${h}
1154 printf '#endif /* _CONFIG_H */\n' >> ${h}
1155 ${rm} -f ${tmp}
1157 # Create the real mk.mk
1158 ${rm} -rf ${tmp0}.* ${tmp0}*
1159 printf 'OBJ_SRC = ' >> ${mk}
1160 if nwantfeat AMALGAMATION; then
1161 echo *.c >> ${mk}
1162 echo 'OBJ_DEP =' >> ${mk}
1163 else
1164 j=`echo "${src}" | sed 's/^.\///'`
1165 echo "${j}" >> ${mk}
1166 printf 'OBJ_DEP = main.c ' >> ${mk}
1167 printf '#define _MAIN_SOURCE\n' >> ${src}
1168 printf '#include "nail.h"\n#include "main.c"\n' >> ${src}
1169 for i in *.c; do
1170 if [ "${i}" = "${j}" ] || [ "${i}" = main.c ]; then
1171 continue
1173 printf "${i} " >> ${mk}
1174 printf "#include \"${i}\"\n" >> ${src}
1175 done
1176 echo >> ${mk}
1179 echo "LIBS = `${cat} ${lib}`" >> ${mk}
1180 echo "INCLUDES = `${cat} ${inc}`" >> ${mk}
1181 echo >> ${mk}
1182 ${cat} ./mk-mk.in >> ${mk}
1184 ## Finished! ##
1186 ${cat} > ${tmp2}.c << \!
1187 #include "config.h"
1188 #ifdef HAVE_NL_LANGINFO
1189 # include <langinfo.h>
1190 #endif
1192 :The following optional features are enabled:
1193 #ifdef HAVE_ICONV
1194 : + Character set conversion using iconv()
1195 #endif
1196 #ifdef HAVE_SETLOCALE
1197 : + Locale support: Printable characters depend on the environment
1198 # ifdef HAVE_C90AMEND1
1199 : + Multibyte character support
1200 # endif
1201 # ifdef HAVE_NL_LANGINFO
1202 : + Automatic detection of terminal character set
1203 # endif
1204 #endif
1205 #ifdef HAVE_SOCKETS
1206 : + Network support
1207 #endif
1208 #ifdef HAVE_IPV6
1209 : + Support for Internet Protocol v6 (IPv6)
1210 #endif
1211 #ifdef HAVE_SSL
1212 # ifdef HAVE_OPENSSL
1213 : + S/MIME and SSL/TLS using OpenSSL
1214 # endif
1215 #endif
1216 #ifdef HAVE_IMAP
1217 : + IMAP protocol
1218 #endif
1219 #ifdef HAVE_GSSAPI
1220 : + IMAP GSSAPI authentication
1221 #endif
1222 #ifdef HAVE_POP3
1223 : + POP3 protocol
1224 #endif
1225 #ifdef HAVE_SMTP
1226 : + SMTP protocol
1227 #endif
1228 #ifdef HAVE_SPAM
1229 : + Interaction with spam filters
1230 #endif
1231 #ifdef HAVE_IDNA
1232 : + IDNA (internationalized domain names for applications) support
1233 #endif
1234 #ifdef HAVE_REGEX
1235 : + Regular expression searches
1236 #endif
1237 #if defined HAVE_READLINE || defined HAVE_EDITLINE || defined HAVE_NCL
1238 : + Command line editing
1239 # ifdef HAVE_TABEXPAND
1240 : + + Tabulator expansion
1241 # endif
1242 # ifdef HAVE_HISTORY
1243 : + + History management
1244 # endif
1245 #endif
1246 #ifdef HAVE_QUOTE_FOLD
1247 : + Extended *quote-fold*ing
1248 #endif
1249 #ifdef HAVE_COLOUR
1250 : + Coloured message display (simple)
1251 #endif
1253 :The following optional features are disabled:
1254 #ifndef HAVE_ICONV
1255 : - Character set conversion using iconv()
1256 #endif
1257 #ifndef HAVE_SETLOCALE
1258 : - Locale support: Only ASCII characters are recognized
1259 #endif
1260 # ifndef HAVE_C90AMEND1
1261 : - Multibyte character support
1262 # endif
1263 # ifndef HAVE_NL_LANGINFO
1264 : - Automatic detection of terminal character set
1265 # endif
1266 #ifndef HAVE_SOCKETS
1267 : - Network support
1268 #endif
1269 #ifndef HAVE_IPV6
1270 : - Support for Internet Protocol v6 (IPv6)
1271 #endif
1272 #if !defined HAVE_SSL
1273 : - SSL/TLS (network transport authentication and encryption)
1274 #endif
1275 #ifndef HAVE_IMAP
1276 : - IMAP protocol
1277 #endif
1278 #ifndef HAVE_GSSAPI
1279 : - IMAP GSSAPI authentication
1280 #endif
1281 #ifndef HAVE_POP3
1282 : - POP3 protocol
1283 #endif
1284 #ifndef HAVE_SMTP
1285 : - SMTP protocol
1286 #endif
1287 #ifndef HAVE_SPAM
1288 : - Interaction with spam filters
1289 #endif
1290 #ifndef HAVE_IDNA
1291 : - IDNA (internationalized domain names for applications) support
1292 #endif
1293 #ifndef HAVE_REGEX
1294 : - Regular expression searches
1295 #endif
1296 #if !defined HAVE_READLINE && !defined HAVE_EDITLINE && !defined HAVE_NCL
1297 : - Command line editing and history
1298 #endif
1299 #ifndef HAVE_QUOTE_FOLD
1300 : - Extended *quote-fold*ing
1301 #endif
1302 #ifndef HAVE_COLOUR
1303 : - Coloured message display (simple)
1304 #endif
1306 :Remarks:
1307 #ifndef HAVE_SNPRINTF
1308 : . The function snprintf() could not be found. mailx will be compiled to use
1309 : sprintf() instead. This might overflow buffers if input values are larger
1310 : than expected. Use the resulting binary with care or update your system
1311 : environment and start the configuration process again.
1312 #endif
1313 #ifndef HAVE_FCHDIR
1314 : . The function fchdir() could not be found. mailx will be compiled to use
1315 : chdir() instead. This is not a problem unless the current working
1316 : directory of mailx is moved while the IMAP cache is used.
1317 #endif
1318 #ifndef HAVE_GETOPT
1319 : . Using a minimal builtin POSIX-like getopt()
1320 #endif
1321 #ifdef HAVE_DEBUG
1322 : . Debug enabled binary: not meant to be used by end-users: THANKS!
1323 #endif
1327 ${make} -f ${makefile} ${tmp2}.x
1328 < ${tmp2}.x >&5 ${sed} -e '/^[^:]/d; /^$/d; s/^://'
1330 # vim:set fenc=utf-8:s-it-mode