2 #@ Please see `INSTALL' and `make.rc' instead.
10 WANT_SSL
=0 WANT_ALL_SSL_ALGORITHMS
=0
11 WANT_SMTP
=0 WANT_POP3
=0
12 WANT_GSSAPI
=0 WANT_NETRC
=0 WANT_AGENT
=0
17 WANT_READLINE
=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
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
; 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 WANT_SSL
=0 WANT_ALL_SSL_ALGORITHMS
=0
129 WANT_SMTP
=0 WANT_POP3
=0
130 WANT_GSSAPI
=0 WANT_NETRC
=0 WANT_AGENT
=0
132 if feat_no SMTP
; then
136 if feat_no READLINE
&& feat_no NCL
; then
137 WANT_HISTORY
=0 WANT_TABEXPAND
=0
140 # If we don't need MD5 leave it alone
141 if feat_no SOCKETS
; then
145 if feat_yes DEVEL
; then
148 if feat_yes DEBUG
; then
149 WANT_NOALLOCA
=1 WANT_DEVEL
=1
153 # Note that potential duplicates in PATH, C_INCLUDE_PATH etc. will be cleaned
154 # via path_check() later on once possible
156 # TODO cc_maxopt is brute simple, we should compile test program and dig real
157 # compiler versions for known compilers, then be more specific
162 i
="${OS:-`uname -s`}"
164 if [ ${i} = SunOS
]; then
165 msg
'SunOS / Solaris? Applying some "early setup" rules ...'
166 _os_early_setup_sunos
171 # OSFULLSPEC is used to recognize changes (i.e., machine type, updates etc.)
172 OSFULLSPEC
="${OS:-`uname -a | ${tr} '[A-Z]' '[a-z]'`}"
173 OS
="${OS:-`uname -s | ${tr} '[A-Z]' '[a-z]'`}"
174 msg
'Operating system is "%s"' ${OS}
176 if [ ${OS} = sunos
]; then
177 msg
' . have special SunOS / Solaris "setup" rules ...'
179 elif [ ${OS} = unixware
]; then
180 msg
' . have special UnixWare environmental rules ...'
181 if feat_yes AUTOCC
&& command -v cc
>/dev
/null
2>&1; then
183 feat_yes DEBUG
&& _CFLAGS
='-v -Xa -g' || _CFLAGS
='-Xa -O'
185 CFLAGS
="${_CFLAGS} ${ADDCFLAGS}"
186 LDFLAGS
="${_LDFLAGS} ${ADDLDFLAGS}"
187 export CC CFLAGS LDFLAGS
188 WANT_AUTOCC
=0 had_want_autocc
=1 need_R_ldflags
=-R
190 elif [ -n "${VERBOSE}" ]; then
191 msg
' . no special treatment for this system necessary or known'
194 # Sledgehammer: better set _GNU_SOURCE
195 # And in general: oh, boy!
196 OS_DEFINES
="${OS_DEFINES}#define _GNU_SOURCE\n"
197 #OS_DEFINES="${OS_DEFINES}#define _POSIX_C_SOURCE 200809L\n"
198 #OS_DEFINES="${OS_DEFINES}#define _XOPEN_SOURCE 700\n"
199 #[ ${OS} = darwin ] && OS_DEFINES="${OS_DEFINES}#define _DARWIN_C_SOURCE\n"
201 # On pkgsrc(7) systems automatically add /usr/pkg/*
202 if [ -d /usr
/pkg
]; then
203 C_INCLUDE_PATH
="${C_INCLUDE_PATH}:/usr/pkg/include"
204 LD_LIBRARY_PATH
="${LD_LIBRARY_PATH}:/usr/pkg/lib"
208 _os_early_setup_sunos
() {
209 # According to standards(5), this is what we need to do
210 if [ -d /usr
/xpg4
]; then :; else
211 msg
'ERROR: On SunOS / Solaris we need /usr/xpg4 environment! Sorry.'
214 PATH
="/usr/xpg4/bin:/usr/ccs/bin:/usr/bin:${PATH}"
215 [ -d /usr
/xpg6
] && PATH
="/usr/xpg6/bin:${PATH}"
220 C_INCLUDE_PATH
="/usr/xpg4/include:${C_INCLUDE_PATH}"
221 LD_LIBRARY_PATH
="/usr/xpg4/lib:${LD_LIBRARY_PATH}"
224 if [ -d /opt
/csw
]; then
225 C_INCLUDE_PATH
="${C_INCLUDE_PATH}:/opt/csw/include"
226 LD_LIBRARY_PATH
="${LD_LIBRARY_PATH}:/opt/csw/lib"
229 OS_DEFINES
="${OS_DEFINES}#define __EXTENSIONS__\n"
230 #OS_DEFINES="${OS_DEFINES}#define _POSIX_C_SOURCE 200112L\n"
232 [ -n "${cksum}" ] ||
cksum=/opt
/csw
/gnu
/cksum
233 if [ -x "${cksum}" ]; then :; else
234 msg
'ERROR: Not an executable program: "%s"' "${cksum}"
235 msg
'ERROR: We need a CRC-32 cksum(1), as specified in POSIX.'
236 msg
'ERROR: However, we do so only for tests.'
237 msg
'ERROR: If that is ok, set "cksum=/usr/bin/true", then rerun'
241 if feat_yes AUTOCC
; then
242 if command -v cc
>/dev
/null
2>&1; then
244 feat_yes DEBUG
&& _CFLAGS
="-v -Xa -g" || _CFLAGS
="-Xa -O"
246 CFLAGS
="${_CFLAGS} ${ADDCFLAGS}"
247 LDFLAGS
="${_LDFLAGS} ${ADDLDFLAGS}"
248 export CC CFLAGS LDFLAGS
249 WANT_AUTOCC
=0 had_want_autocc
=1 need_R_ldflags
=-R
252 cc_maxopt
=2 force_no_stackprot
=1 need_R_ldflags
=-Wl,-R
257 # Check out compiler ($CC) and -flags ($CFLAGS)
259 # Even though it belongs into cc_flags we will try to compile and link
260 # something, so ensure we have a clean state regarding CFLAGS/LDFLAGS or
261 # ADDCFLAGS/ADDLDFLAGS
262 if feat_no AUTOCC
; then
264 # Ensure those don't do any harm
265 ADDCFLAGS
= ADDLDFLAGS
=
266 export ADDCFLAGS ADDLDFLAGS
270 export CFLAGS LDFLAGS
273 [ -n "${CC}" ] && [ "${CC}" != cc ] && { _cc_default; return; }
275 printf >&2 'Searching for a usable C compiler .. $CC='
276 if { i="`command -v clang`"; }; then
278 elif { i="`command -v gcc`"; }; then
280 elif { i="`command -v c99`"; }; then
282 elif { i="`command -v tcc`"; }; then
284 elif { i="`command -v pcc`"; }; then
287 if [ "${CC}" = cc ]; then
289 elif { i="`command -v c89`"; }; then
292 printf >&2 'boing booom tschak\n'
293 msg 'ERROR: I cannot find a compiler!'
294 msg ' Neither of clang(1), gcc(1), tcc(1), c89(1) and c99(1).'
295 msg ' Please set $CC environment variable, maybe $CFLAGS also, rerun.'
299 printf >&2 -- '"%s
"\n' "${CC}"
304 if [ -z "${CC}" ]; then
305 printf >&2 'To go on like you have chosen, please set $CC, rerun.'
309 if [ -z "${VERBOSE}" ] && [ -f ${lst} ] && feat_no DEBUG; then
312 msg 'Using C compiler $CC="%s
"' "${CC}"
317 if feat_yes AUTOCC; then
318 if [ -f ${lst} ] && feat_no DEBUG && [ -z "${VERBOSE}" ]; then
320 msg 'Detecting $CFLAGS/$LDFLAGS for $CC="%s
", just a second..' "${CC}"
323 msg 'Testing usable $CFLAGS/$LDFLAGS for $CC="%s
"' "${CC}"
326 i=`echo "${CC}" | ${awk} 'BEGIN{FS="/"}{print
$NF}'`
327 if { echo "${i}" | ${grep} tcc; } >/dev/null 2>&1; then
328 msg ' . have special tcc
(1) environmental rules ...
'
331 # As of pcc CVS 2016-04-02, stack protection support is announced but
332 # will break if used on Linux
333 if { echo "${i}" | ${grep} pcc; } >/dev/null 2>&1; then
339 feat_no DEBUG && _CFLAGS="-DNDEBUG ${_CFLAGS}"
340 CFLAGS="${_CFLAGS} ${ADDCFLAGS}"
341 LDFLAGS="${_LDFLAGS} ${ADDLDFLAGS}"
343 if feat_no DEBUG; then
344 CFLAGS="-DNDEBUG ${CFLAGS}"
348 export CFLAGS LDFLAGS
352 __cflags=${_CFLAGS} __ldflags=${_LDFLAGS}
359 if feat_yes DEBUG; then
360 # May have problems to find libtcc cc_check -b
364 _CFLAGS="${_CFLAGS} ${__cflags}" _LDFLAGS="${_LDFLAGS} ${__ldflags}"
365 unset __cflags __ldflags
368 _cc_flags_generic() {
369 __cflags=${_CFLAGS} __ldflags=${_LDFLAGS}
371 feat_yes DEVEL && cc_check -std=c89 || cc_check -std=c99
373 # Check -g first since some others may rely upon -g / optim. level
374 if feat_yes DEBUG; then
377 elif [ ${cc_maxopt} -gt 2 ] && cc_check -O3; then
379 elif [ ${cc_maxopt} -gt 1 ] && cc_check -O2; then
381 elif [ ${cc_maxopt} -gt 0 ] && cc_check -O1; then
387 if feat_yes DEVEL && cc_check -Weverything; then
392 cc_check -Wbad-function-cast
393 cc_check -Wcast-align
396 cc_check -Wmissing-prototypes
399 cc_check -Wwrite-strings
400 cc_check -Wno-long-long
404 if feat_yes AMALGAMATION && feat_no DEVEL; then
405 cc_check -Wno-unused-function
407 feat_no DEVEL && cc_check -Wno-unused-result # XXX do right way (pragma too)
409 cc_check -fno-unwind-tables
410 cc_check -fno-asynchronous-unwind-tables
411 cc_check -fstrict-aliasing
412 if cc_check -fstrict-overflow && feat_yes DEVEL; then
413 cc_check -Wstrict-overflow=5
416 if feat_yes DEBUG || feat_yes FORCED_STACKPROT; then
417 if [ -z "${force_no_stackprot}" ]; then
418 if cc_check -fstack-protector-strong ||
419 cc_check -fstack-protector-all; then
420 cc_check -D_FORTIFY_SOURCE=2
423 msg 'Not checking
for -fstack-protector compiler option
,'
424 msg 'since that caused errors
in a
"similar" configuration.
'
425 msg 'You may turn off WANT_AUTOCC and use your own settings
, rerun
'
429 if feat_yes AMALGAMATION; then
433 # LD (+ dependend CC)
435 if feat_yes DEVEL; then
438 #if cc_check -fsanitize=memory &&
439 # ld_check -fsanitize=memory &&
440 # cc_check -fsanitize-memory-track-origins=2 &&
441 # ld_check -fsanitize-memory-track-origins=2; then
448 ld_check -Wl,-z,relro
450 ld_check -Wl,-z,noexecstack
452 # Address randomization
454 if cc_check -fPIE || cc_check -fpie; then
455 ld_check -pie || _CFLAGS=${_ccfg}
459 _CFLAGS="${_CFLAGS} ${__cflags}" _LDFLAGS="${_LDFLAGS} ${__ldflags}"
460 unset __cflags __ldflags
466 ## - Heirloom sh(1) (and same origin) have _sometimes_ problems with ': >'
467 ## redirection, so use "printf '' >" instead
469 ## Very first: we undergo several states regarding I/O redirection etc.,
470 ## but need to deal with option updates from within all. Since all the
471 ## option stuff should be above the scissor line, define utility functions
472 ## and redefine them as necessary.
473 ## And, since we have those functions, simply use them for whatever
482 printf >&2 -- "${fmt}\\n" "${@}"
485 ## First of all, create new configuration and check wether it changed
489 h=./config.h h_name=config.h
492 newlst=./config.lst-new
493 newmk=./config.mk-new
499 t1=ten10one1ten10one1
500 if ( [ ${t1##*ten10} = one1 ] && [ ${t1#*ten10} = one1ten10one1 ] &&
501 [ ${t1%%one1*} = ten10 ] && [ ${t1%one1*} = ten10one1ten10 ]
502 ) > /dev/null 2>&1; then
509 # We need some standard utilities
512 n=${1} i=${2} opt=${3:-0}
513 # Evaluate, just in case user comes in with shell snippets (..well..)
515 if type "${i}" >/dev/null 2>&1; then # XXX why have i type not command -v?
516 [ -n "${VERBOSE}" ] && msg ' . $%s ... "%s"' "${n}" "${i}"
520 if [ ${opt} -eq 0 ]; then
521 msg 'ERROR
: no trace of utility
"%s"' "${n}"
527 # Very easy checks for the operating system in order to be able to adjust paths
528 # or similar very basic things which we need to be able to go at all
531 # Check those tools right now that we need before including $rc
532 msg 'Checking
for basic utility
set'
533 check_tool awk "${awk:-`command -v awk`}"
534 check_tool rm "${rm:-`command -v rm`}"
535 check_tool tr "${tr:-`command -v tr`}"
537 # Our feature check environment
540 [ "x${1}" = xfalse ] || [ "x${1}" = xno ] || [ "x${1}" = xoff ]
545 [ "x${1}" = xtrue ] || [ "x${1}" = xyes ] || [ "x${1}" = xon ] ||
546 [ "x${1}" = xrequire ]
550 [ "x${1}" = xrequire ]
555 i="`echo ${i} | ${tr} '[A-Z
]' '[a-z
]'`"
556 if feat_val_no "${i}"; then
558 elif feat_val_yes "${i}"; then
561 msg "ERROR: %s: any of 0/false/no/off or 1/true/yes/on/require, got: %s" \
572 _feat_check ${1} && return 1
578 i="`echo ${i} | ${tr} '[A-Z
]' '[a-z
]'`"
579 [ "x${i}" = xrequire ] || [ "x${i}" = xrequired ]
582 feat_bail_required() {
583 if feat_require ${1}; then
584 msg 'ERROR
: feature WANT_
%s is required but not available
' "${1}"
588 option_update # XXX this is rather useless here (dependency chain..)
591 # Include $rc, but only take from it what wasn't overwritten by the user from
592 # within the command line or from a chosen fixed CONFIG=
593 # Note we leave alone the values
594 trap "exit 1" HUP INT TERM
595 trap "${rm} -f ${tmp}" EXIT
597 printf >&2 'Reading and preparing configuration from "%s" ... ' ${rc}
599 # We want read(1) to perform backslash escaping in order to be able to use
600 # multiline values in make.rc; the resulting sh(1)/sed(1) code was very slow in
601 # VMs (see [fa2e248]), Aharon Robbins suggested the following
602 < ${rc} ${awk} 'BEGIN{line = ""}{
603 gsub
(/^
[[:space
:]]+/, "", $0)
604 gsub
(/[[:space
:]]+$
/, "", $0)
605 if(gsub
(/\\$
/, "", $0)){
610 if(index
(line
, "#") == 1){
612 }else if(length
(line
)){
618 if [ -n "${good_shell}" ]; then
621 i=`${awk} -v LINE="${line}" 'BEGIN
{
622 gsub
(/=.
*$
/, "", LINE
)
626 if [ "${i}" = "${line}" ]; then
627 msg 'ERROR
: invalid syntax
in "%s"' "${line}"
631 eval j="\$${i}" jx="\${${i}+x}"
632 if [ -n "${j}" ] || [ "${jx}" = x ]; then
635 j=`${awk} -v LINE="${line}" 'BEGIN
{
636 gsub
(/^
[^
=]*=/, "", LINE
)
637 gsub
(/^
\"*/, "", LINE
)
638 gsub
(/\"*$
/, "", LINE
)
644 # Reread the mixed version right now
648 # We need to know about that now, in order to provide utility overwrites etc.
651 msg 'Checking
for remaining
set of utilities
'
652 check_tool grep "${grep:-`command -v grep`}"
654 # Before we step ahead with the other utilities perform a path cleanup first.
655 # We need this function also for C_INCLUDE_PATH and LD_LIBRARY_PATH
656 # "path_check VARNAME" or "path_check VARNAME FLAG VARNAME"
658 varname=${1} addflag=${2} flagvarname=${3}
666 [ -z "${i}" ] && continue
667 [ -d "${i}" ] || continue
668 if [ -n "${j}" ]; then
669 if { z=${y}; echo "${z}"; } | ${grep} ":${i}:" >/dev/null 2>&1; then
674 [ -n "${addflag}" ] && k="${k} ${addflag}${i}"
679 [ -n "${addflag}" ] && k="${addflag}${i}"
682 eval "${varname}=\"${j}\""
683 [ -n "${addflag}" ] && eval "${flagvarname}=\"${k}\""
690 check_tool cat "${cat:-`command -v cat`}"
691 check_tool chmod "${chmod:-`command -v chmod`}"
692 check_tool cp "${cp:-`command -v cp`}"
693 check_tool cmp "${cmp:-`command -v cmp`}"
695 check_tool mkdir "${mkdir:-`command -v mkdir`}"
696 check_tool mv "${mv:-`command -v mv`}"
698 check_tool sed "${sed:-`command -v sed`}"
699 check_tool sort "${sort:-`command -v sort`}"
700 check_tool tee "${tee:-`command -v tee`}"
702 check_tool chown "${chown:-`command -v chown`}" 1 ||
703 check_tool chown "/sbin/chown" 1 ||
704 check_tool chown "/usr/sbin/chown"
706 check_tool make "${MAKE:-`command -v make`}"
708 check_tool strip "${STRIP:-`command -v strip`}" 1 &&
709 HAVE_STRIP=1 || HAVE_STRIP=0
711 # For ./cc-test.sh only
712 check_tool cksum "${cksum:-`command -v cksum`}"
714 # Update WANT_ options now, in order to get possible inter-dependencies right
717 # (No functions since some shells loose non-exported variables in traps)
718 trap "trap \"\" HUP INT TERM; exit 1" HUP INT TERM
719 trap "trap \"\" HUP INT TERM EXIT;\
720 ${rm} -rf ${newlst} ${tmp0}.* ${tmp0}* ${newmk} ${newh}" EXIT
722 # Our configuration options may at this point still contain shell snippets,
723 # we need to evaluate them in order to get them expanded, and we need those
724 # evaluated values not only in our new configuration file, but also at hand..
725 printf >&2 'Evaluating all configuration items ...
'
726 ${rm} -f ${newlst} ${newmk} ${newh}
727 exec 5<&0 6>&1 <${tmp} >${newlst}
730 if [ -n "${good_shell}" ]; then
732 [ "${i}" != "${i#WANT_}" ] && z=1
734 i=`${awk} -v LINE="${line}" 'BEGIN
{
735 gsub
(/=.
*$
/, "", LINE
);\
738 if echo "${i}" | ${grep} '^WANT_
' >/dev/null 2>&1; then
744 if [ -n "${z}" ]; then
745 j="`echo ${j} | ${tr} '[A-Z
]' '[a-z
]'`"
746 if [ -z "${j}" ] || feat_val_no "${j}"; then
748 printf "/*#define ${i}*/\n" >> ${newh}
749 elif feat_val_yes "${j}"; then
750 if feat_val_require "${j}"; then
755 printf "#define ${i}\n" >> ${newh}
757 msg 'ERROR
: cannot parse
<%s
>' "${line}"
761 printf "#define ${i} \"${j}\"\n" >> ${newh}
763 printf "${i} = ${j}\n" >> ${newmk}
767 exec 0<&5 1>&6 5<&- 6<&-
770 # Add the known utility and some other variables
771 printf "#define UAGENT \"${SID}${NAIL}\"\n" >> ${newh}
772 printf "UAGENT = ${SID}${NAIL}\n" >> ${newmk}
774 printf "#define PRIVSEP \"${SID}${NAIL}-privsep\"\n" >> ${newh}
775 printf "PRIVSEP = \$(UAGENT)-privsep\n" >> ${newmk}
776 if feat_yes DOTLOCK; then
777 printf "OPTIONAL_PRIVSEP = \$(PRIVSEP)\n" >> ${newmk}
779 printf "OPTIONAL_PRIVSEP =\n" >> ${newmk}
783 awk cat chmod chown cp cmp grep mkdir mv rm sed sort tee tr \
787 printf "${i} = ${j}\n" >> ${newmk}
788 printf "${i}=${j}\n" >> ${newlst}
791 # Build a basic set of INCS and LIBS according to user environment.
792 path_check C_INCLUDE_PATH -I _INCS
793 INCS="${INCS} ${_INCS}"
794 path_check LD_LIBRARY_PATH -L _LIBS
795 LIBS="${LIBS} ${_LIBS}"
797 export C_INCLUDE_PATH LD_LIBRARY_PATH
799 if [ -n "${need_R_ldflags}" ]; then
802 set -- ${LD_LIBRARY_PATH}
806 LDFLAGS="${LDFLAGS} ${need_R_ldflags}${i}"
807 _LDFLAGS="${_LDFLAGS} ${need_R_ldflags}${i}"
812 ## Detect CC, wether we can use it, and possibly which CFLAGS we can use
816 ${cat} > ${tmp}.c << \!
819 static void doit(char const *s);
821 main(int argc, char **argv){
835 if "${CC}" ${INCS} ${CFLAGS} ${ADDCFLAGS} ${LDFLAGS} ${ADDLDFLAGS} \
836 -o ${tmp2} ${tmp}.c ${LIBS}; then
839 msg 'ERROR
: i cannot compile a
"Hello world" via
'
841 "${CC} ${INCS} ${CFLAGS} ${ADDCFLAGS} ${LDFLAGS} ${ADDLDFLAGS} ${LIBS}"
842 msg 'ERROR
: Please
read INSTALL
, rerun
'
847 [ -n "${cc_check_silent}" ] || printf >&2 ' . CC
%s ..
' "${1}"
848 if "${CC}" ${INCS} ${_CFLAGS} ${1} ${ADDCFLAGS} ${_LDFLAGS} ${ADDLDFLAGS} \
849 -o ${tmp2} ${tmp}.c ${LIBS} >/dev/null 2>&1; then
850 _CFLAGS="${_CFLAGS} ${1}"
851 [ -n "${cc_check_silent}" ] || printf >&2 'yes\n'
854 [ -n "${cc_check_silent}" ] || printf >&2 'no
\n'
859 [ -n "${cc_check_silent}" ] || printf >&2 ' . LD
%s ..
' "${1}"
860 if "${CC}" ${INCS} ${_CFLAGS} ${_LDFLAGS} ${1} ${ADDLDFLAGS} \
861 -o ${tmp2} ${tmp}.c ${LIBS} >/dev/null 2>&1; then
862 _LDFLAGS="${_LDFLAGS} ${1}"
863 [ -n "${cc_check_silent}" ] || printf >&2 'yes\n'
866 [ -n "${cc_check_silent}" ] || printf >&2 'no
\n'
876 printf -- "${i}=${j}\n" >> ${newlst}
882 PATH C_INCLUDE_PATH LD_LIBRARY_PATH \
886 printf -- "${i} = ${j}\n" >> ${newmk}
887 printf -- "${i}=${j}\n" >> ${newlst}
890 # Now finally check wether we already have a configuration and if so, wether
891 # all those parameters are still the same.. or something has actually changed
892 if [ -f ${lst} ] && ${cmp} ${newlst} ${lst} >/dev/null 2>&1; then
893 echo 'Configuration is up-to-date
'
895 elif [ -f ${lst} ]; then
896 echo 'Configuration has been updated..
'
897 ( eval "${MAKE} -f ./mk.mk clean" )
900 echo 'Shiny configuration..
'
903 # Time to redefine helper 1
905 ${rm} -f ${lst} ${h} ${mk}
909 ${mv} -f ${newlst} ${lst}
910 ${mv} -f ${newh} ${h}
911 ${mv} -f ${newmk} ${mk}
913 ## Compile and link checking
921 # (No function since some shells loose non-exported variables in traps)
922 trap "trap \"\" HUP INT TERM;\
923 ${rm} -f ${lst} ${h} ${mk} ${lib} ${inc}; exit 1" HUP INT TERM
924 trap "trap \"\" HUP INT TERM EXIT;\
925 ${rm} -rf ${tmp0}.* ${tmp0}* ${makefile}" EXIT
927 # Time to redefine helper 2
931 printf "*** ${fmt}\\n" "${@}"
932 printf -- "${fmt}\\n" "${@}" >&5
937 printf "*** ${fmt}\\n" "${@}"
938 printf -- "${fmt}" "${@}" >&5
941 exec 5>&2 > ${log} 2>&1
943 echo "${LIBS}" > ${lib}
944 echo "${INCS}" > ${inc}
945 ${cat} > ${makefile} << \!
946 .SUFFIXES: .o .c .x .y
948 $(CC) -I./ $(XINCS) $(CFLAGS) -c $<
950 $(CC) -I./ $(XINCS) -E $< >$@
952 $(CC) -I./ $(XINCS) $(CFLAGS) $(LDFLAGS) -o $@ $< $(XLIBS)
957 variable=$1 topic=$2 define=$3
960 msg_nonl ' .
%s ...
' "${topic}"
961 echo "/* checked ${topic} */" >> ${h}
962 ${rm} -f ${tmp} ${tmp}.o
963 echo '*** test program is
'
964 { echo '#include <'"${h_name}"'>'; cat; } | ${tee} ${tmp}.c
965 #echo '*** the preprocessor generates'
966 #${make} -f ${makefile} ${tmp}.x
968 echo '*** results are'
972 variable
=$1 topic
=$2 define
=$3
974 _check_preface
"${variable}" "${topic}" "${define}"
976 if ${make} -f ${makefile} XINCS="${INCS}" ./${tmp}.o
&&
977 [ -f .
/${tmp}.o
]; then
979 echo "${define}" >> ${h}
980 eval have_
${variable}=yes
983 echo "/* ${define} */" >> ${h}
985 eval unset have_
${variable}
991 run
=$1 variable
=$2 topic
=$3 define
=$4 libs
=$5 incs
=$6
993 _check_preface
"${variable}" "${topic}" "${define}"
995 if ${make} -f ${makefile} XINCS="${INCS} ${incs}" \
996 XLIBS="${LIBS} ${libs}" ./${tmp} &&
998 { [ ${run} -eq 0 ] || ./${tmp}; }; then
999 echo "*** adding INCS<${incs}> LIBS<${libs}>; executed: ${run}"
1001 echo "${define}" >> ${h}
1002 LIBS
="${LIBS} ${libs}"
1003 echo "${libs}" >> ${lib}
1004 INCS
="${INCS} ${incs}"
1005 echo "${incs}" >> ${inc}
1006 eval have_
${variable}=yes
1010 echo "/* ${define} */" >> ${h}
1011 eval unset have_
${variable}
1017 _link_mayrun
0 "${1}" "${2}" "${3}" "${4}" "${5}"
1021 _link_mayrun
1 "${1}" "${2}" "${3}" "${4}" "${5}"
1026 # May be multiline..
1027 [ -n "${OS_DEFINES}" ] && printf -- "${OS_DEFINES}" >> ${h}
1029 if run_check inline '"inline
" functions' \
1030 '#define HAVE_INLINE
1031 #define n_INLINE static inline' << \!
1032 static inline int ilf(int i){return ++i;}
1033 int main(void){return ilf(-1);}
1037 elif run_check inline '"__inline
" functions' \
1038 '#define HAVE_INLINE
1039 #define n_INLINE static __inline' << \!
1040 static __inline int ilf(int i){return ++i;}
1041 int main(void){return ilf(-1);}
1047 if run_check endian 'Little endian byteorder' \
1048 '#define HAVE_BYTE_ORDER_LITTLE' << \!
1050 enum {vBig = 1, vLittle = 0};
1051 union {unsigned short bom; unsigned char buf[2];} u;
1053 return((u.buf[1] == 0xFE) ? vLittle : vBig);
1062 if run_check clock_gettime 'clock_gettime(2)' \
1063 '#define HAVE_CLOCK_GETTIME' << \!
1069 if(!clock_gettime(CLOCK_REALTIME, &ts) || errno != ENOSYS)
1076 elif run_check clock_gettime 'clock_gettime(2) (via -lrt)' \
1077 '#define HAVE_CLOCK_GETTIME' '-lrt' << \!
1083 if(!clock_gettime(CLOCK_REALTIME, &ts) || errno != ENOSYS)
1090 elif run_check gettimeofday 'gettimeofday(2)' \
1091 '#define HAVE_GETTIMEOFDAY' << \!
1092 #include <stdio.h> /* For C89 NULL */
1093 #include <sys/time.h>
1098 if(!gettimeofday(&tv, NULL) || errno != ENOSYS)
1106 have_no_subsecond_time=1
1109 if run_check nanosleep 'nanosleep(2)' \
1110 '#define HAVE_NANOSLEEP' << \!
1117 ts.tv_nsec = 100000;
1118 if(!nanosleep(&ts, NULL) || errno != ENOSYS)
1125 elif run_check nanosleep 'nanosleep(2) (via -lrt)' \
1126 '#define HAVE_NANOSLEEP' '-lrt' << \!
1133 ts.tv_nsec = 100000;
1134 if(!nanosleep(&ts, NULL) || errno != ENOSYS)
1141 # link_check is enough for this, that function is so old, trust the proto
1142 elif link_check sleep 'sleep(3)' \
1143 '#define HAVE_SLEEP' << \!
1147 if(!sleep(1) || errno != ENOSYS)
1155 msg 'ERROR: we require one of nanosleep(2) and sleep(3).'
1159 if run_check userdb 'gete?[gu]id(2), getpwuid(3), getpwnam(3)' << \!
1168 if((gid = getgid()) != 0)
1170 if((uid = getuid()) != 0)
1172 if((pw = getpwuid(uid)) == NULL && errno == ENOSYS)
1174 if((pw = getpwnam("root
")) == NULL && errno == ENOSYS)
1182 msg 'ERROR: we require user and group info / database searches.'
1183 msg 'That much Unix we indulge ourselfs.'
1187 if link_check snprintf 'v?snprintf(3)' << \!
1190 static void dome(char *buf, ...){
1194 vsnprintf(buf, 20, "%s
", ap);
1201 snprintf(b, sizeof b, "%s
", "string
");
1209 msg 'ERROR: we require the snprintf(3) and vsnprintf(3) functions.'
1213 if link_check environ 'environ(3)' << \!
1214 #include <stdio.h> /* For C89 NULL */
1216 extern char **environ;
1218 return environ[0] == NULL;
1224 msg 'ERROR: we require the environ(3) array for subprocess control.'
1228 if link_check termios 'termios.h and tc*(3) family' << \!
1229 #include <termios.h>
1231 struct termios tios;
1233 tcgetattr(0, &tios);
1234 tcsetattr(0, TCSADRAIN | TCSAFLUSH, &tios);
1241 msg 'ERROR: we require termios.h and the tc*() family of functions.'
1242 msg 'That much Unix we indulge ourselfs.'
1248 run_check pathconf 'pathconf(2)' '#define HAVE_PATHCONF' << \!
1255 rv |= !(pathconf(".
", _PC_NAME_MAX) >= 0 || errno == 0 || errno != ENOSYS);
1257 rv |= !(pathconf(".
", _PC_PATH_MAX) >= 0 || errno == 0 || errno != ENOSYS);
1262 run_check pipe2 'pipe2(2)' '#define HAVE_PIPE2' << \!
1269 if(!pipe2(fds, O_CLOEXEC) || errno != ENOSYS)
1275 # We use this only then for now (need NOW+1)
1276 run_check utimensat 'utimensat(2)' '#define HAVE_UTIMENSAT' << \!
1277 #include <fcntl.h> /* For AT_* */
1278 #include <sys/stat.h>
1281 struct timespec ts[2];
1283 ts[0].tv_nsec = UTIME_NOW;
1284 ts[1].tv_nsec = UTIME_OMIT;
1285 if(!utimensat(AT_FDCWD, "", ts, 0) || errno != ENOSYS)
1293 # XXX Add POSIX check once standardized
1294 if link_check posix_random 'arc4random(3)' '#define HAVE_POSIX_RANDOM 0' << \!
1303 elif [ -n "${have_no_subsecond_time}" ]; then
1304 msg 'ERROR: %s %s' 'without a native random' \
1305 'one of clock_gettime(2) and gettimeofday(2) is required.'
1309 link_check setenv 'setenv(3)/unsetenv(3)' '#define HAVE_SETENV' << \!
1312 setenv("s-nail
", "to be made nifty
!", 1);
1318 link_check putc_unlocked 'putc_unlocked(3)' '#define HAVE_PUTC_UNLOCKED' <<\!
1321 putc_unlocked('@', stdout);
1326 link_check fchdir 'fchdir(3)' '#define HAVE_FCHDIR' << \!
1334 link_check setlocale 'setlocale(3)' '#define HAVE_SETLOCALE' << \!
1337 setlocale(LC_ALL, "");
1342 if [ "${have_setlocale}" = yes ]; then
1343 link_check c90amend1 'ISO/IEC 9899:1990/Amendment 1:1995' \
1344 '#define HAVE_C90AMEND1' << \!
1350 char mbb[MB_LEN_MAX + 1];
1355 mbtowc(&wc, "x
", 1);
1356 mbrtowc(&wc, "x
", 1, NULL);
1358 return (mblen("\
0", 1) == 0);
1362 if [ "${have_c90amend1}" = yes ]; then
1363 link_check wcwidth 'wcwidth(3)' '#define HAVE_WCWIDTH' << \!
1372 link_check nl_langinfo 'nl_langinfo(3)' '#define HAVE_NL_LANGINFO' << \!
1373 #include <langinfo.h>
1377 return (nl_langinfo(CODESET) == NULL);
1382 run_check realpath 'realpath(3)' '#define HAVE_REALPATH' << \!
1385 #if 1 /* TODO for now we use realpath(3) without NULL as 2nd arg! */
1386 /* (And note that on Linux tcc(1) otherwise didn't detect once tested! */
1387 char x_buf[4096], *x = realpath(".
", x_buf);
1389 return (x != NULL) ? 0 : 1;
1391 char *x = realpath(".
", NULL), *y = realpath("/", NULL);
1393 return (x != NULL && y != NULL) ? 0 : 1;
1398 link_check wordexp 'wordexp(3)' '#define HAVE_WORDEXP' << \!
1399 #include <stdio.h> /* For C89 NULL */
1400 #include <wordexp.h>
1402 wordexp(NULL, NULL, 0);
1409 if feat_yes DEBUG; then
1410 echo '#define HAVE_DEBUG' >> ${h}
1413 if feat_yes AMALGAMATION; then
1414 echo '#define HAVE_AMALGAMATION' >> ${h}
1417 if feat_no NOALLOCA; then
1418 # Due to NetBSD PR lib/47120 it seems best not to use non-cc-builtin
1419 # versions of alloca(3) since modern compilers just can't be trusted
1420 # not to overoptimize and silently break some code
1421 run_check alloca '__builtin_alloca()' \
1422 '#define HAVE_ALLOCA __builtin_alloca' << \!
1423 #include <stdio.h> /* For C89 NULL */
1425 void *vp = __builtin_alloca(1);
1427 return (vp != NULL);
1432 if feat_yes DEVEL; then
1433 echo '#define HAVE_DEVEL' >> ${h}
1436 if feat_yes NYD2; then
1437 echo '#define HAVE_NYD2' >> ${h}
1442 if feat_yes DOTLOCK; then
1443 if run_check readlink 'readlink(2)' << \!
1449 if(!readlink("here
", buf, sizeof buf) || errno != ENOSYS)
1457 feat_bail_required DOTLOCK
1461 if feat_yes DOTLOCK; then
1462 if run_check fchown 'fchown(2)' << \!
1466 if(!fchown(0, 0, 0) || errno != ENOSYS)
1474 feat_bail_required DOTLOCK
1480 if feat_yes ICONV; then
1481 ${cat} > ${tmp2}.c << \!
1482 #include <stdio.h> /* For C89 NULL */
1487 id = iconv_open("foo
", "bar
");
1488 iconv(id, NULL, NULL, NULL, NULL);
1493 < ${tmp2}.c link_check iconv 'iconv(3) functionality' \
1494 '#define HAVE_ICONV' ||
1495 < ${tmp2}.c link_check iconv 'iconv(3) functionality (via -liconv)' \
1496 '#define HAVE_ICONV' '-liconv' ||
1497 feat_bail_required ICONV
1499 echo '/* WANT_ICONV=0 */' >> ${h}
1502 if feat_yes SOCKETS || feat_yes SPAM_SPAMD; then
1503 ${cat} > ${tmp2}.c << \!
1504 #include <sys/types.h>
1505 #include <sys/socket.h>
1509 struct sockaddr_un soun;
1511 if(socket(AF_UNIX, SOCK_STREAM, 0) == -1 && errno == ENOSYS)
1513 if(connect(0, (struct sockaddr*)&soun, 0) == -1 && errno == ENOSYS)
1515 if(shutdown(0, SHUT_RD | SHUT_WR | SHUT_RDWR) == -1 && errno == ENOSYS)
1521 < ${tmp2}.c run_check af_unix 'AF_UNIX sockets' \
1522 '#define HAVE_UNIX_SOCKETS' ||
1523 < ${tmp2}.c run_check af_unix 'AF_UNIX sockets (via -lnsl)' \
1524 '#define HAVE_UNIX_SOCKETS' '-lnsl' ||
1525 < ${tmp2}.c run_check af_unix 'AF_UNIX sockets (via -lsocket -lnsl)' \
1526 '#define HAVE_UNIX_SOCKETS' '-lsocket -lnsl'
1529 if feat_yes SOCKETS; then
1530 ${cat} > ${tmp2}.c << \!
1532 #include <sys/types.h>
1533 #include <sys/socket.h>
1534 #include <netinet/in.h>
1539 if(socket(AF_INET, SOCK_STREAM, 0) == -1 && errno == ENOSYS)
1541 if(connect(0, &s, 0) == -1 && errno == ENOSYS)
1547 < ${tmp2}.c run_check sockets 'sockets' \
1548 '#define HAVE_SOCKETS' ||
1549 < ${tmp2}.c run_check sockets 'sockets (via -lnsl)' \
1550 '#define HAVE_SOCKETS' '-lnsl' ||
1551 < ${tmp2}.c run_check sockets 'sockets (via -lsocket -lnsl)' \
1552 '#define HAVE_SOCKETS' '-lsocket -lnsl' ||
1553 feat_bail_required SOCKETS
1555 echo '/* WANT_SOCKETS=0 */' >> ${h}
1556 fi # feat_yes SOCKETS
1558 if feat_yes SOCKETS; then
1559 link_check getaddrinfo 'getaddrinfo(3)' \
1560 '#define HAVE_GETADDRINFO' << \!
1562 #include <sys/types.h>
1563 #include <sys/socket.h>
1567 struct addrinfo a, *ap;
1570 switch((lrv = getaddrinfo("foo
", "0", &a, &ap))){
1574 fprintf(stderr, "%s
\n", gai_strerror(lrv));
1583 if feat_yes SOCKETS && [ -z "${have_getaddrinfo}" ]; then
1584 compile_check arpa_inet_h '<arpa/inet.h>' \
1585 '#define HAVE_ARPA_INET_H' << \!
1587 #include <sys/types.h>
1588 #include <sys/socket.h>
1590 #include <netinet/in.h>
1591 #include <arpa/inet.h>
1594 ${cat} > ${tmp2}.c << \!
1596 #include <sys/types.h>
1597 #include <sys/socket.h>
1601 #include <netinet/in.h>
1602 #ifdef HAVE_ARPA_INET_H
1603 #include <arpa/inet.h>
1606 struct sockaddr_in servaddr;
1607 unsigned short portno;
1610 struct in_addr **pptr;
1613 if((ep = getservbyname("POPPY-PORT
", "tcp
")) != NULL)
1614 portno = (unsigned short)ep->s_port;
1616 if((hp = gethostbyname("POPPY-HOST
")) != NULL){
1617 pptr = (struct in_addr**)hp->h_addr_list;
1618 if(hp->h_addrtype != AF_INET)
1619 fprintf(stderr, "au
\n");
1622 case HOST_NOT_FOUND:
1628 fprintf(stderr, "au
\n");
1633 memset(&servaddr, 0, sizeof servaddr);
1634 servaddr.sin_family = AF_INET;
1635 servaddr.sin_port = htons(portno);
1636 memcpy(&servaddr.sin_addr, *pptr, sizeof(struct in_addr));
1637 fprintf(stderr, "Would connect to
%s
:%d ...
\n",
1638 inet_ntoa(**pptr), (int)portno);
1643 < ${tmp2}.c link_check gethostbyname 'get(serv|host)byname(3)' ||
1644 < ${tmp2}.c link_check gethostbyname \
1645 'get(serv|host)byname(3) (via -nsl)' '' '-lnsl' ||
1646 < ${tmp2}.c link_check gethostbyname \
1647 'get(serv|host)byname(3) (via -lsocket -nsl)' \
1648 '' '-lsocket -lnsl' ||
1649 feat_bail_required SOCKETS
1653 run_check setsockopt 'setsockopt(2)' '#define HAVE_SETSOCKOPT' << \!
1654 #include <sys/socket.h>
1660 if(setsockopt(sockfd, SOL_SOCKET, SO_KEEPALIVE, NULL, 0) == -1 &&
1667 feat_yes SOCKETS && [ -n "${have_setsockopt}" ] &&
1668 link_check so_sndtimeo 'SO_SNDTIMEO' '#define HAVE_SO_SNDTIMEO' << \!
1669 #include <sys/socket.h>
1677 setsockopt(sockfd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof tv);
1678 setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof tv);
1683 feat_yes SOCKETS && [ -n "${have_setsockopt}" ] &&
1684 link_check so_linger 'SO_LINGER' '#define HAVE_SO_LINGER' << \!
1685 #include <sys/socket.h>
1693 setsockopt(sockfd, SOL_SOCKET, SO_LINGER, &li, sizeof li);
1698 if feat_yes SSL; then
1699 if link_check openssl 'OpenSSL (new style *_client_method(3ssl))' \
1701 #define HAVE_OPENSSL 10100' '-lssl -lcrypto' << \!
1702 #include <openssl/ssl.h>
1703 #include <openssl/err.h>
1704 #include <openssl/x509v3.h>
1705 #include <openssl/x509.h>
1706 #include <openssl/rand.h>
1707 #ifdef OPENSSL_NO_TLS1 /* TODO only deduced from OPENSSL_NO_SSL[23]! */
1708 # error We need TLSv1.
1711 SSL_CTX *ctx = SSL_CTX_new(TLS_client_method());
1714 PEM_read_PrivateKey(0, 0, 0, 0);
1720 elif link_check openssl 'OpenSSL (old style *_client_method(3ssl))' \
1722 #define HAVE_OPENSSL 10000' '-lssl -lcrypto' << \!
1723 #include <openssl/ssl.h>
1724 #include <openssl/err.h>
1725 #include <openssl/x509v3.h>
1726 #include <openssl/x509.h>
1727 #include <openssl/rand.h>
1728 #if defined OPENSSL_NO_SSL3 &&\
1729 defined OPENSSL_NO_TLS1 /* TODO only deduced from OPENSSL_NO_SSL[23]! */
1730 # error We need one of SSLv3 and TLSv1.
1733 SSL_CTX *ctx = SSL_CTX_new(SSLv23_client_method());
1736 PEM_read_PrivateKey(0, 0, 0, 0);
1743 feat_bail_required SSL
1746 if [ "${have_openssl}" = 'yes' ]; then
1747 compile_check stack_of 'OpenSSL STACK_OF()' \
1748 '#define HAVE_OPENSSL_STACK_OF' << \!
1749 #include <stdio.h> /* For C89 NULL */
1750 #include <openssl/ssl.h>
1751 #include <openssl/err.h>
1752 #include <openssl/x509v3.h>
1753 #include <openssl/x509.h>
1754 #include <openssl/rand.h>
1756 STACK_OF(GENERAL_NAME) *gens = NULL;
1758 printf("%p
", gens); /* to use it */
1763 link_check ossl_conf 'OpenSSL_modules_load_file() support' \
1764 '#define HAVE_OPENSSL_CONFIG' << \!
1765 #include <stdio.h> /* For C89 NULL */
1766 #include <openssl/conf.h>
1768 CONF_modules_load_file(NULL, NULL, CONF_MFLAGS_IGNORE_MISSING_FILE);
1769 CONF_modules_free();
1774 link_check ossl_conf_ctx 'OpenSSL SSL_CONF_CTX support' \
1775 '#define HAVE_OPENSSL_CONF_CTX' << \!
1777 #include <openssl/ssl.h>
1778 #include <openssl/err.h>
1780 #if HAVE_OPENSSL < 10100
1781 SSL_CTX *ctx = SSL_CTX_new(SSLv23_client_method());
1783 SSL_CTX *ctx = SSL_CTX_new(TLS_client_method());
1785 SSL_CONF_CTX *cctx = SSL_CONF_CTX_new();
1787 SSL_CONF_CTX_set_flags(cctx,
1788 SSL_CONF_FLAG_FILE | SSL_CONF_FLAG_CLIENT |
1789 SSL_CONF_FLAG_CERTIFICATE | SSL_CONF_FLAG_SHOW_ERRORS);
1790 SSL_CONF_CTX_set_ssl_ctx(cctx, ctx);
1791 SSL_CONF_cmd(cctx, "Protocol
", "ALL
");
1792 SSL_CONF_CTX_finish(cctx);
1793 SSL_CONF_CTX_free(cctx);
1799 link_check rand_egd 'OpenSSL RAND_egd()' \
1800 '#define HAVE_OPENSSL_RAND_EGD' << \!
1801 #include <openssl/rand.h>
1803 return RAND_egd("some.where
") > 0;
1807 if feat_yes SSL_ALL_ALGORITHMS; then
1808 if link_check ssl_all_algo 'OpenSSL all-algorithms support' \
1809 '#define HAVE_SSL_ALL_ALGORITHMS' << \!
1810 #include <openssl/evp.h>
1812 OpenSSL_add_all_algorithms();
1813 EVP_get_cipherbyname("two cents i never exist
");
1821 feat_bail_required SSL_ALL_ALGORITHMS
1823 fi # SSL_ALL_ALGORITHMS
1825 if feat_yes MD5 && feat_no NOEXTMD5; then
1826 run_check openssl_md5 'MD5 digest in OpenSSL' \
1827 '#define HAVE_OPENSSL_MD5' << \!
1830 #include <openssl/md5.h>
1832 char const dat[] = "abrakadabrafidibus
";
1833 char dig[16], hex[16 * 2];
1837 memset(dig, 0, sizeof(dig));
1838 memset(hex, 0, sizeof(hex));
1840 MD5_Update(&ctx, dat, sizeof(dat) - 1);
1841 MD5_Final(dig, &ctx);
1843 #define hexchar(n) ((n) > 9 ? (n) - 10 + 'a' : (n) + '0')
1844 for(i = 0; i < sizeof(hex) / 2; i++){
1846 hex[j] = hexchar((dig[i] & 0xf0) >> 4);
1847 hex[++j] = hexchar(dig[i] & 0x0f);
1849 return !!memcmp("6d7d0a3d949da2e96f2aa010f65d8326
", hex, sizeof(hex));
1852 fi # feat_yes MD5 && feat_no NOEXTMD5
1855 echo '/* WANT_SSL=0 */' >> ${h}
1858 if feat_yes SMTP; then
1859 echo '#define HAVE_SMTP' >> ${h}
1861 echo '/* WANT_SMTP=0 */' >> ${h}
1864 if feat_yes POP3; then
1865 echo '#define HAVE_POP3' >> ${h}
1867 echo '/* WANT_POP3=0 */' >> ${h}
1870 if feat_yes GSSAPI; then
1871 ${cat} > ${tmp2}.c << \!
1872 #include <gssapi/gssapi.h>
1874 gss_import_name(0, 0, GSS_C_NT_HOSTBASED_SERVICE, 0);
1875 gss_init_sec_context(0,0,0,0,0,0,0,0,0,0,0,0,0);
1879 ${sed} -e '1s/gssapi\///' < ${tmp2}.c > ${tmp3}.c
1881 if command -v krb5-config >/dev/null 2>&1; then
1882 i=`command -v krb5-config`
1883 GSS_LIBS="`CFLAGS= ${i} --libs gssapi`"
1884 GSS_INCS="`CFLAGS= ${i} --cflags`"
1885 i='GSS-API via krb5-config(1)'
1889 i='GSS-API in gssapi/gssapi.h, libgssapi'
1891 if < ${tmp2}.c link_check gss \
1892 "${i}" '#define HAVE_GSSAPI' "${GSS_LIBS}" "${GSS_INCS}" ||\
1893 < ${tmp3}.c link_check gss \
1894 'GSS-API in gssapi.h, libgssapi' \
1895 '#define HAVE_GSSAPI
1896 #define GSSAPI_REG_INCLUDE' \
1898 < ${tmp2}.c link_check gss 'GSS-API in libgssapi_krb5' \
1899 '#define HAVE_GSSAPI' \
1901 < ${tmp3}.c link_check gss \
1902 'GSS-API in libgssapi, OpenBSD-style (pre 5.3)' \
1903 '#define HAVE_GSSAPI
1904 #define GSS_REG_INCLUDE' \
1905 '-lgssapi -lkrb5 -lcrypto' \
1906 '-I/usr/include/kerberosV' ||\
1907 < ${tmp2}.c link_check gss 'GSS-API in libgss' \
1908 '#define HAVE_GSSAPI' \
1910 link_check gss 'GSS-API in libgssapi_krb5, old-style' \
1911 '#define HAVE_GSSAPI
1912 #define GSSAPI_OLD_STYLE' \
1913 '-lgssapi_krb5' << \!
1914 #include <gssapi/gssapi.h>
1915 #include <gssapi/gssapi_generic.h>
1917 gss_import_name(0, 0, gss_nt_service_name, 0);
1918 gss_init_sec_context(0,0,0,0,0,0,0,0,0,0,0,0,0);
1925 feat_bail_required GSSAPI
1928 echo '/* WANT_GSSAPI=0 */' >> ${h}
1929 fi # feat_yes GSSAPI
1931 if feat_yes NETRC; then
1932 echo '#define HAVE_NETRC' >> ${h}
1934 echo '/* WANT_NETRC=0 */' >> ${h}
1937 if feat_yes AGENT; then
1938 echo '#define HAVE_AGENT' >> ${h}
1940 echo '/* WANT_AGENT=0 */' >> ${h}
1943 if feat_yes IDNA; then
1944 if link_check idna 'GNU Libidn' '#define HAVE_IDNA HAVE_IDNA_LIBIDNA' \
1947 #include <idn-free.h>
1948 #include <stringprep.h>
1950 char *utf8, *idna_ascii, *idna_utf8;
1952 utf8 = stringprep_locale_to_utf8("does.this.work
");
1953 if (idna_to_ascii_8z(utf8, &idna_ascii, IDNA_USE_STD3_ASCII_RULES)
1956 idn_free(idna_ascii);
1957 /* (Rather link check only here) */
1958 idna_utf8 = stringprep_convert(idna_ascii, "UTF-8
", "de_DE
");
1964 elif link_check idna 'idnkit' '#define HAVE_IDNA HAVE_IDNA_IDNKIT' \
1967 #include <idn/api.h>
1968 #include <idn/result.h>
1972 char local_name[256];
1974 r = idn_encodename(IDN_ENCODE_APP, "does.this.work
", ace_name,
1976 if (r != idn_success) {
1977 fprintf(stderr, "idn_encodename failed
: %s
\n", idn_result_tostring(r));
1980 r = idn_decodename(IDN_DECODE_APP, ace_name, local_name, sizeof(local_name));
1981 if (r != idn_success) {
1982 fprintf(stderr, "idn_decodename failed
: %s
\n", idn_result_tostring(r));
1991 feat_bail_required IDNA
1994 if [ -n "${have_idna}" ]; then
1995 echo '#define HAVE_IDNA_LIBIDNA 0' >> ${h}
1996 echo '#define HAVE_IDNA_IDNKIT 1' >> ${h}
1999 echo '/* WANT_IDNA=0 */' >> ${h}
2002 if feat_yes IMAP_SEARCH; then
2003 echo '#define HAVE_IMAP_SEARCH' >> ${h}
2005 echo '/* WANT_IMAP_SEARCH=0 */' >> ${h}
2008 if feat_yes REGEX; then
2009 if link_check regex 'regular expressions' '#define HAVE_REGEX' << \!
2016 if (regcomp(&re, ".
*bsd
", REG_EXTENDED | REG_ICASE | REG_NOSUB) != 0)
2018 status = regexec(&re, "plan9
", 0,NULL, 0);
2020 return !(status == REG_NOMATCH);
2026 feat_bail_required REGEX
2029 echo '/* WANT_REGEX=0 */' >> ${h}
2032 if feat_yes READLINE; then
2034 link_check readline "for readline
(3) (${1})" \
2035 '#define HAVE_READLINE' "${1}" << \!
2037 #include <readline/history.h>
2038 #include <readline/readline.h>
2047 stifle_history(242);
2048 rl = readline("Enter a line
:");
2052 rl_extend_line_buffer(10);
2053 rl_point = rl_end = 10;
2054 rl_pre_input_hook = (rl_hook_func_t*)NULL;
2055 rl_forced_update_display();
2057 hs = history_get_history_state();
2059 he = history_list();
2062 rl_free_line_state();
2063 rl_cleanup_after_signal();
2064 rl_reset_after_signal();
2070 __edrdlib -lreadline ||
2071 __edrdlib '-lreadline -ltermcap' || feat_bail_required READLINE
2072 [ -n "${have_readline}" ] && WANT_TABEXPAND=1
2075 if feat_yes NCL && [ -z "${have_readline}" ] &&\
2076 [ -n "${have_c90amend1}" ]; then
2078 echo '#define HAVE_NCL' >> ${h}
2080 feat_bail_required NCL
2081 echo '/* WANT_{READLINE,NCL}=0 */' >> ${h}
2084 # Generic have-a-command-line-editor switch for those who need it below
2085 if [ -n "${have_ncl}" ] ||\
2086 [ -n "${have_readline}" ]; then
2090 if [ -n "${have_cle}" ] && feat_yes HISTORY; then
2091 echo '#define HAVE_HISTORY' >> ${h}
2093 echo '/* WANT_HISTORY=0 */' >> ${h}
2096 if [ -n "${have_cle}" ] && feat_yes TABEXPAND; then
2097 echo '#define HAVE_TABEXPAND' >> ${h}
2099 echo '/* WANT_TABEXPAND=0 */' >> ${h}
2102 if feat_yes TERMCAP; then
2104 link_check termcap "for termcap
(3) (via
${4})" \
2105 "#define HAVE_TERMCAP${3}" "${1}" << _EOT
2111 #define PTR2SIZE(X) ((unsigned long)(X))
2112 #define UNCONST(P) ((void*)(unsigned long)(void const*)(P))
2113 static char
*_termcap_buffer
, *_termcap_ti
, *_termcap_te
;
2115 char buf
[1024+512], cmdbuf
[2048], *cpb
, *cpti
, *cpte
, *cp;
2117 tgetent
(buf
, getenv
("TERM"));
2120 if ((cp = tgetstr
(UNCONST
("ti"), &cpb
)) == NULL
)
2123 if ((cp = tgetstr
(UNCONST
("te"), &cpb
)) == NULL
)
2125 _termcap_buffer
= malloc
(PTR2SIZE
(cpb
- cmdbuf
));
2126 memcpy
(_termcap_buffer
, cmdbuf
, PTR2SIZE
(cpb
- cmdbuf
));
2127 _termcap_ti
= _termcap_buffer
+ PTR2SIZE
(cpti
- cmdbuf
);
2128 _termcap_te
= _termcap_ti
+ PTR2SIZE
(cpte
- cpti
);
2129 tputs
(_termcap_ti
, 1, &putchar
);
2130 tputs
(_termcap_te
, 1, &putchar
);
2132 return (cp == NULL
);
2137 __termlib
-ltermcap '' '' termcap ||
2138 __termlib
-ltermcap '#include <curses.h>' '
2139 #define HAVE_TERMCAP_CURSES' \
2140 'curses.h / -ltermcap' ||
2141 __termlib
-lcurses '#include <curses.h>' '
2142 #define HAVE_TERMCAP_CURSES' \
2143 'curses.h / -lcurses' ||
2144 feat_bail_required TERMCAP
2146 echo '/* WANT_TERMCAP=0 */' >> ${h}
2149 if feat_yes ERRORS
; then
2150 echo '#define HAVE_ERRORS' >> ${h}
2152 echo '/* WANT_ERRORS=0 */' >> ${h}
2157 if feat_yes SPAM_SPAMC
; then
2158 echo '#define HAVE_SPAM_SPAMC' >> ${h}
2159 if command -v spamc
>/dev
/null
2>&1; then
2160 echo "#define SPAM_SPAMC_PATH \"`command -v spamc`\"" >> ${h}
2163 echo '/* WANT_SPAM_SPAMC=0 */' >> ${h}
2166 if feat_yes SPAM_SPAMD
&& [ -n "${have_af_unix}" ]; then
2167 echo '#define HAVE_SPAM_SPAMD' >> ${h}
2169 feat_bail_required SPAM_SPAMD
2170 echo '/* WANT_SPAM_SPAMD=0 */' >> ${h}
2173 if feat_yes SPAM_FILTER
; then
2174 echo '#define HAVE_SPAM_FILTER' >> ${h}
2176 echo '/* WANT_SPAM_FILTER=0 */' >> ${h}
2179 if feat_yes SPAM_SPAMC || feat_yes SPAM_SPAMD || feat_yes SPAM_FILTER
; then
2180 echo '#define HAVE_SPAM' >> ${h}
2182 echo '/* HAVE_SPAM */' >> ${h}
2185 if feat_yes DOCSTRINGS
; then
2186 echo '#define HAVE_DOCSTRINGS' >> ${h}
2188 echo '/* WANT_DOCSTRINGS=0 */' >> ${h}
2191 if feat_yes QUOTE_FOLD
&&\
2192 [ -n "${have_c90amend1}" ] && [ -n "${have_wcwidth}" ]; then
2193 echo '#define HAVE_QUOTE_FOLD' >> ${h}
2195 echo '/* WANT_QUOTE_FOLD=0 */' >> ${h}
2198 if feat_yes FILTER_HTML_TAGSOUP
; then
2199 echo '#define HAVE_FILTER_HTML_TAGSOUP' >> ${h}
2201 echo '/* WANT_FILTER_HTML_TAGSOUP=0 */' >> ${h}
2204 if feat_yes COLOUR
; then
2205 echo '#define HAVE_COLOUR' >> ${h}
2207 echo '/* WANT_COLOUR=0 */' >> ${h}
2210 if feat_yes DOTLOCK
; then
2211 echo '#define HAVE_DOTLOCK' >> ${h}
2213 echo '/* WANT_DOTLOCK=0 */' >> ${h}
2216 if feat_yes MD5
; then
2217 echo '#define HAVE_MD5' >> ${h}
2219 echo '/* WANT_MD5=0 */' >> ${h}
2224 # Since we cat(1) the content of those to cc/"ld", convert them to single line
2226 < "${1}" > "${2}" ${awk} \
2227 'BEGIN {ORS = " "} /^[^#]/ {print} {next} END {ORS = ""; print "\n"}'
2230 squeeze_em ${inc} ${tmp}
2232 squeeze_em ${lib} ${tmp}
2237 printf '#ifndef n_CONFIG_H\n# define n_CONFIG_H 1\n' > ${h}
2238 ${cat} ${tmp} >> ${h}
2241 printf '\n/* The "feature string
" */\n' >> ${h}
2242 printf '# if defined _ACCMACVAR_SOURCE || defined HAVE_AMALGAMATION\n' >> ${h}
2243 printf 'static char const _features[] = "MIME
"\n' >> ${h}
2244 printf '# ifdef HAVE_SETLOCALE\n ",LOCALES
"\n# endif\n' >> ${h}
2245 printf '# ifdef HAVE_C90AMEND1\n ",MULTIBYTE CHARSETS
"\n# endif\n' >> ${h}
2246 printf '# ifdef HAVE_NL_LANGINFO\n ",TERMINAL CHARSET
"\n# endif\n' >> ${h}
2247 printf '# ifdef HAVE_ICONV\n ",ICONV
"\n# endif\n' >> ${h}
2248 printf '# ifdef HAVE_SOCKETS\n ",NETWORK
"\n# endif\n' >> ${h}
2249 printf '# ifdef HAVE_SSL\n ",S
/MIME
,SSL
/TLS
"\n# endif\n' >> ${h}
2250 printf '# ifdef HAVE_SSL_ALL_ALGORITHMS\n ",SSL-ALL-ALGORITHMS
"\n# endif\n'\
2252 printf '# ifdef HAVE_SMTP\n ",SMTP
"\n# endif\n' >> ${h}
2253 printf '# ifdef HAVE_POP3\n ",POP3
"\n# endif\n' >> ${h}
2254 printf '# ifdef HAVE_GSSAPI\n ",GSS-API
"\n# endif\n' >> ${h}
2255 printf '# ifdef HAVE_MD5\n ",MD5
[APOP
,CRAM-MD5
]"\n# endif\n' >> ${h}
2256 printf '# ifdef HAVE_NETRC\n ",NETRC
"\n# endif\n' >> ${h}
2257 printf '# ifdef HAVE_AGENT\n ",AGENT
"\n# endif\n' >> ${h}
2258 printf '# ifdef HAVE_IDNA\n ",IDNA
"\n# endif\n' >> ${h}
2259 printf '# ifdef HAVE_IMAP_SEARCH\n ",IMAP-SEARCH
"\n# endif\n' >> ${h}
2260 printf '# ifdef HAVE_REGEX\n ",REGEX
"\n# endif\n' >> ${h}
2261 printf '# ifdef HAVE_READLINE\n ",READLINE
"\n# endif\n' >> ${h}
2262 printf '# ifdef HAVE_NCL\n ",NCL
"\n# endif\n' >> ${h}
2263 printf '# ifdef HAVE_TABEXPAND\n ",TABEXPAND
"\n# endif\n' >> ${h}
2264 printf '# ifdef HAVE_HISTORY\n ",HISTORY
"\n# endif\n' >> ${h}
2265 printf '# ifdef HAVE_TERMCAP\n ",TERMCAP
"\n# endif\n' >> ${h}
2266 printf '# ifdef HAVE_SPAM_SPAMC\n ",SPAMC
"\n# endif\n' >> ${h}
2267 printf '# ifdef HAVE_SPAM_SPAMD\n ",SPAMD
"\n# endif\n' >> ${h}
2268 printf '# ifdef HAVE_SPAM_FILTER\n ",SPAMFILTER
"\n# endif\n' >> ${h}
2269 printf '# ifdef HAVE_DOCSTRINGS\n ",DOCSTRINGS
"\n# endif\n' >> ${h}
2270 printf '# ifdef HAVE_QUOTE_FOLD\n ",QUOTE-FOLD
"\n# endif\n' >> ${h}
2271 printf '# ifdef HAVE_FILTER_HTML_TAGSOUP\n ",HTML-FILTER
"\n# endif\n' >> ${h}
2272 printf '# ifdef HAVE_COLOUR\n ",COLOUR
"\n# endif\n' >> ${h}
2273 printf '# ifdef HAVE_DOTLOCK\n ",DOTLOCK-FILES
"\n# endif\n' >> ${h}
2274 printf '# ifdef HAVE_DEBUG\n ",DEBUG
"\n# endif\n' >> ${h}
2275 printf '# ifdef HAVE_DEVEL\n ",DEVEL
"\n# endif\n' >> ${h}
2276 printf ';\n# endif /* _ACCMACVAR_SOURCE || HAVE_AMALGAMATION */\n' >> ${h}
2278 # Create the real mk.mk
2279 # Note we cannout use explicit ./ filename prefix for source and object
2280 # pathnames because of a bug in bmake(1)
2281 ${rm} -rf ${tmp0}.* ${tmp0}*
2282 printf 'OBJ_SRC = ' >> ${mk}
2283 if feat_no AMALGAMATION; then
2284 for i in `printf '%s\n' *.c | ${sort}`; do
2285 if [ "${i}" = privsep.c ]; then
2288 printf "${i} " >> ${mk}
2290 printf '\nAMALGAM_TARGET =\nAMALGAM_DEP =\n' >> ${mk}
2292 printf 'main.c\nAMALGAM_TARGET = main.o\nAMALGAM_DEP = ' >> ${mk}
2294 printf '\n/* HAVE_AMALGAMATION: include sources */\n' >> ${h}
2295 printf '#elif _CONFIG_H + 0 == 1\n' >> ${h}
2296 printf '# undef _CONFIG_H\n' >> ${h}
2297 printf '# define _CONFIG_H 2\n' >> ${h}
2298 for i in `printf '%s\n' *.c | ${sort}`; do
2299 if [ "${i}" = "${j}" ] || [ "${i}" = main.c ] || \
2300 [ "${i}" = privsep.c ]; then
2303 printf "${i} " >> ${mk}
2304 printf "# include \"${i}\"\n" >> ${h}
2307 # tcc(1) fails on 2015-11-13 unless this #else clause existed
2308 echo '#else' >> ${h}
2311 printf '#endif /* n_CONFIG_H */\n' >> ${h}
2313 echo "LIBS = `${cat} ${lib}`" >> ${mk}
2314 echo "INCS
= `${cat} ${inc}`" >> ${mk}
2316 ${cat} ./mk-mk.in >> ${mk}
2320 ${cat} > ${tmp2}.c << \!
2323 :The following optional features are enabled:
2324 #ifdef HAVE_SETLOCALE
2325 : + Locale support: Printable characters depend on the environment
2326 # ifdef HAVE_C90AMEND1
2327 : + Multibyte character support
2329 # ifdef HAVE_NL_LANGINFO
2330 : + Automatic detection of terminal character set
2334 : + Character set conversion using iconv()
2340 # ifdef HAVE_OPENSSL
2341 : + S/MIME and SSL/TLS (OpenSSL)
2343 # ifdef HAVE_SSL_ALL_ALGORITHMS
2344 : + + Support for more ("all") digest and cipher algorithms
2354 : + GSS-API authentication
2357 : + MD5 message digest (APOP, CRAM-MD5)
2360 : + .netrc file support
2363 : + Password query through agent
2366 : + IDNA (internationalized domain names for applications) support
2368 #ifdef HAVE_IMAP_SEARCH
2369 : + IMAP-style search expressions
2372 : + Regular expression support (searches, conditional expressions etc.)
2374 #if defined HAVE_READLINE || defined HAVE_NCL
2375 # ifdef HAVE_READLINE
2376 : + Command line editing via readline(3)
2378 : + Command line editing via N(ail) C(ommand) L(ine)
2380 # ifdef HAVE_TABEXPAND
2381 : + + Tabulator expansion
2383 # ifdef HAVE_HISTORY
2384 : + + History management
2388 : + Terminal capability queries
2392 # ifdef HAVE_SPAM_SPAMC
2393 : + + Via spamc(1) (of spamassassin(1))
2395 # ifdef HAVE_SPAM_SPAMD
2396 : + + Directly via spamd(1) (of spamassassin(1))
2398 # ifdef HAVE_SPAM_FILTER
2399 : + + Via freely configurable *spam-filter-XY*s
2402 #ifdef HAVE_DOCSTRINGS
2403 : + Documentation summary strings
2405 #ifdef HAVE_QUOTE_FOLD
2406 : + Extended *quote-fold*ing
2408 #ifdef HAVE_FILTER_HTML_TAGSOUP
2409 : + Builtin HTML-to-text filter (for display purposes, primitive)
2412 : + Coloured message display (simple)
2415 : + Dotlock files and privilege-separated file dotlock program
2418 :The following optional features are disabled:
2419 #ifndef HAVE_SETLOCALE
2420 : - Locale support: Only ASCII characters are recognized
2422 # ifndef HAVE_C90AMEND1
2423 : - Multibyte character support
2425 # ifndef HAVE_NL_LANGINFO
2426 : - Automatic detection of terminal character set
2429 : - Character set conversion using iconv()
2430 : _ (Ooooh, no iconv(3), NO character set conversion possible! Really...)
2432 #ifndef HAVE_SOCKETS
2436 : - S/MIME and SSL/TLS
2438 # ifndef HAVE_SSL_ALL_ALGORITHMS
2439 : - Support for more S/MIME and SSL/TLS digest and cipher algorithms
2449 : - GSS-API authentication
2452 : - MD5 message digest (APOP, CRAM-MD5)
2455 : - .netrc file support
2458 : - Password query through agent
2461 : - IDNA (internationalized domain names for applications) support
2463 #ifndef HAVE_IMAP_SEARCH
2464 : - IMAP-style search expressions
2467 : - Regular expression support
2469 #if !defined HAVE_READLINE && !defined HAVE_NCL
2470 : - Command line editing and history
2472 #ifndef HAVE_TERMCAP
2473 : - Terminal capability queries
2478 #ifndef HAVE_DOCSTRINGS
2479 : - Documentation summary strings
2481 #ifndef HAVE_QUOTE_FOLD
2482 : - Extended *quote-fold*ing
2484 #ifndef HAVE_FILTER_HTML_TAGSOUP
2485 : - Builtin HTML-to-text filter (for display purposes, primitive)
2488 : - Coloured message display (simple)
2490 #ifndef HAVE_DOTLOCK
2491 : - Dotlock files and privilege-separated file dotlock program
2494 #if !defined HAVE_WORDEXP || !defined HAVE_FCHDIR ||\
2495 defined HAVE_DEBUG || defined HAVE_DEVEL
2497 # ifndef HAVE_WORDEXP
2498 : . WARNING: the function wordexp(3) could not be found.
2499 : _ This means that echo(1) will be used via the sh(1)ell in order
2500 : _ to expand shell meta characters in filenames, which is a potential
2501 : _ security hole. Consider to either upgrade your system or set the
2502 : _ *SHELL* variable to some safe(r) wrapper script.
2503 : _ P.S.: the codebase is in transition away from wordexp(3) to some
2504 : _ safe (restricted) internal mechanism, see "COMMANDS" manual, read
2505 : _ about shell word expression in its introduction for more on that.
2507 # ifndef HAVE_FCHDIR
2508 : . The function fchdir(2) could not be found. We will use chdir(2)
2509 : _ instead. This is not a problem unless the current working
2510 : _ directory is changed while this program is inside of it.
2513 : . Debug enabled binary: not meant to be used by end-users: THANKS!
2516 : . Computers do not blunder.
2519 #endif /* Remarks */
2521 : . System-wide resource file: SYSCONFDIR/SYSCONFRC
2524 : . libexecdir: LIBEXECDIR
2527 : . sendmail(1): SENDMAIL (argv[0] = SENDMAIL_PROGNAME)
2528 : . Mail spool directory: MAILSPOOL
2532 ${make} -f ${makefile} ${tmp2}.x
2533 < ${tmp2}.x ${sed} -e '/^[^:]/d; /^$/d; s/^://' |