2 #@ Please see `INSTALL' and `make.rc' instead.
10 WANT_SSL
=0 WANT_ALL_SSL_ALGORITHMS
=0
11 WANT_SMTP
=0 WANT_POP3
=0 WANT_IMAP
=0
12 WANT_GSSAPI
=0 WANT_NETRC
=0 WANT_AGENT
=0
17 WANT_READLINE
=0 WANT_EDITLINE
=0 WANT_NCL
=0
20 WANT_SPAM_SPAMC
=0 WANT_SPAM_SPAMD
=0 WANT_SPAM_FILTER
=0
23 WANT_FILTER_HTML_TAGSOUP
=0
31 WANT_SSL
=1 WANT_ALL_SSL_ALGORITHMS
=1
32 WANT_SMTP
=1 WANT_POP3
=1 WANT_IMAP
=1
33 WANT_GSSAPI
=1 WANT_NETRC
=1 WANT_AGENT
=1
39 WANT_HISTORY
=1 WANT_TABEXPAND
=1
42 WANT_SPAM_SPAMC
=1 WANT_SPAM_SPAMD
=1 WANT_SPAM_FILTER
=1
45 WANT_FILTER_HTML_TAGSOUP
=1
50 # Predefined CONFIG= urations take precedence over anything else
51 if [ -n "${CONFIG}" ]; then
60 [mM
][iI
][nN
][iI
][mM
][aA
][lL
])
66 [mM
][eE
][dD
][iI
][uU
][mM
])
79 [nN
][eE
][tT
][sS
][eE
][nN
][dD
])
85 WANT_GSSAPI
=1 WANT_NETRC
=1 WANT_AGENT
=1
94 [mM
][aA
][xX
][iI
][mM
][aA
][lL
])
99 WANT_DEVEL
=1 WANT_DEBUG
=1 WANT_NYD2
=1
102 [oO
][dD
][eE
][vV
][eE
][lL
])
107 echo >&2 "Unknown CONFIG= setting: ${CONFIG}"
108 echo >&2 'Possible values: NULL, NULLI, MINIMAL, MEDIUM, NETSEND, MAXIMAL'
114 # Inter-relationships
116 if feat_no SMTP
&& feat_no POP3
&& feat_no IMAP
; then
119 if feat_no SOCKETS
; then
120 if feat_require SMTP
; then
121 msg
'ERROR: need SOCKETS for required feature SMTP'
124 if feat_require POP3
; then
125 msg
'ERROR: need SOCKETS for required feature POP3'
128 if feat_require IMAP
; then
129 msg
"ERROR: need SOCKETS for required feature IMAP\\n"
132 WANT_SSL
=0 WANT_ALL_SSL_ALGORITHMS
=0
133 WANT_SMTP
=0 WANT_POP3
=0 WANT_IMAP
=0
134 WANT_GSSAPI
=0 WANT_NETRC
=0 WANT_AGENT
=0
136 if feat_no SMTP
&& feat_no IMAP
; then
140 if feat_no ICONV
; then
144 if feat_no READLINE
&& feat_no EDITLINE
&& feat_no NCL
; then
145 WANT_HISTORY
=0 WANT_TABEXPAND
=0
148 # If we don't need MD5 leave it alone
149 if feat_no SOCKETS
; then
153 if feat_yes DEVEL
; then
156 if feat_yes DEBUG
; then
161 # Note that potential duplicates in PATH, C_INCLUDE_PATH etc. will be cleaned
162 # via path_check() later on once possible
164 # TODO cc_maxopt is brute simple, we should compile test program and dig real
165 # compiler versions for known compilers, then be more specific
170 i
="${OS:-`uname -s`}"
172 if [ ${i} = SunOS
]; then
173 msg
'SunOS / Solaris? Applying some "early setup" rules ...'
174 _os_early_setup_sunos
179 # OSFULLSPEC is used to recognize changes (i.e., machine type, updates etc.)
180 OSFULLSPEC
="${OS:-`uname -a | ${tr} '[A-Z]' '[a-z]'`}"
181 OS
="${OS:-`uname -s | ${tr} '[A-Z]' '[a-z]'`}"
182 msg
'Operating system is "%s"' ${OS}
184 if [ ${OS} = sunos
]; then
185 msg
' . have special SunOS / Solaris "setup" rules ...'
187 elif [ ${OS} = unixware
]; then
188 msg
' . have special UnixWare environmental rules ...'
189 if feat_yes AUTOCC
&& command -v cc
>/dev
/null
2>&1; then
191 feat_yes DEBUG
&& _CFLAGS
='-v -Xa -g' || _CFLAGS
='-Xa -O'
193 CFLAGS
="${_CFLAGS} ${ADDCFLAGS}"
194 LDFLAGS
="${_LDFLAGS} ${ADDLDFLAGS}"
195 export CC CFLAGS LDFLAGS
196 WANT_AUTOCC
=0 had_want_autocc
=1 need_R_ldflags
=-R
198 elif [ -n "${VERBOSE}" ]; then
199 msg
' . no special treatment for this system necessary or known'
202 # Sledgehammer: better set _GNU_SOURCE
203 # And in general: oh, boy!
204 OS_DEFINES
="${OS_DEFINES}#define _GNU_SOURCE\n"
205 #OS_DEFINES="${OS_DEFINES}#define _POSIX_C_SOURCE 200809L\n"
206 #OS_DEFINES="${OS_DEFINES}#define _XOPEN_SOURCE 700\n"
207 #[ ${OS} = darwin ] && OS_DEFINES="${OS_DEFINES}#define _DARWIN_C_SOURCE\n"
209 # On pkgsrc(7) systems automatically add /usr/pkg/*
210 if [ -d /usr
/pkg
]; then
211 C_INCLUDE_PATH
="${C_INCLUDE_PATH}:/usr/pkg/include"
212 LD_LIBRARY_PATH
="${LD_LIBRARY_PATH}:/usr/pkg/lib"
216 _os_early_setup_sunos
() {
217 # According to standards(5), this is what we need to do
218 if [ -d /usr
/xpg4
]; then :; else
219 msg
'ERROR: On SunOS / Solaris we need /usr/xpg4 environment! Sorry.'
222 PATH
="/usr/xpg4/bin:/usr/ccs/bin:/usr/bin:${PATH}"
223 [ -d /usr
/xpg6
] && PATH
="/usr/xpg6/bin:${PATH}"
228 C_INCLUDE_PATH
="/usr/xpg4/include:${C_INCLUDE_PATH}"
229 LD_LIBRARY_PATH
="/usr/xpg4/lib:${LD_LIBRARY_PATH}"
232 if [ -d /opt
/csw
]; then
233 C_INCLUDE_PATH
="${C_INCLUDE_PATH}:/opt/csw/include"
234 LD_LIBRARY_PATH
="${LD_LIBRARY_PATH}:/opt/csw/lib"
237 OS_DEFINES
="${OS_DEFINES}#define __EXTENSIONS__\n"
238 #OS_DEFINES="${OS_DEFINES}#define _POSIX_C_SOURCE 200112L\n"
240 [ -n "${cksum}" ] ||
cksum=/opt
/csw
/gnu
/cksum
241 if [ -x "${cksum}" ]; then :; else
242 msg
'ERROR: Not an executable program: "%s"' "${cksum}"
243 msg
'ERROR: We need a CRC-32 cksum(1), as specified in POSIX.'
244 msg
'ERROR: However, we do so only for tests.'
245 msg
'ERROR: If that is ok, set "cksum=/usr/bin/true", then rerun'
249 if feat_yes AUTOCC
; then
250 if command -v cc
>/dev
/null
2>&1; then
252 feat_yes DEBUG
&& _CFLAGS
="-v -Xa -g" || _CFLAGS
="-Xa -O"
254 CFLAGS
="${_CFLAGS} ${ADDCFLAGS}"
255 LDFLAGS
="${_LDFLAGS} ${ADDLDFLAGS}"
256 export CC CFLAGS LDFLAGS
257 WANT_AUTOCC
=0 had_want_autocc
=1 need_R_ldflags
=-R
260 cc_maxopt
=2 force_no_stackprot
=1 need_R_ldflags
=-Wl,-R
265 # Check out compiler ($CC) and -flags ($CFLAGS)
267 # Even though it belongs into cc_flags we will try to compile and link
268 # something, so ensure we have a clean state regarding CFLAGS/LDFLAGS or
269 # ADDCFLAGS/ADDLDFLAGS
270 if feat_no AUTOCC
; then
272 # Ensure those don't do any harm
273 ADDCFLAGS
= ADDLDFLAGS
=
274 export ADDCFLAGS ADDLDFLAGS
278 export CFLAGS LDFLAGS
281 [ -n "${CC}" ] && [ "${CC}" != cc ] && { _cc_default; return; }
283 printf >&2 'Searching for a usable C compiler .. $CC='
284 if { i="`command -v clang`"; }; then
286 elif { i="`command -v gcc`"; }; then
288 elif { i="`command -v c99`"; }; then
290 elif { i="`command -v tcc`"; }; then
292 elif { i="`command -v pcc`"; }; then
295 if [ "${CC}" = cc ]; then
297 elif { i="`command -v c89`"; }; then
300 printf >&2 'boing booom tschak\n'
301 msg 'ERROR: I cannot find a compiler!'
302 msg ' Neither of clang(1), gcc(1), tcc(1), c89(1) and c99(1).'
303 msg ' Please set $CC environment variable, maybe $CFLAGS also, rerun.'
307 printf >&2 -- '"%s
"\n' "${CC}"
312 if [ -z "${CC}" ]; then
313 printf >&2 'To go on like you have chosen, please set $CC, rerun.'
317 if [ -z "${VERBOSE}" ] && [ -f ${lst} ] && feat_no DEBUG; then
320 msg 'Using C compiler $CC="%s
"' "${CC}"
325 if feat_yes AUTOCC; then
326 if [ -f ${lst} ] && feat_no DEBUG && [ -z "${VERBOSE}" ]; then
328 msg 'Detecting $CFLAGS/$LDFLAGS for $CC="%s
", just a second..' "${CC}"
331 msg 'Testing usable $CFLAGS/$LDFLAGS for $CC="%s
"' "${CC}"
334 i=`echo "${CC}" | ${awk} 'BEGIN{FS="/"}{print
$NF}'`
335 if { echo "${i}" | ${grep} tcc; } >/dev/null 2>&1; then
336 msg ' . have special tcc
(1) environmental rules ...
'
339 # As of pcc CVS 2016-04-02, stack protection support is announced but
340 # will break if used on Linux
341 if { echo "${i}" | ${grep} pcc; } >/dev/null 2>&1; then
347 feat_no DEBUG && _CFLAGS="-DNDEBUG ${_CFLAGS}"
348 CFLAGS="${_CFLAGS} ${ADDCFLAGS}"
349 LDFLAGS="${_LDFLAGS} ${ADDLDFLAGS}"
351 if feat_no DEBUG; then
352 CFLAGS="-DNDEBUG ${CFLAGS}"
356 export CFLAGS LDFLAGS
360 __cflags=${_CFLAGS} __ldflags=${_LDFLAGS}
367 if feat_yes DEBUG; then
368 # May have problems to find libtcc cc_check -b
372 _CFLAGS="${_CFLAGS} ${__cflags}" _LDFLAGS="${_LDFLAGS} ${__ldflags}"
373 unset __cflags __ldflags
376 _cc_flags_generic() {
377 __cflags=${_CFLAGS} __ldflags=${_LDFLAGS}
379 feat_yes DEVEL && cc_check -std=c89 || cc_check -std=c99
381 # Check -g first since some others may rely upon -g / optim. level
382 if feat_yes DEBUG; then
385 elif [ ${cc_maxopt} -gt 2 ] && cc_check -O3; then
387 elif [ ${cc_maxopt} -gt 1 ] && cc_check -O2; then
389 elif [ ${cc_maxopt} -gt 0 ] && cc_check -O1; then
395 if feat_yes DEVEL && cc_check -Weverything; then
400 cc_check -Wbad-function-cast
401 cc_check -Wcast-align
404 cc_check -Wmissing-prototypes
407 cc_check -Wwrite-strings
408 cc_check -Wno-long-long
412 if feat_yes AMALGAMATION && feat_no DEVEL; then
413 cc_check -Wno-unused-function
415 feat_no DEVEL && cc_check -Wno-unused-result # XXX do right way (pragma too)
417 cc_check -fno-unwind-tables
418 cc_check -fno-asynchronous-unwind-tables
419 cc_check -fstrict-aliasing
420 if cc_check -fstrict-overflow && feat_yes DEVEL; then
421 cc_check -Wstrict-overflow=5
424 if feat_yes DEBUG || feat_yes FORCED_STACKPROT; then
425 if [ -z "${force_no_stackprot}" ]; then
426 if cc_check -fstack-protector-strong ||
427 cc_check -fstack-protector-all; then
428 cc_check -D_FORTIFY_SOURCE=2
431 msg 'Not checking
for -fstack-protector compiler option
,'
432 msg 'since that caused errors
in a
"similar" configuration.
'
433 msg 'You may turn off WANT_AUTOCC and use your own settings
, rerun
'
437 if feat_yes AMALGAMATION; then
441 # LD (+ dependend CC)
443 if feat_yes DEVEL; then
446 #if cc_check -fsanitize=memory &&
447 # ld_check -fsanitize=memory &&
448 # cc_check -fsanitize-memory-track-origins=2 &&
449 # ld_check -fsanitize-memory-track-origins=2; then
456 ld_check -Wl,-z,relro
458 ld_check -Wl,-z,noexecstack
460 # Address randomization
462 if cc_check -fPIE || cc_check -fpie; then
463 ld_check -pie || _CFLAGS=${_ccfg}
467 _CFLAGS="${_CFLAGS} ${__cflags}" _LDFLAGS="${_LDFLAGS} ${__ldflags}"
468 unset __cflags __ldflags
474 ## - Heirloom sh(1) (and same origin) have _sometimes_ problems with ': >'
475 ## redirection, so use "printf '' >" instead
477 ## Very first: we undergo several states regarding I/O redirection etc.,
478 ## but need to deal with option updates from within all. Since all the
479 ## option stuff should be above the scissor line, define utility functions
480 ## and redefine them as necessary.
481 ## And, since we have those functions, simply use them for whatever
490 printf >&2 -- "${fmt}\\n" "${@}"
493 ## First of all, create new configuration and check wether it changed
497 h=./config.h h_name=config.h
500 newlst=./config.lst-new
501 newmk=./config.mk-new
507 t1=ten10one1ten10one1
508 if ( [ ${t1##*ten10} = one1 ] && [ ${t1#*ten10} = one1ten10one1 ] &&
509 [ ${t1%%one1*} = ten10 ] && [ ${t1%one1*} = ten10one1ten10 ]
510 ) > /dev/null 2>&1; then
517 # We need some standard utilities
520 n=${1} i=${2} opt=${3:-0}
521 # Evaluate, just in case user comes in with shell snippets (..well..)
523 if type "${i}" >/dev/null 2>&1; then # XXX why have i type not command -v?
524 [ -n "${VERBOSE}" ] && msg ' . $%s ... "%s"' "${n}" "${i}"
528 if [ ${opt} -eq 0 ]; then
529 msg 'ERROR
: no trace of utility
"%s"' "${n}"
535 # Very easy checks for the operating system in order to be able to adjust paths
536 # or similar very basic things which we need to be able to go at all
539 # Check those tools right now that we need before including $rc
540 msg 'Checking
for basic utility
set'
541 check_tool awk "${awk:-`command -v awk`}"
542 check_tool rm "${rm:-`command -v rm`}"
543 check_tool tr "${tr:-`command -v tr`}"
545 # Our feature check environment
548 [ "x${1}" = xfalse ] || [ "x${1}" = xno ] || [ "x${1}" = xoff ]
553 [ "x${1}" = xtrue ] || [ "x${1}" = xyes ] || [ "x${1}" = xon ] ||
554 [ "x${1}" = xrequire ]
558 [ "x${1}" = xrequire ]
563 i="`echo ${i} | ${tr} '[A-Z
]' '[a-z
]'`"
564 if feat_val_no "${i}"; then
566 elif feat_val_yes "${i}"; then
569 msg "ERROR: %s: any of 0/false/no/off or 1/true/yes/on/require, got: %s" \
580 _feat_check ${1} && return 1
586 i="`echo ${i} | ${tr} '[A-Z
]' '[a-z
]'`"
587 [ "x${i}" = xrequire ] || [ "x${i}" = xrequired ]
590 feat_bail_required() {
591 if feat_require ${1}; then
592 msg 'ERROR
: feature WANT_
%s is required but not available
' "${1}"
596 option_update # XXX this is rather useless here (dependency chain..)
599 # Include $rc, but only take from it what wasn't overwritten by the user from
600 # within the command line or from a chosen fixed CONFIG=
601 # Note we leave alone the values
602 trap "exit 1" HUP INT TERM
603 trap "${rm} -f ${tmp}" EXIT
605 printf >&2 'Reading and preparing configuration from "%s" ... ' ${rc}
607 # We want read(1) to perform backslash escaping in order to be able to use
608 # multiline values in make.rc; the resulting sh(1)/sed(1) code was very slow in
609 # VMs (see [fa2e248]), Aharon Robbins suggested the following
610 < ${rc} ${awk} 'BEGIN{line = ""}{
611 gsub
(/^
[[:space
:]]+/, "", $0)
612 gsub
(/[[:space
:]]+$
/, "", $0)
613 if(gsub
(/\\$
/, "", $0)){
618 if(index
(line
, "#") == 1){
620 }else if(length
(line
)){
626 if [ -n "${good_shell}" ]; then
629 i=`${awk} -v LINE="${line}" 'BEGIN
{
630 gsub
(/=.
*$
/, "", LINE
)
634 if [ "${i}" = "${line}" ]; then
635 msg 'ERROR
: invalid syntax
in "%s"' "${line}"
639 eval j="\$${i}" jx="\${${i}+x}"
640 if [ -n "${j}" ] || [ "${jx}" = x ]; then
643 j=`${awk} -v LINE="${line}" 'BEGIN
{
644 gsub
(/^
[^
=]*=/, "", LINE
)
645 gsub
(/^
\"*/, "", LINE
)
646 gsub
(/\"*$
/, "", LINE
)
652 # Reread the mixed version right now
656 # We need to know about that now, in order to provide utility overwrites etc.
659 msg 'Checking
for remaining
set of utilities
'
660 check_tool grep "${grep:-`command -v grep`}"
662 # Before we step ahead with the other utilities perform a path cleanup first.
663 # We need this function also for C_INCLUDE_PATH and LD_LIBRARY_PATH
664 # "path_check VARNAME" or "path_check VARNAME FLAG VARNAME"
666 varname=${1} addflag=${2} flagvarname=${3}
674 [ -z "${i}" ] && continue
675 [ -d "${i}" ] || continue
676 if [ -n "${j}" ]; then
677 if { z=${y}; echo "${z}"; } | ${grep} ":${i}:" >/dev/null 2>&1; then
682 [ -n "${addflag}" ] && k="${k} ${addflag}${i}"
687 [ -n "${addflag}" ] && k="${addflag}${i}"
690 eval "${varname}=\"${j}\""
691 [ -n "${addflag}" ] && eval "${flagvarname}=\"${k}\""
698 check_tool cat "${cat:-`command -v cat`}"
699 check_tool chmod "${chmod:-`command -v chmod`}"
700 check_tool cp "${cp:-`command -v cp`}"
701 check_tool cmp "${cmp:-`command -v cmp`}"
703 check_tool mkdir "${mkdir:-`command -v mkdir`}"
704 check_tool mv "${mv:-`command -v mv`}"
706 check_tool sed "${sed:-`command -v sed`}"
707 check_tool sort "${sort:-`command -v sort`}"
708 check_tool tee "${tee:-`command -v tee`}"
710 check_tool chown "${chown:-`command -v chown`}" 1 ||
711 check_tool chown "/sbin/chown" 1 ||
712 check_tool chown "/usr/sbin/chown"
714 check_tool make "${MAKE:-`command -v make`}"
716 check_tool strip "${STRIP:-`command -v strip`}" 1 &&
717 HAVE_STRIP=1 || HAVE_STRIP=0
719 # For ./cc-test.sh only
720 check_tool cksum "${cksum:-`command -v cksum`}"
722 # Update WANT_ options now, in order to get possible inter-dependencies right
725 # (No functions since some shells loose non-exported variables in traps)
726 trap "trap \"\" HUP INT TERM; exit 1" HUP INT TERM
727 trap "trap \"\" HUP INT TERM EXIT;\
728 ${rm} -rf ${newlst} ${tmp0}.* ${tmp0}* ${newmk} ${newh}" EXIT
730 # Our configuration options may at this point still contain shell snippets,
731 # we need to evaluate them in order to get them expanded, and we need those
732 # evaluated values not only in our new configuration file, but also at hand..
733 printf >&2 'Evaluating all configuration items ...
'
734 ${rm} -f ${newlst} ${newmk} ${newh}
735 exec 5<&0 6>&1 <${tmp} >${newlst}
738 if [ -n "${good_shell}" ]; then
740 [ "${i}" != "${i#WANT_}" ] && z=1
742 i=`${awk} -v LINE="${line}" 'BEGIN
{
743 gsub
(/=.
*$
/, "", LINE
);\
746 if echo "${i}" | ${grep} '^WANT_
' >/dev/null 2>&1; then
752 if [ -n "${z}" ]; then
753 j="`echo ${j} | ${tr} '[A-Z
]' '[a-z
]'`"
754 if [ -z "${j}" ] || feat_val_no "${j}"; then
756 printf "/*#define ${i}*/\n" >> ${newh}
757 elif feat_val_yes "${j}"; then
758 if feat_val_require "${j}"; then
763 printf "#define ${i}\n" >> ${newh}
765 msg 'ERROR
: cannot parse
<%s
>' "${line}"
769 printf "#define ${i} \"${j}\"\n" >> ${newh}
771 printf "${i} = ${j}\n" >> ${newmk}
775 exec 0<&5 1>&6 5<&- 6<&-
778 # Add the known utility and some other variables
779 printf "#define UAGENT \"${SID}${NAIL}\"\n" >> ${newh}
780 printf "UAGENT = ${SID}${NAIL}\n" >> ${newmk}
782 printf "#define PRIVSEP \"${SID}${NAIL}-privsep\"\n" >> ${newh}
783 printf "PRIVSEP = \$(UAGENT)-privsep\n" >> ${newmk}
784 if feat_yes DOTLOCK; then
785 printf "OPTIONAL_PRIVSEP = \$(PRIVSEP)\n" >> ${newmk}
787 printf "OPTIONAL_PRIVSEP =\n" >> ${newmk}
791 awk cat chmod chown cp cmp grep mkdir mv rm sed sort tee tr \
795 printf "${i} = ${j}\n" >> ${newmk}
796 printf "${i}=${j}\n" >> ${newlst}
799 # Build a basic set of INCS and LIBS according to user environment.
800 path_check C_INCLUDE_PATH -I _INCS
801 INCS="${INCS} ${_INCS}"
802 path_check LD_LIBRARY_PATH -L _LIBS
803 LIBS="${LIBS} ${_LIBS}"
805 export C_INCLUDE_PATH LD_LIBRARY_PATH
807 if [ -n "${need_R_ldflags}" ]; then
810 set -- ${LD_LIBRARY_PATH}
814 LDFLAGS="${LDFLAGS} ${need_R_ldflags}${i}"
815 _LDFLAGS="${_LDFLAGS} ${need_R_ldflags}${i}"
820 ## Detect CC, wether we can use it, and possibly which CFLAGS we can use
824 ${cat} > ${tmp}.c << \!
827 static void doit(char const *s);
829 main(int argc, char **argv){
843 if "${CC}" ${INCS} ${CFLAGS} ${ADDCFLAGS} ${LDFLAGS} ${ADDLDFLAGS} \
844 -o ${tmp2} ${tmp}.c ${LIBS}; then
847 msg 'ERROR
: i cannot compile a
"Hello world" via
'
849 "${CC} ${INCS} ${CFLAGS} ${ADDCFLAGS} ${LDFLAGS} ${ADDLDFLAGS} ${LIBS}"
850 msg 'ERROR
: Please
read INSTALL
, rerun
'
855 [ -n "${cc_check_silent}" ] || printf >&2 ' . CC
%s ..
' "${1}"
856 if "${CC}" ${INCS} ${_CFLAGS} ${1} ${ADDCFLAGS} ${_LDFLAGS} ${ADDLDFLAGS} \
857 -o ${tmp2} ${tmp}.c ${LIBS} >/dev/null 2>&1; then
858 _CFLAGS="${_CFLAGS} ${1}"
859 [ -n "${cc_check_silent}" ] || printf >&2 'yes\n'
862 [ -n "${cc_check_silent}" ] || printf >&2 'no
\n'
867 [ -n "${cc_check_silent}" ] || printf >&2 ' . LD
%s ..
' "${1}"
868 if "${CC}" ${INCS} ${_CFLAGS} ${_LDFLAGS} ${1} ${ADDLDFLAGS} \
869 -o ${tmp2} ${tmp}.c ${LIBS} >/dev/null 2>&1; then
870 _LDFLAGS="${_LDFLAGS} ${1}"
871 [ -n "${cc_check_silent}" ] || printf >&2 'yes\n'
874 [ -n "${cc_check_silent}" ] || printf >&2 'no
\n'
884 printf -- "${i}=${j}\n" >> ${newlst}
890 PATH C_INCLUDE_PATH LD_LIBRARY_PATH \
894 printf -- "${i} = ${j}\n" >> ${newmk}
895 printf -- "${i}=${j}\n" >> ${newlst}
898 # Now finally check wether we already have a configuration and if so, wether
899 # all those parameters are still the same.. or something has actually changed
900 if [ -f ${lst} ] && ${cmp} ${newlst} ${lst} >/dev/null 2>&1; then
901 echo 'Configuration is up-to-date
'
903 elif [ -f ${lst} ]; then
904 echo 'Configuration has been updated..
'
905 ( eval "${MAKE} -f ./mk.mk clean" )
908 echo 'Shiny configuration..
'
911 # Time to redefine helper 1
913 ${rm} -f ${lst} ${h} ${mk}
917 ${mv} -f ${newlst} ${lst}
918 ${mv} -f ${newh} ${h}
919 ${mv} -f ${newmk} ${mk}
921 ## Compile and link checking
929 # (No function since some shells loose non-exported variables in traps)
930 trap "trap \"\" HUP INT TERM;\
931 ${rm} -f ${lst} ${h} ${mk} ${lib} ${inc}; exit 1" HUP INT TERM
932 trap "trap \"\" HUP INT TERM EXIT;\
933 ${rm} -rf ${tmp0}.* ${tmp0}* ${makefile}" EXIT
935 # Time to redefine helper 2
939 printf "*** ${fmt}\\n" "${@}"
940 printf -- "${fmt}\\n" "${@}" >&5
945 printf "*** ${fmt}\\n" "${@}"
946 printf -- "${fmt}" "${@}" >&5
949 exec 5>&2 > ${log} 2>&1
951 echo "${LIBS}" > ${lib}
952 echo "${INCS}" > ${inc}
953 ${cat} > ${makefile} << \!
954 .SUFFIXES: .o .c .x .y
956 $(CC) -I./ $(XINCS) $(CFLAGS) -c $<
958 $(CC) -I./ $(XINCS) -E $< >$@
960 $(CC) -I./ $(XINCS) $(CFLAGS) $(LDFLAGS) -o $@ $< $(XLIBS)
965 variable=$1 topic=$2 define=$3
968 msg_nonl ' .
%s ...
' "${topic}"
969 echo "/* checked ${topic} */" >> ${h}
970 ${rm} -f ${tmp} ${tmp}.o
971 echo '*** test program is
'
972 { echo '#include <'"${h_name}"'>'; cat; } | ${tee} ${tmp}.c
973 #echo '*** the preprocessor generates'
974 #${make} -f ${makefile} ${tmp}.x
976 echo '*** results are'
980 variable
=$1 topic
=$2 define
=$3
982 _check_preface
"${variable}" "${topic}" "${define}"
984 if ${make} -f ${makefile} XINCS="${INCS}" ./${tmp}.o
&&
985 [ -f .
/${tmp}.o
]; then
987 echo "${define}" >> ${h}
988 eval have_
${variable}=yes
991 echo "/* ${define} */" >> ${h}
993 eval unset have_
${variable}
999 run
=$1 variable
=$2 topic
=$3 define
=$4 libs
=$5 incs
=$6
1001 _check_preface
"${variable}" "${topic}" "${define}"
1003 if ${make} -f ${makefile} XINCS="${INCS} ${incs}" \
1004 XLIBS="${LIBS} ${libs}" ./${tmp} &&
1006 { [ ${run} -eq 0 ] || ./${tmp}; }; then
1007 echo "*** adding INCS<${incs}> LIBS<${libs}>; executed: ${run}"
1009 echo "${define}" >> ${h}
1010 LIBS
="${LIBS} ${libs}"
1011 echo "${libs}" >> ${lib}
1012 INCS
="${INCS} ${incs}"
1013 echo "${incs}" >> ${inc}
1014 eval have_
${variable}=yes
1018 echo "/* ${define} */" >> ${h}
1019 eval unset have_
${variable}
1025 _link_mayrun
0 "${1}" "${2}" "${3}" "${4}" "${5}"
1029 _link_mayrun
1 "${1}" "${2}" "${3}" "${4}" "${5}"
1034 # May be multiline..
1035 [ -n "${OS_DEFINES}" ] && printf -- "${OS_DEFINES}" >> ${h}
1037 if run_check clock_gettime 'clock_gettime(2)' \
1038 '#define HAVE_CLOCK_GETTIME' << \!
1044 if(!clock_gettime(CLOCK_REALTIME, &ts) || errno != ENOSYS)
1051 elif run_check clock_gettime 'clock_gettime(2) (via -lrt)' \
1052 '#define HAVE_CLOCK_GETTIME' '-lrt' << \!
1058 if(!clock_gettime(CLOCK_REALTIME, &ts) || errno != ENOSYS)
1065 elif run_check gettimeofday 'gettimeofday(2)' \
1066 '#define HAVE_GETTIMEOFDAY' << \!
1067 #include <stdio.h> /* For C89 NULL */
1068 #include <sys/time.h>
1073 if(!gettimeofday(&tv, NULL) || errno != ENOSYS)
1081 have_no_subsecond_time=1
1084 if run_check userdb 'gete?[gu]id(2), getpwuid(3), getpwnam(3)' << \!
1093 if((gid = getgid()) != 0)
1095 if((uid = getuid()) != 0)
1097 if((pw = getpwuid(uid)) == NULL && errno == ENOSYS)
1099 if((pw = getpwnam("root
")) == NULL && errno == ENOSYS)
1107 msg 'ERROR: we require user and group info / database searches.'
1108 msg 'That much Unix we indulge ourselfs.'
1112 if link_check snprintf 'v?snprintf(3)' << \!
1115 static void dome(char *buf, ...){
1119 vsnprintf(buf, 20, "%s
", ap);
1126 snprintf(b, sizeof b, "%s
", "string
");
1134 msg 'ERROR: we require the snprintf(3) and vsnprintf(3) functions.'
1138 if link_check environ 'environ(3)' << \!
1139 #include <stdio.h> /* For C89 NULL */
1141 extern char **environ;
1143 return environ[0] == NULL;
1149 msg 'ERROR: we require the environ(3) array for subprocess control.'
1153 if link_check termios 'termios.h and tc*(3) family' << \!
1154 #include <termios.h>
1156 struct termios tios;
1158 tcgetattr(0, &tios);
1159 tcsetattr(0, TCSADRAIN | TCSAFLUSH, &tios);
1166 msg 'ERROR: we require termios.h and the tc*() family of functions.'
1167 msg 'That much Unix we indulge ourselfs.'
1173 link_check mmap 'mmap(2)' '#define HAVE_MMAP' << \!
1174 #include <sys/types.h>
1175 #include <sys/mman.h>
1178 mmap(0, 0, 0, 0, 0, 0);
1183 link_check mremap 'mremap(2)' '#define HAVE_MREMAP' << \!
1184 #include <sys/types.h>
1185 #include <sys/mman.h>
1188 mremap(0, 0, 0, MREMAP_MAYMOVE);
1193 run_check pathconf 'pathconf(2)' '#define HAVE_PATHCONF' << \!
1200 rv |= !(pathconf(".
", _PC_NAME_MAX) >= 0 || errno == 0 || errno != ENOSYS);
1202 rv |= !(pathconf(".
", _PC_PATH_MAX) >= 0 || errno == 0 || errno != ENOSYS);
1207 run_check pipe2 'pipe2(2)' '#define HAVE_PIPE2' << \!
1214 if(!pipe2(fds, O_CLOEXEC) || errno != ENOSYS)
1220 # We use this only then for now (need NOW+1)
1221 run_check utimensat 'utimensat(2)' '#define HAVE_UTIMENSAT' << \!
1222 #include <fcntl.h> /* For AT_* */
1223 #include <sys/stat.h>
1226 struct timespec ts[2];
1228 ts[0].tv_nsec = UTIME_NOW;
1229 ts[1].tv_nsec = UTIME_OMIT;
1230 if(!utimensat(AT_FDCWD, "", ts, 0) || errno != ENOSYS)
1238 # XXX Add POSIX check once standardized
1239 if link_check posix_random 'arc4random(3)' '#define HAVE_POSIX_RANDOM 0' << \!
1248 elif [ -n "${have_no_subsecond_time}" ]; then
1249 msg 'ERROR: %s %s' 'without a native random' \
1250 'one of clock_gettime(2) and gettimeofday(2) is required.'
1254 link_check setenv 'setenv(3)/unsetenv(3)' '#define HAVE_SETENV' << \!
1257 setenv("s-nail
", "to be made nifty
!", 1);
1263 link_check putc_unlocked 'putc_unlocked(3)' '#define HAVE_PUTC_UNLOCKED' <<\!
1266 putc_unlocked('@', stdout);
1271 link_check fchdir 'fchdir(3)' '#define HAVE_FCHDIR' << \!
1279 link_check setlocale 'setlocale(3)' '#define HAVE_SETLOCALE' << \!
1282 setlocale(LC_ALL, "");
1287 if [ "${have_setlocale}" = yes ]; then
1288 link_check c90amend1 'ISO/IEC 9899:1990/Amendment 1:1995' \
1289 '#define HAVE_C90AMEND1' << \!
1295 char mbb[MB_LEN_MAX + 1];
1300 mbtowc(&wc, "x
", 1);
1301 mbrtowc(&wc, "x
", 1, NULL);
1303 return (mblen("\
0", 1) == 0);
1307 if [ "${have_c90amend1}" = yes ]; then
1308 link_check wcwidth 'wcwidth(3)' '#define HAVE_WCWIDTH' << \!
1317 link_check nl_langinfo 'nl_langinfo(3)' '#define HAVE_NL_LANGINFO' << \!
1318 #include <langinfo.h>
1322 return (nl_langinfo(CODESET) == NULL);
1327 run_check realpath 'realpath(3)' '#define HAVE_REALPATH' << \!
1330 #if 1 /* TODO for now we use realpath(3) without NULL as 2nd arg! */
1331 /* (And note that on Linux tcc(1) otherwise didn't detect once tested! */
1332 char x_buf[4096], *x = realpath(".
", x_buf);
1334 return (x != NULL) ? 0 : 1;
1336 char *x = realpath(".
", NULL), *y = realpath("/", NULL);
1338 return (x != NULL && y != NULL) ? 0 : 1;
1343 link_check wordexp 'wordexp(3)' '#define HAVE_WORDEXP' << \!
1344 #include <stdio.h> /* For C89 NULL */
1345 #include <wordexp.h>
1347 wordexp(NULL, NULL, 0);
1354 if feat_yes DEBUG; then
1355 echo '#define HAVE_DEBUG' >> ${h}
1358 if feat_yes AMALGAMATION; then
1359 echo '#define HAVE_AMALGAMATION' >> ${h}
1362 if feat_no NOALLOCA; then
1363 # Due to NetBSD PR lib/47120 it seems best not to use non-cc-builtin
1364 # versions of alloca(3) since modern compilers just can't be trusted
1365 # not to overoptimize and silently break some code
1366 run_check alloca '__builtin_alloca()' \
1367 '#define HAVE_ALLOCA __builtin_alloca' << \!
1368 #include <stdio.h> /* For C89 NULL */
1370 void *vp = __builtin_alloca(1);
1372 return (vp != NULL);
1377 if feat_yes DEVEL; then
1378 echo '#define HAVE_DEVEL' >> ${h}
1381 if feat_yes NYD2; then
1382 echo '#define HAVE_NYD2' >> ${h}
1387 if feat_yes DOTLOCK; then
1388 if run_check readlink 'readlink(2)' << \!
1394 if(!readlink("here
", buf, sizeof buf) || errno != ENOSYS)
1402 feat_bail_required DOTLOCK
1406 if feat_yes DOTLOCK; then
1407 if run_check fchown 'fchown(2)' << \!
1411 if(!fchown(0, 0, 0) || errno != ENOSYS)
1419 feat_bail_required DOTLOCK
1425 if feat_yes ICONV; then
1426 ${cat} > ${tmp2}.c << \!
1427 #include <stdio.h> /* For C89 NULL */
1432 id = iconv_open("foo
", "bar
");
1433 iconv(id, NULL, NULL, NULL, NULL);
1438 < ${tmp2}.c link_check iconv 'iconv(3) functionality' \
1439 '#define HAVE_ICONV' ||
1440 < ${tmp2}.c link_check iconv 'iconv(3) functionality (via -liconv)' \
1441 '#define HAVE_ICONV' '-liconv' ||
1442 feat_bail_required ICONV
1444 echo '/* WANT_ICONV=0 */' >> ${h}
1447 if feat_yes SOCKETS || feat_yes SPAM_SPAMD; then
1448 ${cat} > ${tmp2}.c << \!
1449 #include <sys/types.h>
1450 #include <sys/socket.h>
1454 struct sockaddr_un soun;
1456 if(socket(AF_UNIX, SOCK_STREAM, 0) == -1 && errno == ENOSYS)
1458 if(connect(0, (struct sockaddr*)&soun, 0) == -1 && errno == ENOSYS)
1460 if(shutdown(0, SHUT_RD | SHUT_WR | SHUT_RDWR) == -1 && errno == ENOSYS)
1466 < ${tmp2}.c run_check af_unix 'AF_UNIX sockets' \
1467 '#define HAVE_UNIX_SOCKETS' ||
1468 < ${tmp2}.c run_check af_unix 'AF_UNIX sockets (via -lnsl)' \
1469 '#define HAVE_UNIX_SOCKETS' '-lnsl' ||
1470 < ${tmp2}.c run_check af_unix 'AF_UNIX sockets (via -lsocket -lnsl)' \
1471 '#define HAVE_UNIX_SOCKETS' '-lsocket -lnsl'
1474 if feat_yes SOCKETS; then
1475 ${cat} > ${tmp2}.c << \!
1477 #include <sys/types.h>
1478 #include <sys/socket.h>
1479 #include <netinet/in.h>
1484 if(socket(AF_INET, SOCK_STREAM, 0) == -1 && errno == ENOSYS)
1486 if(connect(0, &s, 0) == -1 && errno == ENOSYS)
1492 < ${tmp2}.c run_check sockets 'sockets' \
1493 '#define HAVE_SOCKETS' ||
1494 < ${tmp2}.c run_check sockets 'sockets (via -lnsl)' \
1495 '#define HAVE_SOCKETS' '-lnsl' ||
1496 < ${tmp2}.c run_check sockets 'sockets (via -lsocket -lnsl)' \
1497 '#define HAVE_SOCKETS' '-lsocket -lnsl' ||
1498 feat_bail_required SOCKETS
1500 echo '/* WANT_SOCKETS=0 */' >> ${h}
1501 fi # feat_yes SOCKETS
1503 if feat_yes SOCKETS; then
1504 link_check getaddrinfo 'getaddrinfo(3)' \
1505 '#define HAVE_GETADDRINFO' << \!
1507 #include <sys/types.h>
1508 #include <sys/socket.h>
1512 struct addrinfo a, *ap;
1515 switch((lrv = getaddrinfo("foo
", "0", &a, &ap))){
1519 fprintf(stderr, "%s
\n", gai_strerror(lrv));
1528 if feat_yes SOCKETS && [ -z "${have_getaddrinfo}" ]; then
1529 compile_check arpa_inet_h '<arpa/inet.h>' \
1530 '#define HAVE_ARPA_INET_H' << \!
1532 #include <sys/types.h>
1533 #include <sys/socket.h>
1535 #include <netinet/in.h>
1536 #include <arpa/inet.h>
1539 ${cat} > ${tmp2}.c << \!
1541 #include <sys/types.h>
1542 #include <sys/socket.h>
1546 #include <netinet/in.h>
1547 #ifdef HAVE_ARPA_INET_H
1548 #include <arpa/inet.h>
1551 struct sockaddr_in servaddr;
1552 unsigned short portno;
1555 struct in_addr **pptr;
1558 if((ep = getservbyname("POPPY-PORT
", "tcp
")) != NULL)
1559 portno = (unsigned short)ep->s_port;
1561 if((hp = gethostbyname("POPPY-HOST
")) != NULL){
1562 pptr = (struct in_addr**)hp->h_addr_list;
1563 if(hp->h_addrtype != AF_INET)
1564 fprintf(stderr, "au
\n");
1567 case HOST_NOT_FOUND:
1573 fprintf(stderr, "au
\n");
1578 memset(&servaddr, 0, sizeof servaddr);
1579 servaddr.sin_family = AF_INET;
1580 servaddr.sin_port = htons(portno);
1581 memcpy(&servaddr.sin_addr, *pptr, sizeof(struct in_addr));
1582 fprintf(stderr, "Would connect to
%s
:%d ...
\n",
1583 inet_ntoa(**pptr), (int)portno);
1588 < ${tmp2}.c link_check gethostbyname 'get(serv|host)byname(3)' ||
1589 < ${tmp2}.c link_check gethostbyname \
1590 'get(serv|host)byname(3) (via -nsl)' '' '-lnsl' ||
1591 < ${tmp2}.c link_check gethostbyname \
1592 'get(serv|host)byname(3) (via -lsocket -nsl)' \
1593 '' '-lsocket -lnsl' ||
1594 feat_bail_required SOCKETS
1598 run_check setsockopt 'setsockopt(2)' '#define HAVE_SETSOCKOPT' << \!
1599 #include <sys/socket.h>
1605 if(setsockopt(sockfd, SOL_SOCKET, SO_KEEPALIVE, NULL, 0) == -1 &&
1612 feat_yes SOCKETS && [ -n "${have_setsockopt}" ] &&
1613 link_check so_sndtimeo 'SO_SNDTIMEO' '#define HAVE_SO_SNDTIMEO' << \!
1614 #include <sys/socket.h>
1622 setsockopt(sockfd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof tv);
1623 setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof tv);
1628 feat_yes SOCKETS && [ -n "${have_setsockopt}" ] &&
1629 link_check so_linger 'SO_LINGER' '#define HAVE_SO_LINGER' << \!
1630 #include <sys/socket.h>
1638 setsockopt(sockfd, SOL_SOCKET, SO_LINGER, &li, sizeof li);
1643 if feat_yes SSL; then
1644 if link_check openssl 'OpenSSL (new style *_client_method(3ssl))' \
1646 #define HAVE_OPENSSL 10100' '-lssl -lcrypto' << \!
1647 #include <openssl/ssl.h>
1648 #include <openssl/err.h>
1649 #include <openssl/x509v3.h>
1650 #include <openssl/x509.h>
1651 #include <openssl/rand.h>
1652 #ifdef OPENSSL_NO_TLS1 /* TODO only deduced from OPENSSL_NO_SSL[23]! */
1653 # error We need TLSv1.
1656 SSL_CTX *ctx = SSL_CTX_new(TLS_client_method());
1659 PEM_read_PrivateKey(0, 0, 0, 0);
1665 elif link_check openssl 'OpenSSL (old style *_client_method(3ssl))' \
1667 #define HAVE_OPENSSL 10000' '-lssl -lcrypto' << \!
1668 #include <openssl/ssl.h>
1669 #include <openssl/err.h>
1670 #include <openssl/x509v3.h>
1671 #include <openssl/x509.h>
1672 #include <openssl/rand.h>
1673 #if defined OPENSSL_NO_SSL3 &&\
1674 defined OPENSSL_NO_TLS1 /* TODO only deduced from OPENSSL_NO_SSL[23]! */
1675 # error We need one of SSLv3 and TLSv1.
1678 SSL_CTX *ctx = SSL_CTX_new(SSLv23_client_method());
1681 PEM_read_PrivateKey(0, 0, 0, 0);
1688 feat_bail_required SSL
1691 if [ "${have_openssl}" = 'yes' ]; then
1692 compile_check stack_of 'OpenSSL STACK_OF()' \
1693 '#define HAVE_OPENSSL_STACK_OF' << \!
1694 #include <stdio.h> /* For C89 NULL */
1695 #include <openssl/ssl.h>
1696 #include <openssl/err.h>
1697 #include <openssl/x509v3.h>
1698 #include <openssl/x509.h>
1699 #include <openssl/rand.h>
1701 STACK_OF(GENERAL_NAME) *gens = NULL;
1703 printf("%p
", gens); /* to use it */
1708 link_check ossl_conf 'OpenSSL_modules_load_file() support' \
1709 '#define HAVE_OPENSSL_CONFIG' << \!
1710 #include <stdio.h> /* For C89 NULL */
1711 #include <openssl/conf.h>
1713 CONF_modules_load_file(NULL, NULL, CONF_MFLAGS_IGNORE_MISSING_FILE);
1714 CONF_modules_free();
1719 link_check ossl_conf_ctx 'OpenSSL SSL_CONF_CTX support' \
1720 '#define HAVE_OPENSSL_CONF_CTX' << \!
1722 #include <openssl/ssl.h>
1723 #include <openssl/err.h>
1725 #if HAVE_OPENSSL < 10100
1726 SSL_CTX *ctx = SSL_CTX_new(SSLv23_client_method());
1728 SSL_CTX *ctx = SSL_CTX_new(TLS_client_method());
1730 SSL_CONF_CTX *cctx = SSL_CONF_CTX_new();
1732 SSL_CONF_CTX_set_flags(cctx,
1733 SSL_CONF_FLAG_FILE | SSL_CONF_FLAG_CLIENT |
1734 SSL_CONF_FLAG_CERTIFICATE | SSL_CONF_FLAG_SHOW_ERRORS);
1735 SSL_CONF_CTX_set_ssl_ctx(cctx, ctx);
1736 SSL_CONF_cmd(cctx, "Protocol
", "ALL
");
1737 SSL_CONF_CTX_finish(cctx);
1738 SSL_CONF_CTX_free(cctx);
1744 link_check rand_egd 'OpenSSL RAND_egd()' \
1745 '#define HAVE_OPENSSL_RAND_EGD' << \!
1746 #include <openssl/rand.h>
1748 return RAND_egd("some.where
") > 0;
1752 if feat_yes SSL_ALL_ALGORITHMS; then
1753 if link_check ssl_all_algo 'OpenSSL all-algorithms support' \
1754 '#define HAVE_SSL_ALL_ALGORITHMS' << \!
1755 #include <openssl/evp.h>
1757 OpenSSL_add_all_algorithms();
1758 EVP_get_cipherbyname("two cents i never exist
");
1766 feat_bail_required SSL_ALL_ALGORITHMS
1768 fi # SSL_ALL_ALGORITHMS
1770 if feat_yes MD5 && feat_no NOEXTMD5; then
1771 run_check openssl_md5 'MD5 digest in OpenSSL' \
1772 '#define HAVE_OPENSSL_MD5' << \!
1775 #include <openssl/md5.h>
1777 char const dat[] = "abrakadabrafidibus
";
1778 char dig[16], hex[16 * 2];
1782 memset(dig, 0, sizeof(dig));
1783 memset(hex, 0, sizeof(hex));
1785 MD5_Update(&ctx, dat, sizeof(dat) - 1);
1786 MD5_Final(dig, &ctx);
1788 #define hexchar(n) ((n) > 9 ? (n) - 10 + 'a' : (n) + '0')
1789 for(i = 0; i < sizeof(hex) / 2; i++){
1791 hex[j] = hexchar((dig[i] & 0xf0) >> 4);
1792 hex[++j] = hexchar(dig[i] & 0x0f);
1794 return !!memcmp("6d7d0a3d949da2e96f2aa010f65d8326
", hex, sizeof(hex));
1797 fi # feat_yes MD5 && feat_no NOEXTMD5
1800 echo '/* WANT_SSL=0 */' >> ${h}
1803 if feat_yes SMTP; then
1804 echo '#define HAVE_SMTP' >> ${h}
1806 echo '/* WANT_SMTP=0 */' >> ${h}
1809 if feat_yes POP3; then
1810 echo '#define HAVE_POP3' >> ${h}
1812 echo '/* WANT_POP3=0 */' >> ${h}
1815 if feat_yes IMAP; then
1816 echo '#define HAVE_IMAP' >> ${h}
1818 echo '/* WANT_IMAP=0 */' >> ${h}
1821 if feat_yes GSSAPI; then
1822 ${cat} > ${tmp2}.c << \!
1823 #include <gssapi/gssapi.h>
1825 gss_import_name(0, 0, GSS_C_NT_HOSTBASED_SERVICE, 0);
1826 gss_init_sec_context(0,0,0,0,0,0,0,0,0,0,0,0,0);
1830 ${sed} -e '1s/gssapi\///' < ${tmp2}.c > ${tmp3}.c
1832 if command -v krb5-config >/dev/null 2>&1; then
1833 i=`command -v krb5-config`
1834 GSS_LIBS="`CFLAGS= ${i} --libs gssapi`"
1835 GSS_INCS="`CFLAGS= ${i} --cflags`"
1836 i='GSS-API via krb5-config(1)'
1840 i='GSS-API in gssapi/gssapi.h, libgssapi'
1842 if < ${tmp2}.c link_check gss \
1843 "${i}" '#define HAVE_GSSAPI' "${GSS_LIBS}" "${GSS_INCS}" ||\
1844 < ${tmp3}.c link_check gss \
1845 'GSS-API in gssapi.h, libgssapi' \
1846 '#define HAVE_GSSAPI
1847 #define GSSAPI_REG_INCLUDE' \
1849 < ${tmp2}.c link_check gss 'GSS-API in libgssapi_krb5' \
1850 '#define HAVE_GSSAPI' \
1852 < ${tmp3}.c link_check gss \
1853 'GSS-API in libgssapi, OpenBSD-style (pre 5.3)' \
1854 '#define HAVE_GSSAPI
1855 #define GSS_REG_INCLUDE' \
1856 '-lgssapi -lkrb5 -lcrypto' \
1857 '-I/usr/include/kerberosV' ||\
1858 < ${tmp2}.c link_check gss 'GSS-API in libgss' \
1859 '#define HAVE_GSSAPI' \
1861 link_check gss 'GSS-API in libgssapi_krb5, old-style' \
1862 '#define HAVE_GSSAPI
1863 #define GSSAPI_OLD_STYLE' \
1864 '-lgssapi_krb5' << \!
1865 #include <gssapi/gssapi.h>
1866 #include <gssapi/gssapi_generic.h>
1868 gss_import_name(0, 0, gss_nt_service_name, 0);
1869 gss_init_sec_context(0,0,0,0,0,0,0,0,0,0,0,0,0);
1876 feat_bail_required GSSAPI
1879 echo '/* WANT_GSSAPI=0 */' >> ${h}
1880 fi # feat_yes GSSAPI
1882 if feat_yes NETRC; then
1883 echo '#define HAVE_NETRC' >> ${h}
1885 echo '/* WANT_NETRC=0 */' >> ${h}
1888 if feat_yes AGENT; then
1889 echo '#define HAVE_AGENT' >> ${h}
1891 echo '/* WANT_AGENT=0 */' >> ${h}
1894 if feat_yes IDNA; then
1895 if link_check idna 'GNU Libidn' '#define HAVE_IDNA HAVE_IDNA_LIBIDNA' \
1898 #include <idn-free.h>
1899 #include <stringprep.h>
1901 char *utf8, *idna_ascii, *idna_utf8;
1903 utf8 = stringprep_locale_to_utf8("does.this.work
");
1904 if (idna_to_ascii_8z(utf8, &idna_ascii, IDNA_USE_STD3_ASCII_RULES)
1907 idn_free(idna_ascii);
1908 /* (Rather link check only here) */
1909 idna_utf8 = stringprep_convert(idna_ascii, "UTF-8
", "de_DE
");
1915 elif link_check idna 'idnkit' '#define HAVE_IDNA HAVE_IDNA_IDNKIT' \
1918 #include <idn/api.h>
1919 #include <idn/result.h>
1923 char local_name[256];
1925 r = idn_encodename(IDN_ENCODE_APP, "does.this.work
", ace_name,
1927 if (r != idn_success) {
1928 fprintf(stderr, "idn_encodename failed
: %s
\n", idn_result_tostring(r));
1931 r = idn_decodename(IDN_DECODE_APP, ace_name, local_name, sizeof(local_name));
1932 if (r != idn_success) {
1933 fprintf(stderr, "idn_decodename failed
: %s
\n", idn_result_tostring(r));
1942 feat_bail_required IDNA
1945 if [ -n "${have_idna}" ]; then
1946 echo '#define HAVE_IDNA_LIBIDNA 0' >> ${h}
1947 echo '#define HAVE_IDNA_IDNKIT 1' >> ${h}
1950 echo '/* WANT_IDNA=0 */' >> ${h}
1953 if feat_yes IMAP_SEARCH; then
1954 echo '#define HAVE_IMAP_SEARCH' >> ${h}
1956 echo '/* WANT_IMAP_SEARCH=0 */' >> ${h}
1959 if feat_yes REGEX; then
1960 if link_check regex 'regular expressions' '#define HAVE_REGEX' << \!
1967 if (regcomp(&re, ".
*bsd
", REG_EXTENDED | REG_ICASE | REG_NOSUB) != 0)
1969 status = regexec(&re, "plan9
", 0,NULL, 0);
1971 return !(status == REG_NOMATCH);
1977 feat_bail_required REGEX
1980 echo '/* WANT_REGEX=0 */' >> ${h}
1983 if feat_yes READLINE; then
1985 link_check readline "for readline
(3) (${1})" \
1986 '#define HAVE_READLINE' "${1}" << \!
1988 #include <readline/history.h>
1989 #include <readline/readline.h>
1998 stifle_history(242);
1999 rl = readline("Enter a line
:");
2003 rl_extend_line_buffer(10);
2004 rl_point = rl_end = 10;
2005 rl_pre_input_hook = (rl_hook_func_t*)NULL;
2006 rl_forced_update_display();
2008 hs = history_get_history_state();
2010 he = history_list();
2013 rl_free_line_state();
2014 rl_cleanup_after_signal();
2015 rl_reset_after_signal();
2021 __edrdlib -lreadline ||
2022 __edrdlib '-lreadline -ltermcap' || feat_bail_required READLINE
2023 [ -n "${have_readline}" ] && WANT_TABEXPAND=1
2026 if feat_yes EDITLINE && [ -z "${have_readline}" ]; then
2028 link_check editline "for editline
(3) (${1})" \
2029 '#define HAVE_EDITLINE' "${1}" << \!
2030 #include <stdio.h> /* For C89 NULL */
2031 #include <histedit.h>
2032 static char * getprompt(void) { return (char*)"ok
"; }
2035 EditLine *el_el = el_init("TEST
", stdin, stdout, stderr);
2037 History *el_hcom = history_init();
2038 history(el_hcom, &he, H_SETSIZE, 242);
2039 el_set(el_el, EL_SIGNAL, 0);
2040 el_set(el_el, EL_TERMINAL, NULL);
2041 el_set(el_el, EL_HIST, &history, el_hcom);
2042 el_set(el_el, EL_EDITOR, "emacs
");
2043 el_set(el_el, EL_PROMPT, &getprompt);
2044 el_source(el_el, NULL);
2045 history(el_hcom, &he, H_GETSIZE);
2046 history(el_hcom, &he, H_CLEAR);
2048 /* TODO add loader and addfn checks */
2049 history_end(el_hcom);
2056 __edlib '-ledit -ltermcap' || feat_bail_required EDITLINE
2057 [ -n "${have_editline}" ] && WANT_TABEXPAND=0
2060 if feat_yes NCL && [ -z "${have_editline}" ] && [ -z "${have_readline}" ] &&\
2061 [ -n "${have_c90amend1}" ]; then
2063 echo '#define HAVE_NCL' >> ${h}
2065 feat_bail_required NCL
2066 echo '/* WANT_{READLINE,EDITLINE,NCL}=0 */' >> ${h}
2069 # Generic have-a-command-line-editor switch for those who need it below
2070 if [ -n "${have_ncl}" ] || [ -n "${have_editline}" ] ||\
2071 [ -n "${have_readline}" ]; then
2075 if [ -n "${have_cle}" ] && feat_yes HISTORY; then
2076 echo '#define HAVE_HISTORY' >> ${h}
2078 echo '/* WANT_HISTORY=0 */' >> ${h}
2081 if [ -n "${have_cle}" ] && feat_yes TABEXPAND; then
2082 echo '#define HAVE_TABEXPAND' >> ${h}
2084 echo '/* WANT_TABEXPAND=0 */' >> ${h}
2087 if feat_yes TERMCAP; then
2089 link_check termcap "for termcap
(3) (via
${4})" \
2090 "#define HAVE_TERMCAP${3}" "${1}" << _EOT
2096 #define PTR2SIZE(X) ((unsigned long)(X))
2097 #define UNCONST(P) ((void*)(unsigned long)(void const*)(P))
2098 static char
*_termcap_buffer
, *_termcap_ti
, *_termcap_te
;
2100 char buf
[1024+512], cmdbuf
[2048], *cpb
, *cpti
, *cpte
, *cp;
2102 tgetent
(buf
, getenv
("TERM"));
2105 if ((cp = tgetstr
(UNCONST
("ti"), &cpb
)) == NULL
)
2108 if ((cp = tgetstr
(UNCONST
("te"), &cpb
)) == NULL
)
2110 _termcap_buffer
= malloc
(PTR2SIZE
(cpb
- cmdbuf
));
2111 memcpy
(_termcap_buffer
, cmdbuf
, PTR2SIZE
(cpb
- cmdbuf
));
2112 _termcap_ti
= _termcap_buffer
+ PTR2SIZE
(cpti
- cmdbuf
);
2113 _termcap_te
= _termcap_ti
+ PTR2SIZE
(cpte
- cpti
);
2114 tputs
(_termcap_ti
, 1, &putchar
);
2115 tputs
(_termcap_te
, 1, &putchar
);
2117 return (cp == NULL
);
2122 __termlib
-ltermcap '' '' termcap ||
2123 __termlib
-ltermcap '#include <curses.h>' '
2124 #define HAVE_TERMCAP_CURSES' \
2125 'curses.h / -ltermcap' ||
2126 __termlib
-lcurses '#include <curses.h>' '
2127 #define HAVE_TERMCAP_CURSES' \
2128 'curses.h / -lcurses' ||
2129 feat_bail_required TERMCAP
2131 echo '/* WANT_TERMCAP=0 */' >> ${h}
2134 if feat_yes ERRORS
; then
2135 echo '#define HAVE_ERRORS' >> ${h}
2137 echo '/* WANT_ERRORS=0 */' >> ${h}
2142 if feat_yes SPAM_SPAMC
; then
2143 echo '#define HAVE_SPAM_SPAMC' >> ${h}
2144 if command -v spamc
>/dev
/null
2>&1; then
2145 echo "#define SPAM_SPAMC_PATH \"`command -v spamc`\"" >> ${h}
2148 echo '/* WANT_SPAM_SPAMC=0 */' >> ${h}
2151 if feat_yes SPAM_SPAMD
&& [ -n "${have_af_unix}" ]; then
2152 echo '#define HAVE_SPAM_SPAMD' >> ${h}
2154 feat_bail_required SPAM_SPAMD
2155 echo '/* WANT_SPAM_SPAMD=0 */' >> ${h}
2158 if feat_yes SPAM_FILTER
; then
2159 echo '#define HAVE_SPAM_FILTER' >> ${h}
2161 echo '/* WANT_SPAM_FILTER=0 */' >> ${h}
2164 if feat_yes SPAM_SPAMC || feat_yes SPAM_SPAMD || feat_yes SPAM_FILTER
; then
2165 echo '#define HAVE_SPAM' >> ${h}
2167 echo '/* HAVE_SPAM */' >> ${h}
2170 if feat_yes DOCSTRINGS
; then
2171 echo '#define HAVE_DOCSTRINGS' >> ${h}
2173 echo '/* WANT_DOCSTRINGS=0 */' >> ${h}
2176 if feat_yes QUOTE_FOLD
&&\
2177 [ -n "${have_c90amend1}" ] && [ -n "${have_wcwidth}" ]; then
2178 echo '#define HAVE_QUOTE_FOLD' >> ${h}
2180 echo '/* WANT_QUOTE_FOLD=0 */' >> ${h}
2183 if feat_yes FILTER_HTML_TAGSOUP
; then
2184 echo '#define HAVE_FILTER_HTML_TAGSOUP' >> ${h}
2186 echo '/* WANT_FILTER_HTML_TAGSOUP=0 */' >> ${h}
2189 if feat_yes COLOUR
; then
2190 echo '#define HAVE_COLOUR' >> ${h}
2192 echo '/* WANT_COLOUR=0 */' >> ${h}
2195 if feat_yes DOTLOCK
; then
2196 echo '#define HAVE_DOTLOCK' >> ${h}
2198 echo '/* WANT_DOTLOCK=0 */' >> ${h}
2201 if feat_yes MD5
; then
2202 echo '#define HAVE_MD5' >> ${h}
2204 echo '/* WANT_MD5=0 */' >> ${h}
2209 # Since we cat(1) the content of those to cc/"ld", convert them to single line
2211 < "${1}" > "${2}" ${awk} \
2212 'BEGIN {ORS = " "} /^[^#]/ {print} {next} END {ORS = ""; print "\n"}'
2215 squeeze_em ${inc} ${tmp}
2217 squeeze_em ${lib} ${tmp}
2222 printf '#ifndef _CONFIG_H\n# define _CONFIG_H 1\n' > ${h}
2223 ${cat} ${tmp} >> ${h}
2226 printf '\n/* The "feature string
" */\n' >> ${h}
2227 printf '# if defined _ACCMACVAR_SOURCE || defined HAVE_AMALGAMATION\n' >> ${h}
2228 printf 'static char const _features[] = "MIME
"\n' >> ${h}
2229 printf '# ifdef HAVE_SETLOCALE\n ",LOCALES
"\n# endif\n' >> ${h}
2230 printf '# ifdef HAVE_C90AMEND1\n ",MULTIBYTE CHARSETS
"\n# endif\n' >> ${h}
2231 printf '# ifdef HAVE_NL_LANGINFO\n ",TERMINAL CHARSET
"\n# endif\n' >> ${h}
2232 printf '# ifdef HAVE_ICONV\n ",ICONV
"\n# endif\n' >> ${h}
2233 printf '# ifdef HAVE_SOCKETS\n ",NETWORK
"\n# endif\n' >> ${h}
2234 printf '# ifdef HAVE_SSL\n ",S
/MIME
,SSL
/TLS
"\n# endif\n' >> ${h}
2235 printf '# ifdef HAVE_SSL_ALL_ALGORITHMS\n ",SSL-ALL-ALGORITHMS
"\n# endif\n'\
2237 printf '# ifdef HAVE_SMTP\n ",SMTP
"\n# endif\n' >> ${h}
2238 printf '# ifdef HAVE_POP3\n ",POP3
"\n# endif\n' >> ${h}
2239 printf '# ifdef HAVE_IMAP\n ",IMAP
"\n# endif\n' >> ${h}
2240 printf '# ifdef HAVE_GSSAPI\n ",GSS-API
"\n# endif\n' >> ${h}
2241 printf '# ifdef HAVE_MD5\n ",MD5
[APOP
,CRAM-MD5
]"\n# endif\n' >> ${h}
2242 printf '# ifdef HAVE_NETRC\n ",NETRC
"\n# endif\n' >> ${h}
2243 printf '# ifdef HAVE_AGENT\n ",AGENT
"\n# endif\n' >> ${h}
2244 printf '# ifdef HAVE_IDNA\n ",IDNA
"\n# endif\n' >> ${h}
2245 printf '# ifdef HAVE_IMAP_SEARCH\n ",IMAP-SEARCH
"\n# endif\n' >> ${h}
2246 printf '# ifdef HAVE_REGEX\n ",REGEX
"\n# endif\n' >> ${h}
2247 printf '# ifdef HAVE_READLINE\n ",READLINE
"\n# endif\n' >> ${h}
2248 printf '# ifdef HAVE_EDITLINE\n ",EDITLINE
"\n# endif\n' >> ${h}
2249 printf '# ifdef HAVE_NCL\n ",NCL
"\n# endif\n' >> ${h}
2250 printf '# ifdef HAVE_TABEXPAND\n ",TABEXPAND
"\n# endif\n' >> ${h}
2251 printf '# ifdef HAVE_HISTORY\n ",HISTORY
"\n# endif\n' >> ${h}
2252 printf '# ifdef HAVE_TERMCAP\n ",TERMCAP
"\n# endif\n' >> ${h}
2253 printf '# ifdef HAVE_SPAM_SPAMC\n ",SPAMC
"\n# endif\n' >> ${h}
2254 printf '# ifdef HAVE_SPAM_SPAMD\n ",SPAMD
"\n# endif\n' >> ${h}
2255 printf '# ifdef HAVE_SPAM_FILTER\n ",SPAMFILTER
"\n# endif\n' >> ${h}
2256 printf '# ifdef HAVE_DOCSTRINGS\n ",DOCSTRINGS
"\n# endif\n' >> ${h}
2257 printf '# ifdef HAVE_QUOTE_FOLD\n ",QUOTE-FOLD
"\n# endif\n' >> ${h}
2258 printf '# ifdef HAVE_FILTER_HTML_TAGSOUP\n ",HTML-FILTER
"\n# endif\n' >> ${h}
2259 printf '# ifdef HAVE_COLOUR\n ",COLOUR
"\n# endif\n' >> ${h}
2260 printf '# ifdef HAVE_DOTLOCK\n ",DOTLOCK-FILES
"\n# endif\n' >> ${h}
2261 printf '# ifdef HAVE_DEBUG\n ",DEBUG
"\n# endif\n' >> ${h}
2262 printf '# ifdef HAVE_DEVEL\n ",DEVEL
"\n# endif\n' >> ${h}
2263 printf ';\n# endif /* _ACCMACVAR_SOURCE || HAVE_AMALGAMATION */\n' >> ${h}
2265 # Create the real mk.mk
2266 # Note we cannout use explicit ./ filename prefix for source and object
2267 # pathnames because of a bug in bmake(1)
2268 ${rm} -rf ${tmp0}.* ${tmp0}*
2269 printf 'OBJ_SRC = ' >> ${mk}
2270 if feat_no AMALGAMATION; then
2271 for i in `printf '%s\n' *.c | ${sort}`; do
2272 if [ "${i}" = privsep.c ]; then
2275 printf "${i} " >> ${mk}
2277 printf '\nAMALGAM_TARGET =\nAMALGAM_DEP =\n' >> ${mk}
2279 printf 'main.c\nAMALGAM_TARGET = main.o\nAMALGAM_DEP = ' >> ${mk}
2281 printf '\n/* HAVE_AMALGAMATION: include sources */\n' >> ${h}
2282 printf '#elif _CONFIG_H + 0 == 1\n' >> ${h}
2283 printf '# undef _CONFIG_H\n' >> ${h}
2284 printf '# define _CONFIG_H 2\n' >> ${h}
2285 for i in `printf '%s\n' *.c | ${sort}`; do
2286 if [ "${i}" = "${j}" ] || [ "${i}" = main.c ] || \
2287 [ "${i}" = privsep.c ]; then
2290 printf "${i} " >> ${mk}
2291 printf "# include \"${i}\"\n" >> ${h}
2294 # tcc(1) fails on 2015-11-13 unless this #else clause existed
2295 echo '#else' >> ${h}
2298 printf '#endif /* _CONFIG_H */\n' >> ${h}
2300 echo "LIBS = `${cat} ${lib}`" >> ${mk}
2301 echo "INCS
= `${cat} ${inc}`" >> ${mk}
2303 ${cat} ./mk-mk.in >> ${mk}
2307 ${cat} > ${tmp2}.c << \!
2310 :The following optional features are enabled:
2311 #ifdef HAVE_SETLOCALE
2312 : + Locale support: Printable characters depend on the environment
2313 # ifdef HAVE_C90AMEND1
2314 : + Multibyte character support
2316 # ifdef HAVE_NL_LANGINFO
2317 : + Automatic detection of terminal character set
2321 : + Character set conversion using iconv()
2327 # ifdef HAVE_OPENSSL
2328 : + S/MIME and SSL/TLS (OpenSSL)
2330 # ifdef HAVE_SSL_ALL_ALGORITHMS
2331 : + + Support for more ("all") digest and cipher algorithms
2344 : + GSS-API authentication
2347 : + MD5 message digest (APOP, CRAM-MD5)
2350 : + .netrc file support
2353 : + Password query through agent
2356 : + IDNA (internationalized domain names for applications) support
2358 #ifdef HAVE_IMAP_SEARCH
2359 : + IMAP-style search expressions
2362 : + Regular expression support (searches, conditional expressions etc.)
2364 #if defined HAVE_READLINE || defined HAVE_EDITLINE || defined HAVE_NCL
2365 # ifdef HAVE_READLINE
2366 : + Command line editing via readline(3)
2367 # elif defined HAVE_EDITLINE
2368 : + Command line editing via editline(3)
2370 : + Command line editing via N(ail) C(ommand) L(ine)
2372 # ifdef HAVE_TABEXPAND
2373 : + + Tabulator expansion
2375 # ifdef HAVE_HISTORY
2376 : + + History management
2380 : + Terminal capability queries
2384 # ifdef HAVE_SPAM_SPAMC
2385 : + + Via spamc(1) (of spamassassin(1))
2387 # ifdef HAVE_SPAM_SPAMD
2388 : + + Directly via spamd(1) (of spamassassin(1))
2390 # ifdef HAVE_SPAM_FILTER
2391 : + + Via freely configurable *spam-filter-XY*s
2394 #ifdef HAVE_DOCSTRINGS
2395 : + Documentation summary strings
2397 #ifdef HAVE_QUOTE_FOLD
2398 : + Extended *quote-fold*ing
2400 #ifdef HAVE_FILTER_HTML_TAGSOUP
2401 : + Builtin HTML-to-text filter (for display purposes, primitive)
2404 : + Coloured message display (simple)
2407 : + Dotlock files and privilege-separated file dotlock program
2410 :The following optional features are disabled:
2411 #ifndef HAVE_SETLOCALE
2412 : - Locale support: Only ASCII characters are recognized
2414 # ifndef HAVE_C90AMEND1
2415 : - Multibyte character support
2417 # ifndef HAVE_NL_LANGINFO
2418 : - Automatic detection of terminal character set
2421 : - Character set conversion using iconv()
2422 : _ (Ooooh, no iconv(3), NO character set conversion possible! Really...)
2424 #ifndef HAVE_SOCKETS
2428 : - S/MIME and SSL/TLS
2430 # ifndef HAVE_SSL_ALL_ALGORITHMS
2431 : - Support for more S/MIME and SSL/TLS digest and cipher algorithms
2444 : - GSS-API authentication
2447 : - MD5 message digest (APOP, CRAM-MD5)
2450 : - .netrc file support
2453 : - Password query through agent
2456 : - IDNA (internationalized domain names for applications) support
2458 #ifndef HAVE_IMAP_SEARCH
2459 : - IMAP-style search expressions
2462 : - Regular expression support
2464 #if !defined HAVE_READLINE && !defined HAVE_EDITLINE && !defined HAVE_NCL
2465 : - Command line editing and history
2467 #ifndef HAVE_TERMCAP
2468 : - Terminal capability queries
2473 #ifndef HAVE_DOCSTRINGS
2474 : - Documentation summary strings
2476 #ifndef HAVE_QUOTE_FOLD
2477 : - Extended *quote-fold*ing
2479 #ifndef HAVE_FILTER_HTML_TAGSOUP
2480 : - Builtin HTML-to-text filter (for display purposes, primitive)
2483 : - Coloured message display (simple)
2485 #ifndef HAVE_DOTLOCK
2486 : - Dotlock files and privilege-separated file dotlock program
2489 #if !defined HAVE_WORDEXP || !defined HAVE_FCHDIR ||\
2490 defined HAVE_DEBUG || defined HAVE_DEVEL
2492 # ifndef HAVE_WORDEXP
2493 : . WARNING: the function wordexp(3) could not be found.
2494 : _ This means that echo(1) will be used via the sh(1)ell in order
2495 : _ to expand shell meta characters in filenames, which is a potential
2496 : _ security hole. Consider to either upgrade your system or set the
2497 : _ *SHELL* variable to some safe(r) wrapper script.
2498 : _ P.S.: the codebase is in transition away from wordexp(3) to some
2499 : _ safe (restricted) internal mechanism, see "COMMANDS" manual, read
2500 : _ about shell word expression in its introduction for more on that.
2502 # ifndef HAVE_FCHDIR
2503 : . The function fchdir(2) could not be found. We will use chdir(2)
2504 : _ instead. This is not a problem unless the current working
2505 : _ directory of mailx is moved while the IMAP cache is used.
2508 : . Debug enabled binary: not meant to be used by end-users: THANKS!
2511 : . Computers do not blunder.
2514 #endif /* Remarks */
2516 : . System-wide resource file: SYSCONFRC
2519 : . libexecdir: LIBEXECDIR
2522 : . sendmail(1): SENDMAIL (argv[0] = SENDMAIL_PROGNAME)
2523 : . Mail spool directory: MAILSPOOL
2527 ${make} -f ${makefile} ${tmp2}.x
2528 < ${tmp2}.x >&5 ${sed} -e '/^[^:]/d; /^$/d; s/^://'