Home | History | Annotate | Download | only in src
      1 #!/bin/sh
      2 srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.707 2016/11/11 23:31:29 tg Exp $'
      3 #-
      4 # Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
      5 #		2011, 2012, 2013, 2014, 2015, 2016
      6 #	mirabilos <m (at] mirbsd.org>
      7 #
      8 # Provided that these terms and disclaimer and all copyright notices
      9 # are retained or reproduced in an accompanying document, permission
     10 # is granted to deal in this work without restriction, including un-
     11 # limited rights to use, publicly perform, distribute, sell, modify,
     12 # merge, give away, or sublicence.
     13 #
     14 # This work is provided "AS IS" and WITHOUT WARRANTY of any kind, to
     15 # the utmost extent permitted by applicable law, neither express nor
     16 # implied; without malicious intent or gross negligence. In no event
     17 # may a licensor, author or contributor be held liable for indirect,
     18 # direct, other damage, loss, or other issues arising in any way out
     19 # of dealing in the work, even if advised of the possibility of such
     20 # damage or existence of a defect, except proven that it results out
     21 # of said person's immediate fault when using the work as intended.
     22 #-
     23 # People analysing the output must whitelist conftest.c for any kind
     24 # of compiler warning checks (mirtoconf is by design not quiet).
     25 #
     26 # Used environment documentation is at the end of this file.
     27 
     28 LC_ALL=C
     29 export LC_ALL
     30 
     31 case $ZSH_VERSION:$VERSION in
     32 :zsh*) ZSH_VERSION=2 ;;
     33 esac
     34 
     35 if test -n "${ZSH_VERSION+x}" && (emulate sh) >/dev/null 2>&1; then
     36 	emulate sh
     37 	NULLCMD=:
     38 fi
     39 
     40 if test -d /usr/xpg4/bin/. >/dev/null 2>&1; then
     41 	# Solaris: some of the tools have weird behaviour, use portable ones
     42 	PATH=/usr/xpg4/bin:$PATH
     43 	export PATH
     44 fi
     45 
     46 nl='
     47 '
     48 safeIFS='	'
     49 safeIFS=" $safeIFS$nl"
     50 IFS=$safeIFS
     51 allu=QWERTYUIOPASDFGHJKLZXCVBNM
     52 alll=qwertyuiopasdfghjklzxcvbnm
     53 alln=0123456789
     54 alls=______________________________________________________________
     55 
     56 genopt_die() {
     57 	if test -n "$1"; then
     58 		echo >&2 "E: $*"
     59 		echo >&2 "E: in '$srcfile': '$line'"
     60 	else
     61 		echo >&2 "E: invalid input in '$srcfile': '$line'"
     62 	fi
     63 	rm -f "$bn.gen"
     64 	exit 1
     65 }
     66 
     67 genopt_soptc() {
     68 	optc=`echo "$line" | sed 's/^[<>]\(.\).*$/\1/'`
     69 	test x"$optc" = x'|' && return
     70 	optclo=`echo "$optc" | tr $allu $alll`
     71 	if test x"$optc" = x"$optclo"; then
     72 		islo=1
     73 	else
     74 		islo=0
     75 	fi
     76 	sym=`echo "$line" | sed 's/^[<>]/|/'`
     77 	o_str=$o_str$nl"<$optclo$islo$sym"
     78 }
     79 
     80 genopt_scond() {
     81 	case x$cond in
     82 	x)
     83 		cond=
     84 		;;
     85 	x*' '*)
     86 		cond=`echo "$cond" | sed 's/^ //'`
     87 		cond="#if $cond"
     88 		;;
     89 	x'!'*)
     90 		cond=`echo "$cond" | sed 's/^!//'`
     91 		cond="#ifndef $cond"
     92 		;;
     93 	x*)
     94 		cond="#ifdef $cond"
     95 		;;
     96 	esac
     97 }
     98 
     99 do_genopt() {
    100 	srcfile=$1
    101 	test -f "$srcfile" || genopt_die Source file \$srcfile not set.
    102 	bn=`basename "$srcfile" | sed 's/.opt$//'`
    103 	o_hdr='/* +++ GENERATED FILE +++ DO NOT EDIT +++ */'
    104 	o_gen=
    105 	o_str=
    106 	o_sym=
    107 	ddefs=
    108 	state=0
    109 	exec <"$srcfile"
    110 	IFS=
    111 	while IFS= read line; do
    112 		IFS=$safeIFS
    113 		case $state:$line in
    114 		2:'|'*)
    115 			# end of input
    116 			o_sym=`echo "$line" | sed 's/^.//'`
    117 			o_gen=$o_gen$nl"#undef F0"
    118 			o_gen=$o_gen$nl"#undef FN"
    119 			o_gen=$o_gen$ddefs
    120 			state=3
    121 			;;
    122 		1:@@)
    123 			# start of data block
    124 			o_gen=$o_gen$nl"#endif"
    125 			o_gen=$o_gen$nl"#ifndef F0"
    126 			o_gen=$o_gen$nl"#define F0 FN"
    127 			o_gen=$o_gen$nl"#endif"
    128 			state=2
    129 			;;
    130 		*:@@*)
    131 			genopt_die ;;
    132 		0:/\*-|0:\ \**|0:)
    133 			o_hdr=$o_hdr$nl$line
    134 			;;
    135 		0:@*|1:@*)
    136 			# start of a definition block
    137 			sym=`echo "$line" | sed 's/^@//'`
    138 			if test $state = 0; then
    139 				o_gen=$o_gen$nl"#if defined($sym)"
    140 			else
    141 				o_gen=$o_gen$nl"#elif defined($sym)"
    142 			fi
    143 			ddefs="$ddefs$nl#undef $sym"
    144 			state=1
    145 			;;
    146 		0:*|3:*)
    147 			genopt_die ;;
    148 		1:*)
    149 			# definition line
    150 			o_gen=$o_gen$nl$line
    151 			;;
    152 		2:'<'*'|'*)
    153 			genopt_soptc
    154 			;;
    155 		2:'>'*'|'*)
    156 			genopt_soptc
    157 			cond=`echo "$line" | sed 's/^[^|]*|//'`
    158 			genopt_scond
    159 			case $optc in
    160 			'|') optc=0 ;;
    161 			*) optc=\'$optc\' ;;
    162 			esac
    163 			IFS= read line || genopt_die Unexpected EOF
    164 			IFS=$safeIFS
    165 			test -n "$cond" && o_gen=$o_gen$nl"$cond"
    166 			o_gen=$o_gen$nl"$line, $optc)"
    167 			test -n "$cond" && o_gen=$o_gen$nl"#endif"
    168 			;;
    169 		esac
    170 	done
    171 	case $state:$o_sym in
    172 	3:) genopt_die Expected optc sym at EOF ;;
    173 	3:*) ;;
    174 	*) genopt_die Missing EOF marker ;;
    175 	esac
    176 	echo "$o_str" | sort | while IFS='|' read x opts cond; do
    177 		IFS=$safeIFS
    178 		test -n "$x" || continue
    179 		genopt_scond
    180 		test -n "$cond" && echo "$cond"
    181 		echo "\"$opts\""
    182 		test -n "$cond" && echo "#endif"
    183 	done | {
    184 		echo "$o_hdr"
    185 		echo "#ifndef $o_sym$o_gen"
    186 		echo "#else"
    187 		cat
    188 		echo "#undef $o_sym"
    189 		echo "#endif"
    190 	} >"$bn.gen"
    191 	IFS=$safeIFS
    192 	return 0
    193 }
    194 
    195 if test x"$BUILDSH_RUN_GENOPT" = x"1"; then
    196 	set x -G "$srcfile"
    197 	shift
    198 fi
    199 if test x"$1" = x"-G"; then
    200 	do_genopt "$2"
    201 	exit $?
    202 fi
    203 
    204 echo "For the build logs, demonstrate that /dev/null and /dev/tty exist:"
    205 ls -l /dev/null /dev/tty
    206 
    207 v() {
    208 	$e "$*"
    209 	eval "$@"
    210 }
    211 
    212 vv() {
    213 	_c=$1
    214 	shift
    215 	$e "\$ $*" 2>&1
    216 	eval "$@" >vv.out 2>&1
    217 	sed "s^${_c} " <vv.out
    218 }
    219 
    220 vq() {
    221 	eval "$@"
    222 }
    223 
    224 rmf() {
    225 	for _f in "$@"; do
    226 		case $_f in
    227 		Build.sh|check.pl|check.t|dot.mkshrc|*.1|*.c|*.h|*.ico|*.opt) ;;
    228 		*) rm -f "$_f" ;;
    229 		esac
    230 	done
    231 }
    232 
    233 tcfn=no
    234 bi=
    235 ui=
    236 ao=
    237 fx=
    238 me=`basename "$0"`
    239 orig_CFLAGS=$CFLAGS
    240 phase=x
    241 oldish_ed=stdout-ed,no-stderr-ed
    242 
    243 if test -t 1; then
    244 	bi='[1m'
    245 	ui='[4m'
    246 	ao='[0m'
    247 fi
    248 
    249 upper() {
    250 	echo :"$@" | sed 's/^://' | tr $alll $allu
    251 }
    252 
    253 # clean up after ac_testrun()
    254 ac_testdone() {
    255 	eval HAVE_$fu=$fv
    256 	fr=no
    257 	test 0 = $fv || fr=yes
    258 	$e "$bi==> $fd...$ao $ui$fr$ao$fx"
    259 	fx=
    260 }
    261 
    262 # ac_cache label: sets f, fu, fv?=0
    263 ac_cache() {
    264 	f=$1
    265 	fu=`upper $f`
    266 	eval fv=\$HAVE_$fu
    267 	case $fv in
    268 	0|1)
    269 		fx=' (cached)'
    270 		return 0
    271 		;;
    272 	esac
    273 	fv=0
    274 	return 1
    275 }
    276 
    277 # ac_testinit label [!] checkif[!]0 [setlabelifcheckis[!]0] useroutput
    278 # returns 1 if value was cached/implied, 0 otherwise: call ac_testdone
    279 ac_testinit() {
    280 	if ac_cache $1; then
    281 		test x"$2" = x"!" && shift
    282 		test x"$2" = x"" || shift
    283 		fd=${3-$f}
    284 		ac_testdone
    285 		return 1
    286 	fi
    287 	fc=0
    288 	if test x"$2" = x""; then
    289 		ft=1
    290 	else
    291 		if test x"$2" = x"!"; then
    292 			fc=1
    293 			shift
    294 		fi
    295 		eval ft=\$HAVE_`upper $2`
    296 		shift
    297 	fi
    298 	fd=${3-$f}
    299 	if test $fc = "$ft"; then
    300 		fv=$2
    301 		fx=' (implied)'
    302 		ac_testdone
    303 		return 1
    304 	fi
    305 	$e ... $fd
    306 	return 0
    307 }
    308 
    309 # pipe .c | ac_test[n] [!] label [!] checkif[!]0 [setlabelifcheckis[!]0] useroutput
    310 ac_testnnd() {
    311 	if test x"$1" = x"!"; then
    312 		fr=1
    313 		shift
    314 	else
    315 		fr=0
    316 	fi
    317 	ac_testinit "$@" || return 1
    318 	cat >conftest.c
    319 	vv ']' "$CC $CFLAGS $CPPFLAGS $LDFLAGS $NOWARN conftest.c $LIBS $ccpr"
    320 	test $tcfn = no && test -f a.out && tcfn=a.out
    321 	test $tcfn = no && test -f a.exe && tcfn=a.exe
    322 	test $tcfn = no && test -f conftest.exe && tcfn=conftest.exe
    323 	test $tcfn = no && test -f conftest && tcfn=conftest
    324 	if test -f $tcfn; then
    325 		test 1 = $fr || fv=1
    326 	else
    327 		test 0 = $fr || fv=1
    328 	fi
    329 	vscan=
    330 	if test $phase = u; then
    331 		test $ct = gcc && vscan='unrecogni[sz]ed'
    332 		test $ct = hpcc && vscan='unsupported'
    333 		test $ct = pcc && vscan='unsupported'
    334 		test $ct = sunpro && vscan='-e ignored -e turned.off'
    335 	fi
    336 	test -n "$vscan" && grep $vscan vv.out >/dev/null 2>&1 && fv=$fr
    337 	return 0
    338 }
    339 ac_testn() {
    340 	ac_testnnd "$@" || return
    341 	rmf conftest.c conftest.o ${tcfn}* vv.out
    342 	ac_testdone
    343 }
    344 
    345 # ac_ifcpp cppexpr [!] label [!] checkif[!]0 [setlabelifcheckis[!]0] useroutput
    346 ac_ifcpp() {
    347 	expr=$1; shift
    348 	ac_testn "$@" <<-EOF
    349 		#include <unistd.h>
    350 		extern int thiswillneverbedefinedIhope(void);
    351 		int main(void) { return (isatty(0) +
    352 		#$expr
    353 		    0
    354 		#else
    355 		/* force a failure: expr is false */
    356 		    thiswillneverbedefinedIhope()
    357 		#endif
    358 		    ); }
    359 EOF
    360 	test x"$1" = x"!" && shift
    361 	f=$1
    362 	fu=`upper $f`
    363 	eval fv=\$HAVE_$fu
    364 	test x"$fv" = x"1"
    365 }
    366 
    367 add_cppflags() {
    368 	CPPFLAGS="$CPPFLAGS $*"
    369 }
    370 
    371 ac_cppflags() {
    372 	test x"$1" = x"" || fu=$1
    373 	fv=$2
    374 	test x"$2" = x"" && eval fv=\$HAVE_$fu
    375 	add_cppflags -DHAVE_$fu=$fv
    376 }
    377 
    378 ac_test() {
    379 	ac_testn "$@"
    380 	ac_cppflags
    381 }
    382 
    383 # ac_flags [-] add varname cflags [text] [ldflags]
    384 ac_flags() {
    385 	if test x"$1" = x"-"; then
    386 		shift
    387 		hf=1
    388 	else
    389 		hf=0
    390 	fi
    391 	fa=$1
    392 	vn=$2
    393 	f=$3
    394 	ft=$4
    395 	fl=$5
    396 	test x"$ft" = x"" && ft="if $f can be used"
    397 	save_CFLAGS=$CFLAGS
    398 	CFLAGS="$CFLAGS $f"
    399 	if test -n "$fl"; then
    400 		save_LDFLAGS=$LDFLAGS
    401 		LDFLAGS="$LDFLAGS $fl"
    402 	fi
    403 	if test 1 = $hf; then
    404 		ac_testn can_$vn '' "$ft"
    405 	else
    406 		ac_testn can_$vn '' "$ft" <<-'EOF'
    407 			/* evil apo'stroph in comment test */
    408 			#include <unistd.h>
    409 			int main(void) { return (isatty(0)); }
    410 		EOF
    411 	fi
    412 	eval fv=\$HAVE_CAN_`upper $vn`
    413 	if test -n "$fl"; then
    414 		test 11 = $fa$fv || LDFLAGS=$save_LDFLAGS
    415 	fi
    416 	test 11 = $fa$fv || CFLAGS=$save_CFLAGS
    417 }
    418 
    419 # ac_header [!] header [prereq ...]
    420 ac_header() {
    421 	if test x"$1" = x"!"; then
    422 		na=1
    423 		shift
    424 	else
    425 		na=0
    426 	fi
    427 	hf=$1; shift
    428 	hv=`echo "$hf" | tr -d '\012\015' | tr -c $alll$allu$alln $alls`
    429 	echo "/* NeXTstep bug workaround */" >x
    430 	for i
    431 	do
    432 		case $i in
    433 		_time)
    434 			echo '#if HAVE_BOTH_TIME_H' >>x
    435 			echo '#include <sys/time.h>' >>x
    436 			echo '#include <time.h>' >>x
    437 			echo '#elif HAVE_SYS_TIME_H' >>x
    438 			echo '#include <sys/time.h>' >>x
    439 			echo '#elif HAVE_TIME_H' >>x
    440 			echo '#include <time.h>' >>x
    441 			echo '#endif' >>x
    442 			;;
    443 		*)
    444 			echo "#include <$i>" >>x
    445 			;;
    446 		esac
    447 	done
    448 	echo "#include <$hf>" >>x
    449 	echo '#include <unistd.h>' >>x
    450 	echo 'int main(void) { return (isatty(0)); }' >>x
    451 	ac_testn "$hv" "" "<$hf>" <x
    452 	rmf x
    453 	test 1 = $na || ac_cppflags
    454 }
    455 
    456 addsrcs() {
    457 	if test x"$1" = x"!"; then
    458 		fr=0
    459 		shift
    460 	else
    461 		fr=1
    462 	fi
    463 	eval i=\$$1
    464 	test $fr = "$i" && case " $SRCS " in
    465 	*\ $2\ *)	;;
    466 	*)		SRCS="$SRCS $2" ;;
    467 	esac
    468 }
    469 
    470 
    471 curdir=`pwd` srcdir=`dirname "$0" 2>/dev/null`
    472 case x$srcdir in
    473 x)
    474 	srcdir=.
    475 	;;
    476 *\ *|*"	"*|*"$nl"*)
    477 	echo >&2 Source directory should not contain space or tab or newline.
    478 	echo >&2 Errors may occur.
    479 	;;
    480 *"'"*)
    481 	echo Source directory must not contain single quotes.
    482 	exit 1
    483 	;;
    484 esac
    485 dstversion=`sed -n '/define MKSH_VERSION/s/^.*"\([^"]*\)".*$/\1/p' "$srcdir/sh.h"`
    486 add_cppflags -DMKSH_BUILDSH
    487 
    488 e=echo
    489 r=0
    490 eq=0
    491 pm=0
    492 cm=normal
    493 optflags=-std-compile-opts
    494 check_categories=
    495 last=
    496 tfn=
    497 legacy=0
    498 
    499 for i
    500 do
    501 	case $last:$i in
    502 	c:combine|c:dragonegg|c:llvm|c:lto)
    503 		cm=$i
    504 		last=
    505 		;;
    506 	c:*)
    507 		echo "$me: Unknown option -c '$i'!" >&2
    508 		exit 1
    509 		;;
    510 	o:*)
    511 		optflags=$i
    512 		last=
    513 		;;
    514 	t:*)
    515 		tfn=$i
    516 		last=
    517 		;;
    518 	:-c)
    519 		last=c
    520 		;;
    521 	:-G)
    522 		echo "$me: Do not call me with '-G'!" >&2
    523 		exit 1
    524 		;;
    525 	:-g)
    526 		# checker, debug, valgrind build
    527 		add_cppflags -DDEBUG
    528 		CFLAGS="$CFLAGS -g3 -fno-builtin"
    529 		;;
    530 	:-j)
    531 		pm=1
    532 		;;
    533 	:-L)
    534 		legacy=1
    535 		;;
    536 	:+L)
    537 		legacy=0
    538 		;;
    539 	:-M)
    540 		cm=makefile
    541 		;;
    542 	:-O)
    543 		optflags=-std-compile-opts
    544 		;;
    545 	:-o)
    546 		last=o
    547 		;;
    548 	:-Q)
    549 		eq=1
    550 		;;
    551 	:-r)
    552 		r=1
    553 		;;
    554 	:-t)
    555 		last=t
    556 		;;
    557 	:-v)
    558 		echo "Build.sh $srcversion"
    559 		echo "for mksh $dstversion"
    560 		exit 0
    561 		;;
    562 	:*)
    563 		echo "$me: Unknown option '$i'!" >&2
    564 		exit 1
    565 		;;
    566 	*)
    567 		echo "$me: Unknown option -'$last' '$i'!" >&2
    568 		exit 1
    569 		;;
    570 	esac
    571 done
    572 if test -n "$last"; then
    573 	echo "$me: Option -'$last' not followed by argument!" >&2
    574 	exit 1
    575 fi
    576 
    577 test -z "$tfn" && if test $legacy = 0; then
    578 	tfn=mksh
    579 else
    580 	tfn=lksh
    581 fi
    582 if test -d $tfn || test -d $tfn.exe; then
    583 	echo "$me: Error: ./$tfn is a directory!" >&2
    584 	exit 1
    585 fi
    586 rmf a.exe* a.out* conftest.c conftest.exe* *core core.* ${tfn}* *.bc *.dbg \
    587     *.ll *.o *.gen *.cat1 Rebuild.sh lft no signames.inc test.sh x vv.out
    588 
    589 SRCS="lalloc.c eval.c exec.c expr.c funcs.c histrap.c jobs.c"
    590 SRCS="$SRCS lex.c main.c misc.c shf.c syn.c tree.c var.c"
    591 
    592 if test $legacy = 0; then
    593 	SRCS="$SRCS edit.c"
    594 	check_categories="$check_categories shell:legacy-no int:32"
    595 else
    596 	check_categories="$check_categories shell:legacy-yes"
    597 	add_cppflags -DMKSH_LEGACY_MODE
    598 	HAVE_PERSISTENT_HISTORY=0
    599 fi
    600 
    601 if test x"$srcdir" = x"."; then
    602 	CPPFLAGS="-I. $CPPFLAGS"
    603 else
    604 	CPPFLAGS="-I. -I'$srcdir' $CPPFLAGS"
    605 fi
    606 test -n "$LDSTATIC" && if test -n "$LDFLAGS"; then
    607 	LDFLAGS="$LDFLAGS $LDSTATIC"
    608 else
    609 	LDFLAGS=$LDSTATIC
    610 fi
    611 
    612 if test -z "$TARGET_OS"; then
    613 	x=`uname -s 2>/dev/null || uname`
    614 	test x"$x" = x"`uname -n 2>/dev/null`" || TARGET_OS=$x
    615 fi
    616 if test -z "$TARGET_OS"; then
    617 	echo "$me: Set TARGET_OS, your uname is broken!" >&2
    618 	exit 1
    619 fi
    620 oswarn=
    621 ccpc=-Wc,
    622 ccpl=-Wl,
    623 tsts=
    624 ccpr='|| for _f in ${tcfn}*; do case $_f in Build.sh|check.pl|check.t|dot.mkshrc|*.1|*.c|*.h|*.ico|*.opt) ;; *) rm -f "$_f" ;; esac; done'
    625 
    626 # Evil hack
    627 if test x"$TARGET_OS" = x"Android"; then
    628 	check_categories="$check_categories android"
    629 	TARGET_OS=Linux
    630 fi
    631 
    632 # Evil OS
    633 if test x"$TARGET_OS" = x"Minix"; then
    634 	echo >&2 "
    635 WARNING: additional checks before running Build.sh required!
    636 You can avoid these by calling Build.sh correctly, see below.
    637 "
    638 	cat >conftest.c <<'EOF'
    639 #include <sys/types.h>
    640 const char *
    641 #ifdef _NETBSD_SOURCE
    642 ct="Ninix3"
    643 #else
    644 ct="Minix3"
    645 #endif
    646 ;
    647 EOF
    648 	ct=unknown
    649 	vv ']' "${CC-cc} -E $CFLAGS $CPPFLAGS $NOWARN conftest.c | grep ct= | tr -d \\\\015 >x"
    650 	sed 's/^/[ /' x
    651 	eval `cat x`
    652 	rmf x vv.out
    653 	case $ct in
    654 	Minix3|Ninix3)
    655 		echo >&2 "
    656 Warning: you set TARGET_OS to $TARGET_OS but that is ambiguous.
    657 Please set it to either Minix3 or Ninix3, whereas the latter is
    658 all versions of Minix with even partial NetBSD(R) userland. The
    659 value determined from your compiler for the current compilation
    660 (which may be wrong) is: $ct
    661 "
    662 		TARGET_OS=$ct
    663 		;;
    664 	*)
    665 		echo >&2 "
    666 Warning: you set TARGET_OS to $TARGET_OS but that is ambiguous.
    667 Please set it to either Minix3 or Ninix3, whereas the latter is
    668 all versions of Minix with even partial NetBSD(R) userland. The
    669 proper value couldn't be determined, continue at your own risk.
    670 "
    671 		;;
    672 	esac
    673 fi
    674 
    675 # Configuration depending on OS revision, on OSes that need them
    676 case $TARGET_OS in
    677 NEXTSTEP)
    678 	test x"$TARGET_OSREV" = x"" && TARGET_OSREV=`hostinfo 2>&1 | \
    679 	    grep 'NeXT Mach [0-9][0-9.]*:' | \
    680 	    sed 's/^.*NeXT Mach \([0-9][0-9.]*\):.*$/\1/'`
    681 	;;
    682 QNX|SCO_SV)
    683 	test x"$TARGET_OSREV" = x"" && TARGET_OSREV=`uname -r`
    684 	;;
    685 esac
    686 
    687 # Configuration depending on OS name
    688 case $TARGET_OS in
    689 386BSD)
    690 	: "${HAVE_CAN_OTWO=0}"
    691 	add_cppflags -DMKSH_NO_SIGSETJMP
    692 	add_cppflags -DMKSH_TYPEDEF_SIG_ATOMIC_T=int
    693 	;;
    694 AIX)
    695 	add_cppflags -D_ALL_SOURCE
    696 	: "${HAVE_SETLOCALE_CTYPE=0}"
    697 	;;
    698 BeOS)
    699 	case $KSH_VERSION in
    700 	*MIRBSD\ KSH*)
    701 		oswarn="; it has minor issues"
    702 		;;
    703 	*)
    704 		oswarn="; you must recompile mksh with"
    705 		oswarn="$oswarn${nl}itself in a second stage"
    706 		;;
    707 	esac
    708 	# BeOS has no real tty either
    709 	add_cppflags -DMKSH_UNEMPLOYED
    710 	add_cppflags -DMKSH_DISABLE_TTY_WARNING
    711 	# BeOS doesn't have different UIDs and GIDs
    712 	add_cppflags -DMKSH__NO_SETEUGID
    713 	;;
    714 BSD/OS)
    715 	: "${HAVE_SETLOCALE_CTYPE=0}"
    716 	;;
    717 Coherent)
    718 	oswarn="; it has major issues"
    719 	add_cppflags -DMKSH__NO_SYMLINK
    720 	check_categories="$check_categories nosymlink"
    721 	add_cppflags -DMKSH__NO_SETEUGID
    722 	add_cppflags -DMKSH_DISABLE_TTY_WARNING
    723 	;;
    724 CYGWIN*)
    725 	: "${HAVE_SETLOCALE_CTYPE=0}"
    726 	;;
    727 Darwin)
    728 	add_cppflags -D_DARWIN_C_SOURCE
    729 	;;
    730 DragonFly)
    731 	;;
    732 FreeBSD)
    733 	;;
    734 FreeMiNT)
    735 	oswarn="; it has minor issues"
    736 	add_cppflags -D_GNU_SOURCE
    737 	: "${HAVE_SETLOCALE_CTYPE=0}"
    738 	;;
    739 GNU)
    740 	case $CC in
    741 	*tendracc*) ;;
    742 	*) add_cppflags -D_GNU_SOURCE ;;
    743 	esac
    744 	add_cppflags -DSETUID_CAN_FAIL_WITH_EAGAIN
    745 	# define MKSH__NO_PATH_MAX to use Hurd-only functions
    746 	add_cppflags -DMKSH__NO_PATH_MAX
    747 	;;
    748 GNU/kFreeBSD)
    749 	case $CC in
    750 	*tendracc*) ;;
    751 	*) add_cppflags -D_GNU_SOURCE ;;
    752 	esac
    753 	add_cppflags -DSETUID_CAN_FAIL_WITH_EAGAIN
    754 	;;
    755 Haiku)
    756 	add_cppflags -DMKSH_ASSUME_UTF8; HAVE_ISSET_MKSH_ASSUME_UTF8=1
    757 	;;
    758 Harvey)
    759 	add_cppflags -D_POSIX_SOURCE
    760 	add_cppflags -D_LIMITS_EXTENSION
    761 	add_cppflags -D_BSD_EXTENSION
    762 	add_cppflags -D_SUSV2_SOURCE
    763 	add_cppflags -D_GNU_SOURCE
    764 	add_cppflags -DMKSH_ASSUME_UTF8; HAVE_ISSET_MKSH_ASSUME_UTF8=1
    765 	add_cppflags -DMKSH_NO_CMDLINE_EDITING
    766 	add_cppflags -DMKSH__NO_SETEUGID
    767 	oswarn=' and will currently not work'
    768 	add_cppflags -DMKSH_UNEMPLOYED
    769 	add_cppflags -DMKSH_NOPROSPECTOFWORK
    770 	# these taken from Harvey-OS github and need re-checking
    771 	add_cppflags -D_setjmp=setjmp -D_longjmp=longjmp
    772 	: "${HAVE_CAN_NO_EH_FRAME=0}"
    773 	: "${HAVE_CAN_FNOSTRICTALIASING=0}"
    774 	: "${HAVE_CAN_FSTACKPROTECTORSTRONG=0}"
    775 	;;
    776 HP-UX)
    777 	;;
    778 Interix)
    779 	ccpc='-X '
    780 	ccpl='-Y '
    781 	add_cppflags -D_ALL_SOURCE
    782 	: "${LIBS=-lcrypt}"
    783 	: "${HAVE_SETLOCALE_CTYPE=0}"
    784 	;;
    785 IRIX*)
    786 	: "${HAVE_SETLOCALE_CTYPE=0}"
    787 	;;
    788 Linux)
    789 	case $CC in
    790 	*tendracc*) ;;
    791 	*) add_cppflags -D_GNU_SOURCE ;;
    792 	esac
    793 	add_cppflags -DSETUID_CAN_FAIL_WITH_EAGAIN
    794 	: "${HAVE_REVOKE=0}"
    795 	;;
    796 LynxOS)
    797 	oswarn="; it has minor issues"
    798 	;;
    799 MidnightBSD)
    800 	;;
    801 Minix-vmd)
    802 	add_cppflags -DMKSH__NO_SETEUGID
    803 	add_cppflags -DMKSH_UNEMPLOYED
    804 	add_cppflags -D_MINIX_SOURCE
    805 	oldish_ed=no-stderr-ed		# no /bin/ed, maybe see below
    806 	: "${HAVE_SETLOCALE_CTYPE=0}"
    807 	;;
    808 Minix3)
    809 	add_cppflags -DMKSH_UNEMPLOYED
    810 	add_cppflags -DMKSH_NO_LIMITS
    811 	add_cppflags -D_POSIX_SOURCE -D_POSIX_1_SOURCE=2 -D_MINIX
    812 	oldish_ed=no-stderr-ed		# /usr/bin/ed(!) is broken
    813 	: "${HAVE_SETLOCALE_CTYPE=0}"
    814 	;;
    815 MirBSD)
    816 	;;
    817 MSYS_*)
    818 	add_cppflags -DMKSH_ASSUME_UTF8=0; HAVE_ISSET_MKSH_ASSUME_UTF8=1
    819 	# almost same as CYGWIN* (from RT|Chatzilla)
    820 	: "${HAVE_SETLOCALE_CTYPE=0}"
    821 	# broken on this OE (from ir0nh34d)
    822 	: "${HAVE_STDINT_H=0}"
    823 	;;
    824 NetBSD)
    825 	;;
    826 NEXTSTEP)
    827 	add_cppflags -D_NEXT_SOURCE
    828 	add_cppflags -D_POSIX_SOURCE
    829 	: "${AWK=gawk}"
    830 	: "${CC=cc -posix}"
    831 	add_cppflags -DMKSH_NO_SIGSETJMP
    832 	# NeXTstep cannot get a controlling tty
    833 	add_cppflags -DMKSH_UNEMPLOYED
    834 	case $TARGET_OSREV in
    835 	4.2*)
    836 		# OpenStep 4.2 is broken by default
    837 		oswarn="; it needs libposix.a"
    838 		;;
    839 	esac
    840 	;;
    841 Ninix3)
    842 	# similar to Minix3
    843 	add_cppflags -DMKSH_UNEMPLOYED
    844 	add_cppflags -DMKSH_NO_LIMITS
    845 	# but no idea what else could be needed
    846 	oswarn="; it has unknown issues"
    847 	;;
    848 OpenBSD)
    849 	: "${HAVE_SETLOCALE_CTYPE=0}"
    850 	;;
    851 OS/2)
    852 	HAVE_TERMIOS_H=0
    853 	HAVE_MKNOD=0	# setmode() incompatible
    854 	oswarn="; it is currently being ported, get it from"
    855 	oswarn="$oswarn${nl}https://github.com/komh/mksh-os2 in the meanwhile"
    856 	check_categories="$check_categories nosymlink"
    857 	: "${CC=gcc}"
    858 	: "${SIZE=: size}"
    859 	add_cppflags -DMKSH_UNEMPLOYED
    860 	add_cppflags -DMKSH_NOPROSPECTOFWORK
    861 	add_cppflags -DMKSH_NO_LIMITS
    862 	;;
    863 OSF1)
    864 	HAVE_SIG_T=0	# incompatible
    865 	add_cppflags -D_OSF_SOURCE
    866 	add_cppflags -D_POSIX_C_SOURCE=200112L
    867 	add_cppflags -D_XOPEN_SOURCE=600
    868 	add_cppflags -D_XOPEN_SOURCE_EXTENDED
    869 	: "${HAVE_SETLOCALE_CTYPE=0}"
    870 	;;
    871 Plan9)
    872 	add_cppflags -D_POSIX_SOURCE
    873 	add_cppflags -D_LIMITS_EXTENSION
    874 	add_cppflags -D_BSD_EXTENSION
    875 	add_cppflags -D_SUSV2_SOURCE
    876 	add_cppflags -DMKSH_ASSUME_UTF8; HAVE_ISSET_MKSH_ASSUME_UTF8=1
    877 	add_cppflags -DMKSH_NO_CMDLINE_EDITING
    878 	add_cppflags -DMKSH__NO_SETEUGID
    879 	oswarn=' and will currently not work'
    880 	add_cppflags -DMKSH_UNEMPLOYED
    881 	# this is for detecting kencc
    882 	add_cppflags -DMKSH_MAYBE_KENCC
    883 	;;
    884 PW32*)
    885 	HAVE_SIG_T=0	# incompatible
    886 	oswarn=' and will currently not work'
    887 	: "${HAVE_SETLOCALE_CTYPE=0}"
    888 	;;
    889 QNX)
    890 	add_cppflags -D__NO_EXT_QNX
    891 	add_cppflags -D__EXT_UNIX_MISC
    892 	case $TARGET_OSREV in
    893 	[012345].*|6.[0123].*|6.4.[01])
    894 		oldish_ed=no-stderr-ed		# oldish /bin/ed is broken
    895 		;;
    896 	esac
    897 	: "${HAVE_SETLOCALE_CTYPE=0}"
    898 	;;
    899 SCO_SV)
    900 	case $TARGET_OSREV in
    901 	3.2*)
    902 		# SCO OpenServer 5
    903 		add_cppflags -DMKSH_UNEMPLOYED
    904 		;;
    905 	5*)
    906 		# SCO OpenServer 6
    907 		;;
    908 	*)
    909 		oswarn='; this is an unknown version of'
    910 		oswarn="$oswarn$nl$TARGET_OS ${TARGET_OSREV}, please tell me what to do"
    911 		;;
    912 	esac
    913 	: "${HAVE_SYS_SIGLIST=0}${HAVE__SYS_SIGLIST=0}"
    914 	;;
    915 skyos)
    916 	oswarn="; it has minor issues"
    917 	;;
    918 SunOS)
    919 	add_cppflags -D_BSD_SOURCE
    920 	add_cppflags -D__EXTENSIONS__
    921 	;;
    922 syllable)
    923 	add_cppflags -D_GNU_SOURCE
    924 	add_cppflags -DMKSH_NO_SIGSUSPEND
    925 	oswarn=' and will currently not work'
    926 	;;
    927 ULTRIX)
    928 	: "${CC=cc -YPOSIX}"
    929 	add_cppflags -DMKSH_TYPEDEF_SSIZE_T=int
    930 	: "${HAVE_SETLOCALE_CTYPE=0}"
    931 	;;
    932 UnixWare|UNIX_SV)
    933 	# SCO UnixWare
    934 	: "${HAVE_SYS_SIGLIST=0}${HAVE__SYS_SIGLIST=0}"
    935 	;;
    936 UWIN*)
    937 	ccpc='-Yc,'
    938 	ccpl='-Yl,'
    939 	tsts=" 3<>/dev/tty"
    940 	oswarn="; it will compile, but the target"
    941 	oswarn="$oswarn${nl}platform itself is very flakey/unreliable"
    942 	: "${HAVE_SETLOCALE_CTYPE=0}"
    943 	;;
    944 _svr4)
    945 	# generic target for SVR4 Unix with uname -s = uname -n
    946 	# this duplicates the * target below
    947 	oswarn='; it may or may not work'
    948 	test x"$TARGET_OSREV" = x"" && TARGET_OSREV=`uname -r`
    949 	;;
    950 *)
    951 	oswarn='; it may or may not work'
    952 	test x"$TARGET_OSREV" = x"" && TARGET_OSREV=`uname -r`
    953 	;;
    954 esac
    955 
    956 : "${HAVE_MKNOD=0}"
    957 
    958 : "${AWK=awk}${CC=cc}${NROFF=nroff}${SIZE=size}"
    959 test 0 = $r && echo | $NROFF -v 2>&1 | grep GNU >/dev/null 2>&1 && \
    960     echo | $NROFF -c >/dev/null 2>&1 && NROFF="$NROFF -c"
    961 
    962 # this aids me in tracing FTBFSen without access to the buildd
    963 $e "Hi from$ao $bi$srcversion$ao on:"
    964 case $TARGET_OS in
    965 AIX)
    966 	vv '|' "oslevel >&2"
    967 	vv '|' "uname -a >&2"
    968 	;;
    969 Darwin)
    970 	vv '|' "hwprefs machine_type os_type os_class >&2"
    971 	vv '|' "sw_vers >&2"
    972 	vv '|' "system_profiler SPSoftwareDataType SPHardwareDataType >&2"
    973 	vv '|' "/bin/sh --version >&2"
    974 	vv '|' "xcodebuild -version >&2"
    975 	vv '|' "uname -a >&2"
    976 	vv '|' "sysctl kern.version hw.machine hw.model hw.memsize hw.availcpu hw.cpufrequency hw.byteorder hw.cpu64bit_capable >&2"
    977 	;;
    978 IRIX*)
    979 	vv '|' "uname -a >&2"
    980 	vv '|' "hinv -v >&2"
    981 	;;
    982 OSF1)
    983 	vv '|' "uname -a >&2"
    984 	vv '|' "/usr/sbin/sizer -v >&2"
    985 	;;
    986 SCO_SV|UnixWare|UNIX_SV)
    987 	vv '|' "uname -a >&2"
    988 	vv '|' "uname -X >&2"
    989 	;;
    990 *)
    991 	vv '|' "uname -a >&2"
    992 	;;
    993 esac
    994 test -z "$oswarn" || echo >&2 "
    995 Warning: mksh has not yet been ported to or tested on your
    996 operating system '$TARGET_OS'$oswarn. If you can provide
    997 a shell account to the developer, this may improve; please
    998 drop us a success or failure notice or even send in diffs.
    999 "
   1000 $e "$bi$me: Building the MirBSD Korn Shell$ao $ui$dstversion$ao on $TARGET_OS ${TARGET_OSREV}..."
   1001 
   1002 #
   1003 # Start of mirtoconf checks
   1004 #
   1005 $e $bi$me: Scanning for functions... please ignore any errors.$ao
   1006 
   1007 #
   1008 # Compiler: which one?
   1009 #
   1010 # notes:
   1011 # - ICC defines __GNUC__ too
   1012 # - GCC defines __hpux too
   1013 # - LLVM+clang defines __GNUC__ too
   1014 # - nwcc defines __GNUC__ too
   1015 CPP="$CC -E"
   1016 $e ... which compiler seems to be used
   1017 cat >conftest.c <<'EOF'
   1018 const char *
   1019 #if defined(__ICC) || defined(__INTEL_COMPILER)
   1020 ct="icc"
   1021 #elif defined(__xlC__) || defined(__IBMC__)
   1022 ct="xlc"
   1023 #elif defined(__SUNPRO_C)
   1024 ct="sunpro"
   1025 #elif defined(__ACK__)
   1026 ct="ack"
   1027 #elif defined(__BORLANDC__)
   1028 ct="bcc"
   1029 #elif defined(__WATCOMC__)
   1030 ct="watcom"
   1031 #elif defined(__MWERKS__)
   1032 ct="metrowerks"
   1033 #elif defined(__HP_cc)
   1034 ct="hpcc"
   1035 #elif defined(__DECC) || (defined(__osf__) && !defined(__GNUC__))
   1036 ct="dec"
   1037 #elif defined(__PGI)
   1038 ct="pgi"
   1039 #elif defined(__DMC__)
   1040 ct="dmc"
   1041 #elif defined(_MSC_VER)
   1042 ct="msc"
   1043 #elif defined(__ADSPBLACKFIN__) || defined(__ADSPTS__) || defined(__ADSP21000__)
   1044 ct="adsp"
   1045 #elif defined(__IAR_SYSTEMS_ICC__)
   1046 ct="iar"
   1047 #elif defined(SDCC)
   1048 ct="sdcc"
   1049 #elif defined(__PCC__)
   1050 ct="pcc"
   1051 #elif defined(__TenDRA__)
   1052 ct="tendra"
   1053 #elif defined(__TINYC__)
   1054 ct="tcc"
   1055 #elif defined(__llvm__) && defined(__clang__)
   1056 ct="clang"
   1057 #elif defined(__NWCC__)
   1058 ct="nwcc"
   1059 #elif defined(__GNUC__)
   1060 ct="gcc"
   1061 #elif defined(_COMPILER_VERSION)
   1062 ct="mipspro"
   1063 #elif defined(__sgi)
   1064 ct="mipspro"
   1065 #elif defined(__hpux) || defined(__hpua)
   1066 ct="hpcc"
   1067 #elif defined(__ultrix)
   1068 ct="ucode"
   1069 #elif defined(__USLC__)
   1070 ct="uslc"
   1071 #elif defined(__LCC__)
   1072 ct="lcc"
   1073 #elif defined(MKSH_MAYBE_KENCC)
   1074 /* and none of the above matches */
   1075 ct="kencc"
   1076 #else
   1077 ct="unknown"
   1078 #endif
   1079 ;
   1080 const char *
   1081 #if defined(__KLIBC__) && !defined(__OS2__)
   1082 et="klibc"
   1083 #else
   1084 et="unknown"
   1085 #endif
   1086 ;
   1087 EOF
   1088 ct=untested
   1089 et=untested
   1090 vv ']' "$CPP $CFLAGS $CPPFLAGS $NOWARN conftest.c | \
   1091     sed -n '/^ *[ce]t *= */s/^ *\([ce]t\) *= */\1=/p' | tr -d \\\\015 >x"
   1092 sed 's/^/[ /' x
   1093 eval `cat x`
   1094 rmf x vv.out
   1095 cat >conftest.c <<'EOF'
   1096 #include <unistd.h>
   1097 int main(void) { return (isatty(0)); }
   1098 EOF
   1099 case $ct in
   1100 ack)
   1101 	# work around "the famous ACK const bug"
   1102 	CPPFLAGS="-Dconst= $CPPFLAGS"
   1103 	;;
   1104 adsp)
   1105 	echo >&2 'Warning: Analog Devices C++ compiler for Blackfin, TigerSHARC
   1106     and SHARC (21000) DSPs detected. This compiler has not yet
   1107     been tested for compatibility with mksh. Continue at your
   1108     own risk, please report success/failure to the developers.'
   1109 	;;
   1110 bcc)
   1111 	echo >&2 "Warning: Borland C++ Builder detected. This compiler might
   1112     produce broken executables. Continue at your own risk,
   1113     please report success/failure to the developers."
   1114 	;;
   1115 clang)
   1116 	# does not work with current "ccc" compiler driver
   1117 	vv '|' "$CC $CFLAGS $CPPFLAGS $LDFLAGS $NOWARN $LIBS -version"
   1118 	# one of these two works, for now
   1119 	vv '|' "${CLANG-clang} -version"
   1120 	vv '|' "${CLANG-clang} --version"
   1121 	# ensure compiler and linker are in sync unless overridden
   1122 	case $CCC_CC:$CCC_LD in
   1123 	:*)	;;
   1124 	*:)	CCC_LD=$CCC_CC; export CCC_LD ;;
   1125 	esac
   1126 	: "${HAVE_STRING_POOLING=i1}"
   1127 	;;
   1128 dec)
   1129 	vv '|' "$CC $CFLAGS $CPPFLAGS $LDFLAGS $NOWARN $LIBS -V"
   1130 	vv '|' "$CC $CFLAGS $CPPFLAGS $LDFLAGS $NOWARN -Wl,-V conftest.c $LIBS"
   1131 	;;
   1132 dmc)
   1133 	echo >&2 "Warning: Digital Mars Compiler detected. When running under"
   1134 	echo >&2 "    UWIN, mksh tends to be unstable due to the limitations"
   1135 	echo >&2 "    of this platform. Continue at your own risk,"
   1136 	echo >&2 "    please report success/failure to the developers."
   1137 	;;
   1138 gcc)
   1139 	vv '|' "$CC $CFLAGS $CPPFLAGS $LDFLAGS $NOWARN -v conftest.c $LIBS"
   1140 	vv '|' 'echo `$CC $CFLAGS $CPPFLAGS $LDFLAGS $NOWARN $LIBS \
   1141 	    -dumpmachine` gcc`$CC $CFLAGS $CPPFLAGS $LDFLAGS $NOWARN \
   1142 	    $LIBS -dumpversion`'
   1143 	: "${HAVE_STRING_POOLING=i2}"
   1144 	;;
   1145 hpcc)
   1146 	vv '|' "$CC $CFLAGS $CPPFLAGS $LDFLAGS $NOWARN -V conftest.c $LIBS"
   1147 	;;
   1148 iar)
   1149 	echo >&2 'Warning: IAR Systems (http://www.iar.com) compiler for embedded
   1150     systems detected. This unsupported compiler has not yet
   1151     been tested for compatibility with mksh. Continue at your
   1152     own risk, please report success/failure to the developers.'
   1153 	;;
   1154 icc)
   1155 	vv '|' "$CC $CFLAGS $CPPFLAGS $LDFLAGS $NOWARN $LIBS -V"
   1156 	;;
   1157 kencc)
   1158 	vv '|' "$CC $CFLAGS $CPPFLAGS $LDFLAGS $NOWARN -v conftest.c $LIBS"
   1159 	;;
   1160 lcc)
   1161 	vv '|' "$CC $CFLAGS $CPPFLAGS $LDFLAGS $NOWARN -v conftest.c $LIBS"
   1162 	add_cppflags -D__inline__=__inline
   1163 	;;
   1164 metrowerks)
   1165 	echo >&2 'Warning: Metrowerks C compiler detected. This has not yet
   1166     been tested for compatibility with mksh. Continue at your
   1167     own risk, please report success/failure to the developers.'
   1168 	;;
   1169 mipspro)
   1170 	vv '|' "$CC $CFLAGS $CPPFLAGS $LDFLAGS $NOWARN $LIBS -version"
   1171 	;;
   1172 msc)
   1173 	ccpr=		# errorlevels are not reliable
   1174 	case $TARGET_OS in
   1175 	Interix)
   1176 		if [[ -n $C89_COMPILER ]]; then
   1177 			C89_COMPILER=`ntpath2posix -c "$C89_COMPILER"`
   1178 		else
   1179 			C89_COMPILER=CL.EXE
   1180 		fi
   1181 		if [[ -n $C89_LINKER ]]; then
   1182 			C89_LINKER=`ntpath2posix -c "$C89_LINKER"`
   1183 		else
   1184 			C89_LINKER=LINK.EXE
   1185 		fi
   1186 		vv '|' "$C89_COMPILER /HELP >&2"
   1187 		vv '|' "$C89_LINKER /LINK >&2"
   1188 		;;
   1189 	esac
   1190 	;;
   1191 nwcc)
   1192 	vv '|' "$CC $CFLAGS $CPPFLAGS $LDFLAGS $NOWARN $LIBS -version"
   1193 	;;
   1194 pcc)
   1195 	vv '|' "$CC $CFLAGS $CPPFLAGS $LDFLAGS $NOWARN $LIBS -v"
   1196 	;;
   1197 pgi)
   1198 	echo >&2 'Warning: PGI detected. This unknown compiler has not yet
   1199     been tested for compatibility with mksh. Continue at your
   1200     own risk, please report success/failure to the developers.'
   1201 	;;
   1202 sdcc)
   1203 	echo >&2 'Warning: sdcc (http://sdcc.sourceforge.net), the small devices
   1204     C compiler for embedded systems detected. This has not yet
   1205     been tested for compatibility with mksh. Continue at your
   1206     own risk, please report success/failure to the developers.'
   1207 	;;
   1208 sunpro)
   1209 	vv '|' "$CC $CFLAGS $CPPFLAGS $LDFLAGS $NOWARN -V conftest.c $LIBS"
   1210 	;;
   1211 tcc)
   1212 	vv '|' "$CC $CFLAGS $CPPFLAGS $LDFLAGS $NOWARN $LIBS -v"
   1213 	;;
   1214 tendra)
   1215 	vv '|' "$CC $CFLAGS $CPPFLAGS $LDFLAGS $NOWARN $LIBS -V 2>&1 | \
   1216 	    grep -F -i -e version -e release"
   1217 	;;
   1218 ucode)
   1219 	vv '|' "$CC $CFLAGS $CPPFLAGS $LDFLAGS $NOWARN $LIBS -V"
   1220 	vv '|' "$CC $CFLAGS $CPPFLAGS $LDFLAGS $NOWARN -Wl,-V conftest.c $LIBS"
   1221 	;;
   1222 uslc)
   1223 	case $TARGET_OS:$TARGET_OSREV in
   1224 	SCO_SV:3.2*)
   1225 		# SCO OpenServer 5
   1226 		CFLAGS="$CFLAGS -g"
   1227 		: "${HAVE_CAN_OTWO=0}${HAVE_CAN_OPTIMISE=0}"
   1228 		;;
   1229 	esac
   1230 	vv '|' "$CC $CFLAGS $CPPFLAGS $LDFLAGS $NOWARN -V conftest.c $LIBS"
   1231 	;;
   1232 watcom)
   1233 	vv '|' "$CC $CFLAGS $CPPFLAGS $LDFLAGS $NOWARN -v conftest.c $LIBS"
   1234 	;;
   1235 xlc)
   1236 	vv '|' "$CC $CFLAGS $CPPFLAGS $LDFLAGS $NOWARN $LIBS -qversion"
   1237 	vv '|' "$CC $CFLAGS $CPPFLAGS $LDFLAGS $NOWARN $LIBS -qversion=verbose"
   1238 	vv '|' "ld -V"
   1239 	;;
   1240 *)
   1241 	test x"$ct" = x"untested" && $e "!!! detecting preprocessor failed"
   1242 	ct=unknown
   1243 	vv "$CC --version"
   1244 	vv '|' "$CC $CFLAGS $CPPFLAGS $LDFLAGS $NOWARN -v conftest.c $LIBS"
   1245 	vv '|' "$CC $CFLAGS $CPPFLAGS $LDFLAGS $NOWARN -V conftest.c $LIBS"
   1246 	;;
   1247 esac
   1248 case $cm in
   1249 dragonegg|llvm)
   1250 	vv '|' "llc -version"
   1251 	;;
   1252 esac
   1253 etd=" on $et"
   1254 case $et in
   1255 klibc)
   1256 	add_cppflags -DMKSH_NO_LIMITS
   1257 	;;
   1258 unknown)
   1259 	# nothing special detected, dont worry
   1260 	etd=
   1261 	;;
   1262 *)
   1263 	# huh?
   1264 	;;
   1265 esac
   1266 $e "$bi==> which compiler seems to be used...$ao $ui$ct$etd$ao"
   1267 rmf conftest.c conftest.o conftest a.out* a.exe* conftest.exe* vv.out
   1268 
   1269 #
   1270 # Compiler: works as-is, with -Wno-error and -Werror
   1271 #
   1272 save_NOWARN=$NOWARN
   1273 NOWARN=
   1274 DOWARN=
   1275 ac_flags 0 compiler_works '' 'if the compiler works'
   1276 test 1 = $HAVE_CAN_COMPILER_WORKS || exit 1
   1277 HAVE_COMPILER_KNOWN=0
   1278 test $ct = unknown || HAVE_COMPILER_KNOWN=1
   1279 if ac_ifcpp 'if 0' compiler_fails '' \
   1280     'if the compiler does not fail correctly'; then
   1281 	save_CFLAGS=$CFLAGS
   1282 	: "${HAVE_CAN_DELEXE=x}"
   1283 	case $ct in
   1284 	dec)
   1285 		CFLAGS="$CFLAGS ${ccpl}-non_shared"
   1286 		ac_testn can_delexe compiler_fails 0 'for the -non_shared linker option' <<-EOF
   1287 			#include <unistd.h>
   1288 			int main(void) { return (isatty(0)); }
   1289 		EOF
   1290 		;;
   1291 	dmc)
   1292 		CFLAGS="$CFLAGS ${ccpl}/DELEXECUTABLE"
   1293 		ac_testn can_delexe compiler_fails 0 'for the /DELEXECUTABLE linker option' <<-EOF
   1294 			#include <unistd.h>
   1295 			int main(void) { return (isatty(0)); }
   1296 		EOF
   1297 		;;
   1298 	*)
   1299 		exit 1
   1300 		;;
   1301 	esac
   1302 	test 1 = $HAVE_CAN_DELEXE || CFLAGS=$save_CFLAGS
   1303 	ac_testn compiler_still_fails '' 'if the compiler still does not fail correctly' <<-EOF
   1304 	EOF
   1305 	test 1 = $HAVE_COMPILER_STILL_FAILS && exit 1
   1306 fi
   1307 if ac_ifcpp 'ifdef __TINYC__' couldbe_tcc '!' compiler_known 0 \
   1308     'if this could be tcc'; then
   1309 	ct=tcc
   1310 	CPP='cpp -D__TINYC__'
   1311 	HAVE_COMPILER_KNOWN=1
   1312 fi
   1313 
   1314 case $ct in
   1315 bcc)
   1316 	save_NOWARN="${ccpc}-w"
   1317 	DOWARN="${ccpc}-w!"
   1318 	;;
   1319 dec)
   1320 	# -msg_* flags not used yet, or is -w2 correct?
   1321 	;;
   1322 dmc)
   1323 	save_NOWARN="${ccpc}-w"
   1324 	DOWARN="${ccpc}-wx"
   1325 	;;
   1326 hpcc)
   1327 	save_NOWARN=
   1328 	DOWARN=+We
   1329 	;;
   1330 kencc)
   1331 	save_NOWARN=
   1332 	DOWARN=
   1333 	;;
   1334 mipspro)
   1335 	save_NOWARN=
   1336 	DOWARN="-diag_error 1-10000"
   1337 	;;
   1338 msc)
   1339 	save_NOWARN="${ccpc}/w"
   1340 	DOWARN="${ccpc}/WX"
   1341 	;;
   1342 sunpro)
   1343 	test x"$save_NOWARN" = x"" && save_NOWARN='-errwarn=%none'
   1344 	ac_flags 0 errwarnnone "$save_NOWARN"
   1345 	test 1 = $HAVE_CAN_ERRWARNNONE || save_NOWARN=
   1346 	ac_flags 0 errwarnall "-errwarn=%all"
   1347 	test 1 = $HAVE_CAN_ERRWARNALL && DOWARN="-errwarn=%all"
   1348 	;;
   1349 tendra)
   1350 	save_NOWARN=-w
   1351 	;;
   1352 ucode)
   1353 	save_NOWARN=
   1354 	DOWARN=-w2
   1355 	;;
   1356 watcom)
   1357 	save_NOWARN=
   1358 	DOWARN=-Wc,-we
   1359 	;;
   1360 xlc)
   1361 	save_NOWARN=-qflag=i:e
   1362 	DOWARN=-qflag=i:i
   1363 	;;
   1364 *)
   1365 	test x"$save_NOWARN" = x"" && save_NOWARN=-Wno-error
   1366 	ac_flags 0 wnoerror "$save_NOWARN"
   1367 	test 1 = $HAVE_CAN_WNOERROR || save_NOWARN=
   1368 	ac_flags 0 werror -Werror
   1369 	test 1 = $HAVE_CAN_WERROR && DOWARN=-Werror
   1370 	test $ct = icc && DOWARN="$DOWARN -wd1419"
   1371 	;;
   1372 esac
   1373 NOWARN=$save_NOWARN
   1374 
   1375 #
   1376 # Compiler: extra flags (-O2 -f* -W* etc.)
   1377 #
   1378 i=`echo :"$orig_CFLAGS" | sed 's/^://' | tr -c -d $alll$allu$alln`
   1379 # optimisation: only if orig_CFLAGS is empty
   1380 test x"$i" = x"" && case $ct in
   1381 hpcc)
   1382 	phase=u
   1383 	ac_flags 1 otwo +O2
   1384 	phase=x
   1385 	;;
   1386 kencc|tcc|tendra)
   1387 	# no special optimisation
   1388 	;;
   1389 sunpro)
   1390 	cat >x <<-'EOF'
   1391 		#include <unistd.h>
   1392 		int main(void) { return (isatty(0)); }
   1393 		#define __IDSTRING_CONCAT(l,p)	__LINTED__ ## l ## _ ## p
   1394 		#define __IDSTRING_EXPAND(l,p)	__IDSTRING_CONCAT(l,p)
   1395 		#define pad			void __IDSTRING_EXPAND(__LINE__,x)(void) { }
   1396 	EOF
   1397 	yes pad | head -n 256 >>x
   1398 	ac_flags - 1 otwo -xO2 <x
   1399 	rmf x
   1400 	;;
   1401 xlc)
   1402 	ac_flags 1 othree "-O3 -qstrict"
   1403 	test 1 = $HAVE_CAN_OTHREE || ac_flags 1 otwo -O2
   1404 	;;
   1405 *)
   1406 	ac_flags 1 otwo -O2
   1407 	test 1 = $HAVE_CAN_OTWO || ac_flags 1 optimise -O
   1408 	;;
   1409 esac
   1410 # other flags: just add them if they are supported
   1411 i=0
   1412 case $ct in
   1413 bcc)
   1414 	ac_flags 1 strpool "${ccpc}-d" 'if string pooling can be enabled'
   1415 	;;
   1416 clang)
   1417 	i=1
   1418 	;;
   1419 dec)
   1420 	ac_flags 0 verb -verbose
   1421 	ac_flags 1 rodata -readonly_strings
   1422 	;;
   1423 dmc)
   1424 	ac_flags 1 decl "${ccpc}-r" 'for strict prototype checks'
   1425 	ac_flags 1 schk "${ccpc}-s" 'for stack overflow checking'
   1426 	;;
   1427 gcc)
   1428 	# The following tests run with -Werror (gcc only) if possible
   1429 	NOWARN=$DOWARN; phase=u
   1430 	ac_flags 1 wnodeprecateddecls -Wno-deprecated-declarations
   1431 	# mksh is not written in CFrustFrust!
   1432 	ac_flags 1 no_eh_frame -fno-asynchronous-unwind-tables
   1433 	ac_flags 1 fnostrictaliasing -fno-strict-aliasing
   1434 	ac_flags 1 fstackprotectorstrong -fstack-protector-strong
   1435 	test 1 = $HAVE_CAN_FSTACKPROTECTORSTRONG || \
   1436 	    ac_flags 1 fstackprotectorall -fstack-protector-all
   1437 	test $cm = dragonegg && case " $CC $CFLAGS $LDFLAGS " in
   1438 	*\ -fplugin=*dragonegg*) ;;
   1439 	*) ac_flags 1 fplugin_dragonegg -fplugin=dragonegg ;;
   1440 	esac
   1441 	case $cm in
   1442 	combine)
   1443 		fv=0
   1444 		checks='7 8'
   1445 		;;
   1446 	lto)
   1447 		fv=0
   1448 		checks='1 2 3 4 5 6 7 8'
   1449 		;;
   1450 	*)
   1451 		fv=1
   1452 		;;
   1453 	esac
   1454 	test $fv = 1 || for what in $checks; do
   1455 		test $fv = 1 && break
   1456 		case $what in
   1457 		1)	t_cflags='-flto=jobserver'
   1458 			t_ldflags='-fuse-linker-plugin'
   1459 			t_use=1 t_name=fltojs_lp ;;
   1460 		2)	t_cflags='-flto=jobserver' t_ldflags=''
   1461 			t_use=1 t_name=fltojs_nn ;;
   1462 		3)	t_cflags='-flto=jobserver'
   1463 			t_ldflags='-fno-use-linker-plugin -fwhole-program'
   1464 			t_use=1 t_name=fltojs_np ;;
   1465 		4)	t_cflags='-flto'
   1466 			t_ldflags='-fuse-linker-plugin'
   1467 			t_use=1 t_name=fltons_lp ;;
   1468 		5)	t_cflags='-flto' t_ldflags=''
   1469 			t_use=1 t_name=fltons_nn ;;
   1470 		6)	t_cflags='-flto'
   1471 			t_ldflags='-fno-use-linker-plugin -fwhole-program'
   1472 			t_use=1 t_name=fltons_np ;;
   1473 		7)	t_cflags='-fwhole-program --combine' t_ldflags=''
   1474 			t_use=0 t_name=combine cm=combine ;;
   1475 		8)	fv=1 cm=normal ;;
   1476 		esac
   1477 		test $fv = 1 && break
   1478 		ac_flags $t_use $t_name "$t_cflags" \
   1479 		    "if gcc supports $t_cflags $t_ldflags" "$t_ldflags"
   1480 	done
   1481 	ac_flags 1 data_abi_align -malign-data=abi
   1482 	i=1
   1483 	;;
   1484 hpcc)
   1485 	phase=u
   1486 	# probably not needed
   1487 	#ac_flags 1 agcc -Agcc 'for support of GCC extensions'
   1488 	phase=x
   1489 	;;
   1490 icc)
   1491 	ac_flags 1 fnobuiltinsetmode -fno-builtin-setmode
   1492 	ac_flags 1 fnostrictaliasing -fno-strict-aliasing
   1493 	ac_flags 1 fstacksecuritycheck -fstack-security-check
   1494 	i=1
   1495 	;;
   1496 mipspro)
   1497 	ac_flags 1 fullwarn -fullwarn 'for remark output support'
   1498 	;;
   1499 msc)
   1500 	ac_flags 1 strpool "${ccpc}/GF" 'if string pooling can be enabled'
   1501 	echo 'int main(void) { char test[64] = ""; return (*test); }' >x
   1502 	ac_flags - 1 stackon "${ccpc}/GZ" 'if stack checks can be enabled' <x
   1503 	ac_flags - 1 stckall "${ccpc}/Ge" 'stack checks for all functions' <x
   1504 	ac_flags - 1 secuchk "${ccpc}/GS" 'for compiler security checks' <x
   1505 	rmf x
   1506 	ac_flags 1 wall "${ccpc}/Wall" 'to enable all warnings'
   1507 	ac_flags 1 wp64 "${ccpc}/Wp64" 'to enable 64-bit warnings'
   1508 	;;
   1509 nwcc)
   1510 	#broken# ac_flags 1 ssp -stackprotect
   1511 	i=1
   1512 	;;
   1513 pcc)
   1514 	ac_flags 1 fstackprotectorall -fstack-protector-all
   1515 	i=1
   1516 	;;
   1517 sunpro)
   1518 	phase=u
   1519 	ac_flags 1 v -v
   1520 	ac_flags 1 ipo -xipo 'for cross-module optimisation'
   1521 	phase=x
   1522 	;;
   1523 tcc)
   1524 	: #broken# ac_flags 1 boundschk -b
   1525 	;;
   1526 tendra)
   1527 	ac_flags 0 ysystem -Ysystem
   1528 	test 1 = $HAVE_CAN_YSYSTEM && CPPFLAGS="-Ysystem $CPPFLAGS"
   1529 	ac_flags 1 extansi -Xa
   1530 	;;
   1531 xlc)
   1532 	ac_flags 1 rodata "-qro -qroconst -qroptr"
   1533 	ac_flags 1 rtcheck -qcheck=all
   1534 	#ac_flags 1 rtchkc -qextchk	# reported broken
   1535 	ac_flags 1 wformat "-qformat=all -qformat=nozln"
   1536 	#ac_flags 1 wp64 -qwarn64	# too verbose for now
   1537 	;;
   1538 esac
   1539 # flags common to a subset of compilers (run with -Werror on gcc)
   1540 if test 1 = $i; then
   1541 	ac_flags 1 wall -Wall
   1542 	ac_flags 1 fwrapv -fwrapv
   1543 fi
   1544 
   1545 # on demand means: GCC version >= 4
   1546 fd='if to rely on compiler for string pooling'
   1547 ac_cache string_pooling || case $HAVE_STRING_POOLING in
   1548 2) fx=' (on demand, cached)' ;;
   1549 i1) fv=1 ;;
   1550 i2) fv=2; fx=' (on demand)' ;;
   1551 esac
   1552 ac_testdone
   1553 test x"$HAVE_STRING_POOLING" = x"0" || ac_cppflags
   1554 
   1555 phase=x
   1556 # The following tests run with -Werror or similar (all compilers) if possible
   1557 NOWARN=$DOWARN
   1558 test $ct = pcc && phase=u
   1559 
   1560 #
   1561 # Compiler: check for stuff that only generates warnings
   1562 #
   1563 ac_test attribute_bounded '' 'for __attribute__((__bounded__))' <<-'EOF'
   1564 	#if defined(__TenDRA__) || (defined(__GNUC__) && (__GNUC__ < 2))
   1565 	extern int thiswillneverbedefinedIhope(void);
   1566 	/* force a failure: TenDRA and gcc 1.42 have false positive here */
   1567 	int main(void) { return (thiswillneverbedefinedIhope()); }
   1568 	#else
   1569 	#include <string.h>
   1570 	#undef __attribute__
   1571 	int xcopy(const void *, void *, size_t)
   1572 	    __attribute__((__bounded__(__buffer__, 1, 3)))
   1573 	    __attribute__((__bounded__(__buffer__, 2, 3)));
   1574 	int main(int ac, char *av[]) { return (xcopy(av[0], av[--ac], 1)); }
   1575 	int xcopy(const void *s, void *d, size_t n) {
   1576 		/*
   1577 		 * if memmove does not exist, we are not on a system
   1578 		 * with GCC with __bounded__ attribute either so poo
   1579 		 */
   1580 		memmove(d, s, n); return ((int)n);
   1581 	}
   1582 	#endif
   1583 EOF
   1584 ac_test attribute_format '' 'for __attribute__((__format__))' <<-'EOF'
   1585 	#if defined(__TenDRA__) || (defined(__GNUC__) && (__GNUC__ < 2))
   1586 	extern int thiswillneverbedefinedIhope(void);
   1587 	/* force a failure: TenDRA and gcc 1.42 have false positive here */
   1588 	int main(void) { return (thiswillneverbedefinedIhope()); }
   1589 	#else
   1590 	#define fprintf printfoo
   1591 	#include <stdio.h>
   1592 	#undef __attribute__
   1593 	#undef fprintf
   1594 	extern int fprintf(FILE *, const char *format, ...)
   1595 	    __attribute__((__format__(__printf__, 2, 3)));
   1596 	int main(int ac, char **av) { return (fprintf(stderr, "%s%d", *av, ac)); }
   1597 	#endif
   1598 EOF
   1599 ac_test attribute_noreturn '' 'for __attribute__((__noreturn__))' <<-'EOF'
   1600 	#if defined(__TenDRA__) || (defined(__GNUC__) && (__GNUC__ < 2))
   1601 	extern int thiswillneverbedefinedIhope(void);
   1602 	/* force a failure: TenDRA and gcc 1.42 have false positive here */
   1603 	int main(void) { return (thiswillneverbedefinedIhope()); }
   1604 	#else
   1605 	#include <stdlib.h>
   1606 	#undef __attribute__
   1607 	void fnord(void) __attribute__((__noreturn__));
   1608 	int main(void) { fnord(); }
   1609 	void fnord(void) { exit(0); }
   1610 	#endif
   1611 EOF
   1612 ac_test attribute_pure '' 'for __attribute__((__pure__))' <<-'EOF'
   1613 	#if defined(__TenDRA__) || (defined(__GNUC__) && (__GNUC__ < 2))
   1614 	extern int thiswillneverbedefinedIhope(void);
   1615 	/* force a failure: TenDRA and gcc 1.42 have false positive here */
   1616 	int main(void) { return (thiswillneverbedefinedIhope()); }
   1617 	#else
   1618 	#include <unistd.h>
   1619 	#undef __attribute__
   1620 	int foo(const char *) __attribute__((__pure__));
   1621 	int main(int ac, char **av) { return (foo(av[ac - 1]) + isatty(0)); }
   1622 	int foo(const char *s) { return ((int)s[0]); }
   1623 	#endif
   1624 EOF
   1625 ac_test attribute_unused '' 'for __attribute__((__unused__))' <<-'EOF'
   1626 	#if defined(__TenDRA__) || (defined(__GNUC__) && (__GNUC__ < 2))
   1627 	extern int thiswillneverbedefinedIhope(void);
   1628 	/* force a failure: TenDRA and gcc 1.42 have false positive here */
   1629 	int main(void) { return (thiswillneverbedefinedIhope()); }
   1630 	#else
   1631 	#include <unistd.h>
   1632 	#undef __attribute__
   1633 	int main(int ac __attribute__((__unused__)), char **av
   1634 	    __attribute__((__unused__))) { return (isatty(0)); }
   1635 	#endif
   1636 EOF
   1637 ac_test attribute_used '' 'for __attribute__((__used__))' <<-'EOF'
   1638 	#if defined(__TenDRA__) || (defined(__GNUC__) && (__GNUC__ < 2))
   1639 	extern int thiswillneverbedefinedIhope(void);
   1640 	/* force a failure: TenDRA and gcc 1.42 have false positive here */
   1641 	int main(void) { return (thiswillneverbedefinedIhope()); }
   1642 	#else
   1643 	#include <unistd.h>
   1644 	#undef __attribute__
   1645 	static const char fnord[] __attribute__((__used__)) = "42";
   1646 	int main(void) { return (isatty(0)); }
   1647 	#endif
   1648 EOF
   1649 
   1650 # End of tests run with -Werror
   1651 NOWARN=$save_NOWARN
   1652 phase=x
   1653 
   1654 #
   1655 # mksh: flavours (full/small mksh, omit certain stuff)
   1656 #
   1657 if ac_ifcpp 'ifdef MKSH_SMALL' isset_MKSH_SMALL '' \
   1658     "if a reduced-feature mksh is requested"; then
   1659 	: "${HAVE_NICE=0}"
   1660 	: "${HAVE_PERSISTENT_HISTORY=0}"
   1661 	check_categories="$check_categories smksh"
   1662 fi
   1663 ac_ifcpp 'if defined(MKSH_BINSHPOSIX) || defined(MKSH_BINSHREDUCED)' \
   1664     isset_MKSH_BINSH '' 'if invoking as sh should be handled specially' && \
   1665     check_categories="$check_categories binsh"
   1666 ac_ifcpp 'ifdef MKSH_UNEMPLOYED' isset_MKSH_UNEMPLOYED '' \
   1667     "if mksh will be built without job control" && \
   1668     check_categories="$check_categories arge"
   1669 ac_ifcpp 'ifdef MKSH_NOPROSPECTOFWORK' isset_MKSH_NOPROSPECTOFWORK '' \
   1670     "if mksh will be built without job signals" && \
   1671     check_categories="$check_categories arge nojsig"
   1672 ac_ifcpp 'ifdef MKSH_ASSUME_UTF8' isset_MKSH_ASSUME_UTF8 '' \
   1673     'if the default UTF-8 mode is specified' && : "${HAVE_SETLOCALE_CTYPE=0}"
   1674 #ac_ifcpp 'ifdef MKSH_DISABLE_DEPRECATED' isset_MKSH_DISABLE_DEPRECATED '' \
   1675 #    "if deprecated features are to be omitted" && \
   1676 #    check_categories="$check_categories nodeprecated"
   1677 #ac_ifcpp 'ifdef MKSH_DISABLE_EXPERIMENTAL' isset_MKSH_DISABLE_EXPERIMENTAL '' \
   1678 #    "if experimental features are to be omitted" && \
   1679 #    check_categories="$check_categories noexperimental"
   1680 ac_ifcpp 'ifdef MKSH_MIDNIGHTBSD01ASH_COMPAT' isset_MKSH_MIDNIGHTBSD01ASH_COMPAT '' \
   1681     'if the MidnightBSD 0.1 ash compatibility mode is requested' && \
   1682     check_categories="$check_categories mnbsdash"
   1683 
   1684 #
   1685 # Environment: headers
   1686 #
   1687 ac_header sys/time.h sys/types.h
   1688 ac_header time.h sys/types.h
   1689 test "11" = "$HAVE_SYS_TIME_H$HAVE_TIME_H" || HAVE_BOTH_TIME_H=0
   1690 ac_test both_time_h '' 'whether <sys/time.h> and <time.h> can both be included' <<-'EOF'
   1691 	#include <sys/types.h>
   1692 	#include <sys/time.h>
   1693 	#include <time.h>
   1694 	#include <unistd.h>
   1695 	int main(void) { struct tm tm; return ((int)sizeof(tm) + isatty(0)); }
   1696 EOF
   1697 ac_header sys/bsdtypes.h
   1698 ac_header sys/file.h sys/types.h
   1699 ac_header sys/mkdev.h sys/types.h
   1700 ac_header sys/mman.h sys/types.h
   1701 ac_header sys/param.h
   1702 ac_header sys/resource.h sys/types.h _time
   1703 ac_header sys/select.h sys/types.h
   1704 ac_header sys/sysmacros.h
   1705 ac_header bstring.h
   1706 ac_header grp.h sys/types.h
   1707 ac_header io.h
   1708 ac_header libgen.h
   1709 ac_header libutil.h sys/types.h
   1710 ac_header paths.h
   1711 ac_header stdint.h stdarg.h
   1712 # include strings.h only if compatible with string.h
   1713 ac_header strings.h sys/types.h string.h
   1714 ac_header termios.h
   1715 ac_header ulimit.h sys/types.h
   1716 ac_header values.h
   1717 
   1718 #
   1719 # Environment: definitions
   1720 #
   1721 echo '#include <sys/types.h>
   1722 #include <unistd.h>
   1723 /* check that off_t can represent 2^63-1 correctly, thx FSF */
   1724 #define LARGE_OFF_T ((((off_t)1 << 31) << 31) - 1 + (((off_t)1 << 31) << 31))
   1725 int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 &&
   1726     LARGE_OFF_T % 2147483647 == 1) ? 1 : -1];
   1727 int main(void) { return (isatty(0)); }' >lft.c
   1728 ac_testn can_lfs '' "for large file support" <lft.c
   1729 save_CPPFLAGS=$CPPFLAGS
   1730 add_cppflags -D_FILE_OFFSET_BITS=64
   1731 ac_testn can_lfs_sus '!' can_lfs 0 "... with -D_FILE_OFFSET_BITS=64" <lft.c
   1732 if test 0 = $HAVE_CAN_LFS_SUS; then
   1733 	CPPFLAGS=$save_CPPFLAGS
   1734 	add_cppflags -D_LARGE_FILES=1
   1735 	ac_testn can_lfs_aix '!' can_lfs 0 "... with -D_LARGE_FILES=1" <lft.c
   1736 	test 1 = $HAVE_CAN_LFS_AIX || CPPFLAGS=$save_CPPFLAGS
   1737 fi
   1738 rm -f lft.c
   1739 rmf lft*	# end of large file support test
   1740 
   1741 #
   1742 # Environment: types
   1743 #
   1744 ac_test can_inttypes '!' stdint_h 1 "for standard 32-bit integer types" <<-'EOF'
   1745 	#include <sys/types.h>
   1746 	#include <stddef.h>
   1747 	int main(int ac, char **av) { return ((uint32_t)(size_t)*av + (int32_t)ac); }
   1748 EOF
   1749 ac_test can_ucbints '!' can_inttypes 1 "for UCB 32-bit integer types" <<-'EOF'
   1750 	#include <sys/types.h>
   1751 	#include <stddef.h>
   1752 	int main(int ac, char **av) { return ((u_int32_t)(size_t)*av + (int32_t)ac); }
   1753 EOF
   1754 ac_test can_int8type '!' stdint_h 1 "for standard 8-bit integer type" <<-'EOF'
   1755 	#include <sys/types.h>
   1756 	#include <stddef.h>
   1757 	int main(int ac, char **av) { return ((uint8_t)(size_t)av[ac]); }
   1758 EOF
   1759 ac_test can_ucbint8 '!' can_int8type 1 "for UCB 8-bit integer type" <<-'EOF'
   1760 	#include <sys/types.h>
   1761 	#include <stddef.h>
   1762 	int main(int ac, char **av) { return ((u_int8_t)(size_t)av[ac]); }
   1763 EOF
   1764 
   1765 ac_test rlim_t <<-'EOF'
   1766 	#include <sys/types.h>
   1767 	#if HAVE_BOTH_TIME_H
   1768 	#include <sys/time.h>
   1769 	#include <time.h>
   1770 	#elif HAVE_SYS_TIME_H
   1771 	#include <sys/time.h>
   1772 	#elif HAVE_TIME_H
   1773 	#include <time.h>
   1774 	#endif
   1775 	#if HAVE_SYS_RESOURCE_H
   1776 	#include <sys/resource.h>
   1777 	#endif
   1778 	#include <unistd.h>
   1779 	int main(void) { return (((int)(rlim_t)0) + isatty(0)); }
   1780 EOF
   1781 
   1782 # only testn: added later below
   1783 ac_testn sig_t <<-'EOF'
   1784 	#include <sys/types.h>
   1785 	#include <signal.h>
   1786 	#include <stddef.h>
   1787 	volatile sig_t foo = (sig_t)0;
   1788 	int main(void) { return (foo == (sig_t)0); }
   1789 EOF
   1790 
   1791 ac_testn sighandler_t '!' sig_t 0 <<-'EOF'
   1792 	#include <sys/types.h>
   1793 	#include <signal.h>
   1794 	#include <stddef.h>
   1795 	volatile sighandler_t foo = (sighandler_t)0;
   1796 	int main(void) { return (foo == (sighandler_t)0); }
   1797 EOF
   1798 if test 1 = $HAVE_SIGHANDLER_T; then
   1799 	add_cppflags -Dsig_t=sighandler_t
   1800 	HAVE_SIG_T=1
   1801 fi
   1802 
   1803 ac_testn __sighandler_t '!' sig_t 0 <<-'EOF'
   1804 	#include <sys/types.h>
   1805 	#include <signal.h>
   1806 	#include <stddef.h>
   1807 	volatile __sighandler_t foo = (__sighandler_t)0;
   1808 	int main(void) { return (foo == (__sighandler_t)0); }
   1809 EOF
   1810 if test 1 = $HAVE___SIGHANDLER_T; then
   1811 	add_cppflags -Dsig_t=__sighandler_t
   1812 	HAVE_SIG_T=1
   1813 fi
   1814 
   1815 test 1 = $HAVE_SIG_T || add_cppflags -Dsig_t=nosig_t
   1816 ac_cppflags SIG_T
   1817 
   1818 #
   1819 # check whether whatever we use for the final link will succeed
   1820 #
   1821 if test $cm = makefile; then
   1822 	: nothing to check
   1823 else
   1824 	HAVE_LINK_WORKS=x
   1825 	ac_testinit link_works '' 'checking if the final link command may succeed'
   1826 	fv=1
   1827 	cat >conftest.c <<-EOF
   1828 		#define EXTERN
   1829 		#define MKSH_INCLUDES_ONLY
   1830 		#include "sh.h"
   1831 		__RCSID("$srcversion");
   1832 		int main(void) { printf("Hello, World!\\n"); return (isatty(0)); }
   1833 EOF
   1834 	case $cm in
   1835 	llvm)
   1836 		v "$CC $CFLAGS $CPPFLAGS $NOWARN -emit-llvm -c conftest.c" || fv=0
   1837 		rmf $tfn.s
   1838 		test $fv = 0 || v "llvm-link -o - conftest.o | opt $optflags | llc -o $tfn.s" || fv=0
   1839 		test $fv = 0 || v "$CC $CFLAGS $LDFLAGS -o $tcfn $tfn.s $LIBS $ccpr"
   1840 		;;
   1841 	dragonegg)
   1842 		v "$CC $CFLAGS $CPPFLAGS $NOWARN -S -flto conftest.c" || fv=0
   1843 		test $fv = 0 || v "mv conftest.s conftest.ll"
   1844 		test $fv = 0 || v "llvm-as conftest.ll" || fv=0
   1845 		rmf $tfn.s
   1846 		test $fv = 0 || v "llvm-link -o - conftest.bc | opt $optflags | llc -o $tfn.s" || fv=0
   1847 		test $fv = 0 || v "$CC $CFLAGS $LDFLAGS -o $tcfn $tfn.s $LIBS $ccpr"
   1848 		;;
   1849 	combine)
   1850 		v "$CC $CFLAGS $CPPFLAGS $LDFLAGS -fwhole-program --combine $NOWARN -o $tcfn conftest.c $LIBS $ccpr"
   1851 		;;
   1852 	lto|normal)
   1853 		cm=normal
   1854 		v "$CC $CFLAGS $CPPFLAGS $NOWARN -c conftest.c" || fv=0
   1855 		test $fv = 0 || v "$CC $CFLAGS $LDFLAGS -o $tcfn conftest.o $LIBS $ccpr"
   1856 		;;
   1857 	esac
   1858 	test -f $tcfn || fv=0
   1859 	ac_testdone
   1860 	test $fv = 1 || exit 1
   1861 fi
   1862 
   1863 #
   1864 # Environment: errors and signals
   1865 #
   1866 test x"NetBSD" = x"$TARGET_OS" && $e Ignore the compatibility warning.
   1867 
   1868 ac_testn sys_errlist '' "the sys_errlist[] array and sys_nerr" <<-'EOF'
   1869 	extern const int sys_nerr;
   1870 	extern const char * const sys_errlist[];
   1871 	extern int isatty(int);
   1872 	int main(void) { return (*sys_errlist[sys_nerr - 1] + isatty(0)); }
   1873 EOF
   1874 ac_testn _sys_errlist '!' sys_errlist 0 "the _sys_errlist[] array and _sys_nerr" <<-'EOF'
   1875 	extern const int _sys_nerr;
   1876 	extern const char * const _sys_errlist[];
   1877 	extern int isatty(int);
   1878 	int main(void) { return (*_sys_errlist[_sys_nerr - 1] + isatty(0)); }
   1879 EOF
   1880 if test 1 = "$HAVE__SYS_ERRLIST"; then
   1881 	add_cppflags -Dsys_nerr=_sys_nerr
   1882 	add_cppflags -Dsys_errlist=_sys_errlist
   1883 	HAVE_SYS_ERRLIST=1
   1884 fi
   1885 ac_cppflags SYS_ERRLIST
   1886 
   1887 for what in name list; do
   1888 	uwhat=`upper $what`
   1889 	ac_testn sys_sig$what '' "the sys_sig${what}[] array" <<-EOF
   1890 		extern const char * const sys_sig${what}[];
   1891 		extern int isatty(int);
   1892 		int main(void) { return (sys_sig${what}[0][0] + isatty(0)); }
   1893 	EOF
   1894 	ac_testn _sys_sig$what '!' sys_sig$what 0 "the _sys_sig${what}[] array" <<-EOF
   1895 		extern const char * const _sys_sig${what}[];
   1896 		extern int isatty(int);
   1897 		int main(void) { return (_sys_sig${what}[0][0] + isatty(0)); }
   1898 	EOF
   1899 	eval uwhat_v=\$HAVE__SYS_SIG$uwhat
   1900 	if test 1 = "$uwhat_v"; then
   1901 		add_cppflags -Dsys_sig$what=_sys_sig$what
   1902 		eval HAVE_SYS_SIG$uwhat=1
   1903 	fi
   1904 	ac_cppflags SYS_SIG$uwhat
   1905 done
   1906 
   1907 #
   1908 # Environment: library functions
   1909 #
   1910 ac_test flock <<-'EOF'
   1911 	#include <sys/types.h>
   1912 	#include <fcntl.h>
   1913 	#undef flock
   1914 	#if HAVE_SYS_FILE_H
   1915 	#include <sys/file.h>
   1916 	#endif
   1917 	int main(void) { return (flock(0, LOCK_EX | LOCK_UN)); }
   1918 EOF
   1919 
   1920 ac_test lock_fcntl '!' flock 1 'whether we can lock files with fcntl' <<-'EOF'
   1921 	#include <fcntl.h>
   1922 	#undef flock
   1923 	int main(void) {
   1924 		struct flock lks;
   1925 		lks.l_type = F_WRLCK | F_UNLCK;
   1926 		return (fcntl(0, F_SETLKW, &lks));
   1927 	}
   1928 EOF
   1929 
   1930 ac_test getrusage <<-'EOF'
   1931 	#define MKSH_INCLUDES_ONLY
   1932 	#include "sh.h"
   1933 	int main(void) {
   1934 		struct rusage ru;
   1935 		return (getrusage(RUSAGE_SELF, &ru) +
   1936 		    getrusage(RUSAGE_CHILDREN, &ru));
   1937 	}
   1938 EOF
   1939 
   1940 ac_test getsid <<-'EOF'
   1941 	#include <unistd.h>
   1942 	int main(void) { return ((int)getsid(0)); }
   1943 EOF
   1944 
   1945 ac_test gettimeofday <<-'EOF'
   1946 	#define MKSH_INCLUDES_ONLY
   1947 	#include "sh.h"
   1948 	int main(void) { struct timeval tv; return (gettimeofday(&tv, NULL)); }
   1949 EOF
   1950 
   1951 ac_test killpg <<-'EOF'
   1952 	#include <signal.h>
   1953 	int main(int ac, char *av[]) { return (av[0][killpg(123, ac)]); }
   1954 EOF
   1955 
   1956 ac_test memmove <<-'EOF'
   1957 	#include <sys/types.h>
   1958 	#include <stddef.h>
   1959 	#include <string.h>
   1960 	#if HAVE_STRINGS_H
   1961 	#include <strings.h>
   1962 	#endif
   1963 	int main(int ac, char *av[]) {
   1964 		return (*(int *)(void *)memmove(av[0], av[1], (size_t)ac));
   1965 	}
   1966 EOF
   1967 
   1968 ac_test mknod '' 'if to use mknod(), makedev() and friends' <<-'EOF'
   1969 	#define MKSH_INCLUDES_ONLY
   1970 	#include "sh.h"
   1971 	int main(int ac, char *av[]) {
   1972 		dev_t dv;
   1973 		dv = makedev((unsigned int)ac, (unsigned int)av[0][0]);
   1974 		return (mknod(av[0], (mode_t)0, dv) ? (int)major(dv) :
   1975 		    (int)minor(dv));
   1976 	}
   1977 EOF
   1978 
   1979 ac_test mmap lock_fcntl 0 'for mmap and munmap' <<-'EOF'
   1980 	#include <sys/types.h>
   1981 	#if HAVE_SYS_FILE_H
   1982 	#include <sys/file.h>
   1983 	#endif
   1984 	#if HAVE_SYS_MMAN_H
   1985 	#include <sys/mman.h>
   1986 	#endif
   1987 	#include <stddef.h>
   1988 	#include <stdlib.h>
   1989 	int main(void) { return ((void *)mmap(NULL, (size_t)0,
   1990 	    PROT_READ, MAP_PRIVATE, 0, (off_t)0) == (void *)NULL ? 1 :
   1991 	    munmap(NULL, 0)); }
   1992 EOF
   1993 
   1994 ac_test nice <<-'EOF'
   1995 	#include <unistd.h>
   1996 	int main(void) { return (nice(4)); }
   1997 EOF
   1998 
   1999 ac_test revoke <<-'EOF'
   2000 	#include <sys/types.h>
   2001 	#if HAVE_LIBUTIL_H
   2002 	#include <libutil.h>
   2003 	#endif
   2004 	#include <unistd.h>
   2005 	int main(int ac, char *av[]) { return (ac + revoke(av[0])); }
   2006 EOF
   2007 
   2008 ac_test setlocale_ctype '' 'setlocale(LC_CTYPE, "")' <<-'EOF'
   2009 	#include <locale.h>
   2010 	#include <stddef.h>
   2011 	int main(void) { return ((int)(size_t)(void *)setlocale(LC_CTYPE, "")); }
   2012 EOF
   2013 
   2014 ac_test langinfo_codeset setlocale_ctype 0 'nl_langinfo(CODESET)' <<-'EOF'
   2015 	#include <langinfo.h>
   2016 	#include <stddef.h>
   2017 	int main(void) { return ((int)(size_t)(void *)nl_langinfo(CODESET)); }
   2018 EOF
   2019 
   2020 ac_test select <<-'EOF'
   2021 	#include <sys/types.h>
   2022 	#if HAVE_BOTH_TIME_H
   2023 	#include <sys/time.h>
   2024 	#include <time.h>
   2025 	#elif HAVE_SYS_TIME_H
   2026 	#include <sys/time.h>
   2027 	#elif HAVE_TIME_H
   2028 	#include <time.h>
   2029 	#endif
   2030 	#if HAVE_SYS_BSDTYPES_H
   2031 	#include <sys/bsdtypes.h>
   2032 	#endif
   2033 	#if HAVE_SYS_SELECT_H
   2034 	#include <sys/select.h>
   2035 	#endif
   2036 	#if HAVE_BSTRING_H
   2037 	#include <bstring.h>
   2038 	#endif
   2039 	#include <stddef.h>
   2040 	#include <stdlib.h>
   2041 	#include <string.h>
   2042 	#if HAVE_STRINGS_H
   2043 	#include <strings.h>
   2044 	#endif
   2045 	#include <unistd.h>
   2046 	int main(void) {
   2047 		struct timeval tv = { 1, 200000 };
   2048 		fd_set fds; FD_ZERO(&fds); FD_SET(0, &fds);
   2049 		return (select(FD_SETSIZE, &fds, NULL, NULL, &tv));
   2050 	}
   2051 EOF
   2052 
   2053 ac_test setresugid <<-'EOF'
   2054 	#include <sys/types.h>
   2055 	#include <unistd.h>
   2056 	int main(void) { return (setresuid(0,0,0) + setresgid(0,0,0)); }
   2057 EOF
   2058 
   2059 ac_test setgroups setresugid 0 <<-'EOF'
   2060 	#include <sys/types.h>
   2061 	#if HAVE_GRP_H
   2062 	#include <grp.h>
   2063 	#endif
   2064 	#include <unistd.h>
   2065 	int main(void) { gid_t gid = 0; return (setgroups(0, &gid)); }
   2066 EOF
   2067 
   2068 if test x"$et" = x"klibc"; then
   2069 
   2070 	ac_testn __rt_sigsuspend '' 'whether klibc uses RT signals' <<-'EOF'
   2071 		#define MKSH_INCLUDES_ONLY
   2072 		#include "sh.h"
   2073 		extern int __rt_sigsuspend(const sigset_t *, size_t);
   2074 		int main(void) { return (__rt_sigsuspend(NULL, 0)); }
   2075 EOF
   2076 
   2077 	# no? damn! legacy crap ahead!
   2078 
   2079 	ac_testn __sigsuspend_s '!' __rt_sigsuspend 1 \
   2080 	    'whether sigsuspend is usable (1/2)' <<-'EOF'
   2081 		#define MKSH_INCLUDES_ONLY
   2082 		#include "sh.h"
   2083 		extern int __sigsuspend_s(sigset_t);
   2084 		int main(void) { return (__sigsuspend_s(0)); }
   2085 EOF
   2086 	ac_testn __sigsuspend_xxs '!' __sigsuspend_s 1 \
   2087 	    'whether sigsuspend is usable (2/2)' <<-'EOF'
   2088 		#define MKSH_INCLUDES_ONLY
   2089 		#include "sh.h"
   2090 		extern int __sigsuspend_xxs(int, int, sigset_t);
   2091 		int main(void) { return (__sigsuspend_xxs(0, 0, 0)); }
   2092 EOF
   2093 
   2094 	if test "000" = "$HAVE___RT_SIGSUSPEND$HAVE___SIGSUSPEND_S$HAVE___SIGSUSPEND_XXS"; then
   2095 		# no usable sigsuspend(), use pause() *ugh*
   2096 		add_cppflags -DMKSH_NO_SIGSUSPEND
   2097 	fi
   2098 fi
   2099 
   2100 ac_test strerror '!' sys_errlist 0 <<-'EOF'
   2101 	extern char *strerror(int);
   2102 	int main(int ac, char *av[]) { return (*strerror(*av[ac])); }
   2103 EOF
   2104 
   2105 ac_test strsignal '!' sys_siglist 0 <<-'EOF'
   2106 	#include <string.h>
   2107 	#include <signal.h>
   2108 	int main(void) { return (strsignal(1)[0]); }
   2109 EOF
   2110 
   2111 ac_test strlcpy <<-'EOF'
   2112 	#include <string.h>
   2113 	int main(int ac, char *av[]) { return (strlcpy(*av, av[1],
   2114 	    (size_t)ac)); }
   2115 EOF
   2116 
   2117 #
   2118 # check headers for declarations
   2119 #
   2120 ac_test flock_decl flock 1 'for declaration of flock()' <<-'EOF'
   2121 	#define MKSH_INCLUDES_ONLY
   2122 	#include "sh.h"
   2123 	#if HAVE_SYS_FILE_H
   2124 	#include <sys/file.h>
   2125 	#endif
   2126 	int main(void) { return ((flock)(0, 0)); }
   2127 EOF
   2128 ac_test revoke_decl revoke 1 'for declaration of revoke()' <<-'EOF'
   2129 	#define MKSH_INCLUDES_ONLY
   2130 	#include "sh.h"
   2131 	int main(void) { return ((revoke)("")); }
   2132 EOF
   2133 ac_test sys_errlist_decl sys_errlist 0 "for declaration of sys_errlist[] and sys_nerr" <<-'EOF'
   2134 	#define MKSH_INCLUDES_ONLY
   2135 	#include "sh.h"
   2136 	int main(void) { return (*sys_errlist[sys_nerr - 1] + isatty(0)); }
   2137 EOF
   2138 ac_test sys_siglist_decl sys_siglist 0 'for declaration of sys_siglist[]' <<-'EOF'
   2139 	#define MKSH_INCLUDES_ONLY
   2140 	#include "sh.h"
   2141 	int main(void) { return (sys_siglist[0][0] + isatty(0)); }
   2142 EOF
   2143 
   2144 #
   2145 # other checks
   2146 #
   2147 fd='if to use persistent history'
   2148 ac_cache PERSISTENT_HISTORY || case $HAVE_MMAP$HAVE_FLOCK$HAVE_LOCK_FCNTL in
   2149 11*|101) fv=1 ;;
   2150 esac
   2151 test 1 = $fv || check_categories="$check_categories no-histfile"
   2152 ac_testdone
   2153 ac_cppflags
   2154 
   2155 save_CFLAGS=$CFLAGS
   2156 ac_testn compile_time_asserts_$$ '' 'whether compile-time assertions pass' <<-'EOF'
   2157 	#define MKSH_INCLUDES_ONLY
   2158 	#include "sh.h"
   2159 	#ifndef CHAR_BIT
   2160 	#define CHAR_BIT 8	/* defuse this test on really legacy systems */
   2161 	#endif
   2162 	struct ctasserts {
   2163 	#define cta(name, assertion) char name[(assertion) ? 1 : -1]
   2164 /* this one should be defined by the standard */
   2165 cta(char_is_1_char, (sizeof(char) == 1) && (sizeof(signed char) == 1) &&
   2166     (sizeof(unsigned char) == 1));
   2167 cta(char_is_8_bits, ((CHAR_BIT) == 8) && ((int)(unsigned char)0xFF == 0xFF) &&
   2168     ((int)(unsigned char)0x100 == 0) && ((int)(unsigned char)(int)-1 == 0xFF));
   2169 /* the next assertion is probably not really needed */
   2170 cta(short_is_2_char, sizeof(short) == 2);
   2171 cta(short_size_no_matter_of_signedness, sizeof(short) == sizeof(unsigned short));
   2172 /* the next assertion is probably not really needed */
   2173 cta(int_is_4_char, sizeof(int) == 4);
   2174 cta(int_size_no_matter_of_signedness, sizeof(int) == sizeof(unsigned int));
   2175 
   2176 cta(long_ge_int, sizeof(long) >= sizeof(int));
   2177 cta(long_size_no_matter_of_signedness, sizeof(long) == sizeof(unsigned long));
   2178 
   2179 #ifndef MKSH_LEGACY_MODE
   2180 /* the next assertion is probably not really needed */
   2181 cta(ari_is_4_char, sizeof(mksh_ari_t) == 4);
   2182 /* but this is */
   2183 cta(ari_has_31_bit, 0 < (mksh_ari_t)(((((mksh_ari_t)1 << 15) << 15) - 1) * 2 + 1));
   2184 /* the next assertion is probably not really needed */
   2185 cta(uari_is_4_char, sizeof(mksh_uari_t) == 4);
   2186 /* but the next three are; we REQUIRE unsigned integer wraparound */
   2187 cta(uari_has_31_bit, 0 < (mksh_uari_t)(((((mksh_uari_t)1 << 15) << 15) - 1) * 2 + 1));
   2188 cta(uari_has_32_bit, 0 < (mksh_uari_t)(((((mksh_uari_t)1 << 15) << 15) - 1) * 4 + 3));
   2189 cta(uari_wrap_32_bit,
   2190     (mksh_uari_t)(((((mksh_uari_t)1 << 15) << 15) - 1) * 4 + 3) >
   2191     (mksh_uari_t)(((((mksh_uari_t)1 << 15) << 15) - 1) * 4 + 4));
   2192 #define NUM 22
   2193 #else
   2194 #define NUM 16
   2195 #endif
   2196 /* these are always required */
   2197 cta(ari_is_signed, (mksh_ari_t)-1 < (mksh_ari_t)0);
   2198 cta(uari_is_unsigned, (mksh_uari_t)-1 > (mksh_uari_t)0);
   2199 /* we require these to have the precisely same size and assume 2s complement */
   2200 cta(ari_size_no_matter_of_signedness, sizeof(mksh_ari_t) == sizeof(mksh_uari_t));
   2201 
   2202 cta(sizet_size_no_matter_of_signedness, sizeof(ssize_t) == sizeof(size_t));
   2203 cta(sizet_voidptr_same_size, sizeof(size_t) == sizeof(void *));
   2204 cta(sizet_funcptr_same_size, sizeof(size_t) == sizeof(void (*)(void)));
   2205 /* our formatting routines assume this */
   2206 cta(ptr_fits_in_long, sizeof(size_t) <= sizeof(long));
   2207 cta(ari_fits_in_long, sizeof(mksh_ari_t) <= sizeof(long));
   2208 /* for struct alignment people */
   2209 		char padding[64 - NUM];
   2210 	};
   2211 char ctasserts_dblcheck[sizeof(struct ctasserts) == 64 ? 1 : -1];
   2212 	int main(void) { return (sizeof(ctasserts_dblcheck) + isatty(0)); }
   2213 EOF
   2214 CFLAGS=$save_CFLAGS
   2215 eval test 1 = \$HAVE_COMPILE_TIME_ASSERTS_$$ || exit 1
   2216 
   2217 #
   2218 # extra checks for legacy mksh
   2219 #
   2220 if test $legacy = 1; then
   2221 	ac_test long_32bit '' 'whether long is 32 bit wide' <<-'EOF'
   2222 		#define MKSH_INCLUDES_ONLY
   2223 		#include "sh.h"
   2224 		#ifndef CHAR_BIT
   2225 		#define CHAR_BIT 0
   2226 		#endif
   2227 		struct ctasserts {
   2228 		#define cta(name, assertion) char name[(assertion) ? 1 : -1]
   2229 			cta(char_is_8_bits, (CHAR_BIT) == 8);
   2230 			cta(long_is_32_bits, sizeof(long) == 4);
   2231 		};
   2232 		int main(void) { return (sizeof(struct ctasserts)); }
   2233 EOF
   2234 
   2235 	ac_test long_64bit '!' long_32bit 0 'whether long is 64 bit wide' <<-'EOF'
   2236 		#define MKSH_INCLUDES_ONLY
   2237 		#include "sh.h"
   2238 		#ifndef CHAR_BIT
   2239 		#define CHAR_BIT 0
   2240 		#endif
   2241 		struct ctasserts {
   2242 		#define cta(name, assertion) char name[(assertion) ? 1 : -1]
   2243 			cta(char_is_8_bits, (CHAR_BIT) == 8);
   2244 			cta(long_is_64_bits, sizeof(long) == 8);
   2245 		};
   2246 		int main(void) { return (sizeof(struct ctasserts)); }
   2247 EOF
   2248 
   2249 	case $HAVE_LONG_32BIT$HAVE_LONG_64BIT in
   2250 	10) check_categories="$check_categories int:32" ;;
   2251 	01) check_categories="$check_categories int:64" ;;
   2252 	*) check_categories="$check_categories int:u" ;;
   2253 	esac
   2254 fi
   2255 
   2256 #
   2257 # Compiler: Praeprocessor (only if needed)
   2258 #
   2259 test 0 = $HAVE_SYS_SIGNAME && if ac_testinit cpp_dd '' \
   2260     'checking if the C Preprocessor supports -dD'; then
   2261 	echo '#define foo bar' >conftest.c
   2262 	vv ']' "$CPP $CFLAGS $CPPFLAGS $NOWARN -dD conftest.c >x"
   2263 	grep '#define foo bar' x >/dev/null 2>&1 && fv=1
   2264 	rmf conftest.c x vv.out
   2265 	ac_testdone
   2266 fi
   2267 
   2268 #
   2269 # End of mirtoconf checks
   2270 #
   2271 $e ... done.
   2272 
   2273 # Some operating systems have ancient versions of ed(1) writing
   2274 # the character count to standard output; cope for that
   2275 echo wq >x
   2276 ed x <x 2>/dev/null | grep 3 >/dev/null 2>&1 && \
   2277     check_categories="$check_categories $oldish_ed"
   2278 rmf x vv.out
   2279 
   2280 if test 0 = $HAVE_SYS_SIGNAME; then
   2281 	if test 1 = $HAVE_CPP_DD; then
   2282 		$e Generating list of signal names...
   2283 	else
   2284 		$e No list of signal names available via cpp. Falling back...
   2285 	fi
   2286 	sigseenone=:
   2287 	sigseentwo=:
   2288 	echo '#include <signal.h>
   2289 #if defined(NSIG_MAX)
   2290 #define cfg_NSIG NSIG_MAX
   2291 #elif defined(NSIG)
   2292 #define cfg_NSIG NSIG
   2293 #elif defined(_NSIG)
   2294 #define cfg_NSIG _NSIG
   2295 #elif defined(SIGMAX)
   2296 #define cfg_NSIG (SIGMAX + 1)
   2297 #elif defined(_SIGMAX)
   2298 #define cfg_NSIG (_SIGMAX + 1)
   2299 #else
   2300 /*XXX better error out, see sh.h */
   2301 #define cfg_NSIG 64
   2302 #endif
   2303 int
   2304 mksh_cfg= cfg_NSIG
   2305 ;' >conftest.c
   2306 	# GNU sed 2.03 segfaults when optimising this to sed -n
   2307 	NSIG=`vq "$CPP $CFLAGS $CPPFLAGS $NOWARN conftest.c" | \
   2308 	    grep -v '^#' | \
   2309 	    sed '/mksh_cfg.*= *$/{
   2310 		N
   2311 		s/\n/ /
   2312 		}' | \
   2313 	    grep '^ *mksh_cfg *=' | \
   2314 	    sed 's/^ *mksh_cfg *=[	 ]*\([()0-9x+-][()0-9x+	 -]*\).*$/\1/'`
   2315 	case $NSIG in
   2316 	*mksh_cfg*) $e "Error: NSIG='$NSIG'"; NSIG=0 ;;
   2317 	*[\ \(\)+-]*) NSIG=`"$AWK" "BEGIN { print $NSIG }" </dev/null` ;;
   2318 	esac
   2319 	printf=printf
   2320 	(printf hallo) >/dev/null 2>&1 || printf=echo
   2321 	test $printf = echo || test "`printf %d 42`" = 42 || printf=echo
   2322 	test $printf = echo || NSIG=`printf %d "$NSIG" 2>/dev/null`
   2323 	$printf "NSIG=$NSIG ... "
   2324 	sigs="ABRT FPE ILL INT SEGV TERM ALRM BUS CHLD CONT HUP KILL PIPE QUIT"
   2325 	sigs="$sigs STOP TSTP TTIN TTOU USR1 USR2 POLL PROF SYS TRAP URG VTALRM"
   2326 	sigs="$sigs XCPU XFSZ INFO WINCH EMT IO DIL LOST PWR SAK CLD IOT STKFLT"
   2327 	sigs="$sigs ABND DCE DUMP IOERR TRACE DANGER THCONT THSTOP RESV UNUSED"
   2328 	test 1 = $HAVE_CPP_DD && test $NSIG -gt 1 && sigs="$sigs "`vq \
   2329 	    "$CPP $CFLAGS $CPPFLAGS $NOWARN -dD conftest.c" | \
   2330 	    grep '[	 ]SIG[A-Z0-9][A-Z0-9]*[	 ]' | \
   2331 	    sed 's/^.*[	 ]SIG\([A-Z0-9][A-Z0-9]*\)[	 ].*$/\1/' | sort`
   2332 	test $NSIG -gt 1 || sigs=
   2333 	for name in $sigs; do
   2334 		case $sigseenone in
   2335 		*:$name:*) continue ;;
   2336 		esac
   2337 		sigseenone=$sigseenone$name:
   2338 		echo '#include <signal.h>' >conftest.c
   2339 		echo int >>conftest.c
   2340 		echo mksh_cfg= SIG$name >>conftest.c
   2341 		echo ';' >>conftest.c
   2342 		# GNU sed 2.03 croaks on optimising this, too
   2343 		vq "$CPP $CFLAGS $CPPFLAGS $NOWARN conftest.c" | \
   2344 		    grep -v '^#' | \
   2345 		    sed '/mksh_cfg.*= *$/{
   2346 			N
   2347 			s/\n/ /
   2348 			}' | \
   2349 		    grep '^ *mksh_cfg *=' | \
   2350 		    sed 's/^ *mksh_cfg *=[	 ]*\([0-9][0-9x]*\).*$/:\1 '$name/
   2351 	done | sed -n '/^:[^ ]/s/^://p' | while read nr name; do
   2352 		test $printf = echo || nr=`printf %d "$nr" 2>/dev/null`
   2353 		test $nr -gt 0 && test $nr -lt $NSIG || continue
   2354 		case $sigseentwo in
   2355 		*:$nr:*) ;;
   2356 		*)	echo "		{ \"$name\", $nr },"
   2357 			sigseentwo=$sigseentwo$nr:
   2358 			$printf "$name=$nr " >&2
   2359 			;;
   2360 		esac
   2361 	done 2>&1 >signames.inc
   2362 	rmf conftest.c
   2363 	$e done.
   2364 fi
   2365 
   2366 addsrcs '!' HAVE_STRLCPY strlcpy.c
   2367 addsrcs USE_PRINTF_BUILTIN printf.c
   2368 test 1 = "$USE_PRINTF_BUILTIN" && add_cppflags -DMKSH_PRINTF_BUILTIN
   2369 test 1 = "$HAVE_CAN_VERB" && CFLAGS="$CFLAGS -verbose"
   2370 add_cppflags -DMKSH_BUILD_R=541
   2371 
   2372 $e $bi$me: Finished configuration testing, now producing output.$ao
   2373 
   2374 files=
   2375 objs=
   2376 sp=
   2377 case $tcfn in
   2378 a.exe|conftest.exe)
   2379 	mkshexe=$tfn.exe
   2380 	add_cppflags -DMKSH_EXE_EXT
   2381 	;;
   2382 *)
   2383 	mkshexe=$tfn
   2384 	;;
   2385 esac
   2386 case $curdir in
   2387 *\ *)	mkshshebang="#!./$mkshexe" ;;
   2388 *)	mkshshebang="#!$curdir/$mkshexe" ;;
   2389 esac
   2390 cat >test.sh <<-EOF
   2391 	$mkshshebang
   2392 	LC_ALL=C PATH='$PATH'; export LC_ALL PATH
   2393 	test -n "\$KSH_VERSION" || exit 1
   2394 	set -A check_categories -- $check_categories
   2395 	pflag='$curdir/$mkshexe'
   2396 	sflag='$srcdir/check.t'
   2397 	usee=0 Pflag=0 Sflag=0 uset=0 vflag=1 xflag=0
   2398 	while getopts "C:e:fPp:QSs:t:v" ch; do case \$ch {
   2399 	(C)	check_categories[\${#check_categories[*]}]=\$OPTARG ;;
   2400 	(e)	usee=1; eflag=\$OPTARG ;;
   2401 	(f)	check_categories[\${#check_categories[*]}]=fastbox ;;
   2402 	(P)	Pflag=1 ;;
   2403 	(+P)	Pflag=0 ;;
   2404 	(p)	pflag=\$OPTARG ;;
   2405 	(Q)	vflag=0 ;;
   2406 	(+Q)	vflag=1 ;;
   2407 	(S)	Sflag=1 ;;
   2408 	(+S)	Sflag=0 ;;
   2409 	(s)	sflag=\$OPTARG ;;
   2410 	(t)	uset=1; tflag=\$OPTARG ;;
   2411 	(v)	vflag=1 ;;
   2412 	(+v)	vflag=0 ;;
   2413 	(*)	xflag=1 ;;
   2414 	}
   2415 	done
   2416 	shift \$((OPTIND - 1))
   2417 	set -A args -- '$srcdir/check.pl' -p "\$pflag"
   2418 	x=
   2419 	for y in "\${check_categories[@]}"; do
   2420 		x=\$x,\$y
   2421 	done
   2422 	if [[ -n \$x ]]; then
   2423 		args[\${#args[*]}]=-C
   2424 		args[\${#args[*]}]=\${x#,}
   2425 	fi
   2426 	if (( usee )); then
   2427 		args[\${#args[*]}]=-e
   2428 		args[\${#args[*]}]=\$eflag
   2429 	fi
   2430 	(( Pflag )) && args[\${#args[*]}]=-P
   2431 	if (( uset )); then
   2432 		args[\${#args[*]}]=-t
   2433 		args[\${#args[*]}]=\$tflag
   2434 	fi
   2435 	(( vflag )) && args[\${#args[*]}]=-v
   2436 	(( xflag )) && args[\${#args[*]}]=-x	# force usage by synerr
   2437 	if [[ -n \$TMPDIR && -d \$TMPDIR/. ]]; then
   2438 		args[\${#args[*]}]=-T
   2439 		args[\${#args[*]}]=\$TMPDIR
   2440 	fi
   2441 	print Testing mksh for conformance:
   2442 	grep -F -e Mir''OS: -e MIRBSD "\$sflag"
   2443 	print "This shell is actually:\\n\\t\$KSH_VERSION"
   2444 	print 'test.sh built for mksh $dstversion'
   2445 	cstr='\$os = defined \$^O ? \$^O : "unknown";'
   2446 	cstr="\$cstr"'print \$os . ", Perl version " . \$];'
   2447 	for perli in \$PERL perl5 perl no; do
   2448 		if [[ \$perli = no ]]; then
   2449 			print Cannot find a working Perl interpreter, aborting.
   2450 			exit 1
   2451 		fi
   2452 		print "Trying Perl interpreter '\$perli'..."
   2453 		perlos=\$(\$perli -e "\$cstr")
   2454 		rv=\$?
   2455 		print "Errorlevel \$rv, running on '\$perlos'"
   2456 		if (( rv )); then
   2457 			print "=> not using"
   2458 			continue
   2459 		fi
   2460 		if [[ -n \$perlos ]]; then
   2461 			print "=> using it"
   2462 			break
   2463 		fi
   2464 	done
   2465 	(( Sflag )) || echo + \$perli "\${args[@]}" -s "\$sflag" "\$@"
   2466 	(( Sflag )) || exec \$perli "\${args[@]}" -s "\$sflag" "\$@"$tsts
   2467 	# use of the -S option for check.t split into multiple chunks
   2468 	rv=0
   2469 	for s in "\$sflag".*; do
   2470 		echo + \$perli "\${args[@]}" -s "\$s" "\$@"
   2471 		\$perli "\${args[@]}" -s "\$s" "\$@"$tsts
   2472 		rc=\$?
   2473 		(( rv = rv ? rv : rc ))
   2474 	done
   2475 	exit \$rv
   2476 EOF
   2477 chmod 755 test.sh
   2478 case $cm in
   2479 dragonegg)
   2480 	emitbc="-S -flto"
   2481 	;;
   2482 llvm)
   2483 	emitbc="-emit-llvm -c"
   2484 	;;
   2485 *)
   2486 	emitbc=-c
   2487 	;;
   2488 esac
   2489 echo ": # work around NeXTstep bug" >Rebuild.sh
   2490 cd "$srcdir"
   2491 optfiles=`echo *.opt`
   2492 cd "$curdir"
   2493 for file in $optfiles; do
   2494 	echo "echo + Running genopt on '$file'..."
   2495 	echo "(srcfile='$srcdir/$file'; BUILDSH_RUN_GENOPT=1; . '$srcdir/Build.sh')"
   2496 done >>Rebuild.sh
   2497 echo set -x >>Rebuild.sh
   2498 for file in $SRCS; do
   2499 	op=`echo x"$file" | sed 's/^x\(.*\)\.c$/\1./'`
   2500 	test -f $file || file=$srcdir/$file
   2501 	files="$files$sp$file"
   2502 	sp=' '
   2503 	echo "$CC $CFLAGS $CPPFLAGS $emitbc $file || exit 1" >>Rebuild.sh
   2504 	if test $cm = dragonegg; then
   2505 		echo "mv ${op}s ${op}ll" >>Rebuild.sh
   2506 		echo "llvm-as ${op}ll || exit 1" >>Rebuild.sh
   2507 		objs="$objs$sp${op}bc"
   2508 	else
   2509 		objs="$objs$sp${op}o"
   2510 	fi
   2511 done
   2512 case $cm in
   2513 dragonegg|llvm)
   2514 	echo "rm -f $tfn.s" >>Rebuild.sh
   2515 	echo "llvm-link -o - $objs | opt $optflags | llc -o $tfn.s" >>Rebuild.sh
   2516 	lobjs=$tfn.s
   2517 	;;
   2518 *)
   2519 	lobjs=$objs
   2520 	;;
   2521 esac
   2522 echo tcfn=$mkshexe >>Rebuild.sh
   2523 echo "$CC $CFLAGS $LDFLAGS -o \$tcfn $lobjs $LIBS $ccpr" >>Rebuild.sh
   2524 echo "test -f \$tcfn || exit 1; $SIZE \$tcfn" >>Rebuild.sh
   2525 if test $cm = makefile; then
   2526 	extras='emacsfn.h exprtok.h rlimits.opt sh.h sh_flags.opt var_spec.h'
   2527 	test 0 = $HAVE_SYS_SIGNAME && extras="$extras signames.inc"
   2528 	gens= genq=
   2529 	for file in $optfiles; do
   2530 		genf=`basename "$file" | sed 's/.opt$/.gen/'`
   2531 		gens="$gens $genf"
   2532 		genq="$genq$nl$genf: $srcdir/Build.sh $srcdir/$file
   2533 			srcfile=$srcdir/$file; BUILDSH_RUN_GENOPT=1; . $srcdir/Build.sh"
   2534 	done
   2535 	cat >Makefrag.inc <<EOF
   2536 # Makefile fragment for building mksh $dstversion
   2537 
   2538 PROG=		$mkshexe
   2539 MAN=		mksh.1
   2540 SRCS=		$SRCS
   2541 SRCS_FP=	$files
   2542 OBJS_BP=	$objs
   2543 INDSRCS=	$extras
   2544 NONSRCS_INST=	dot.mkshrc \$(MAN)
   2545 NONSRCS_NOINST=	Build.sh Makefile Rebuild.sh check.pl check.t test.sh
   2546 CC=		$CC
   2547 CFLAGS=		$CFLAGS
   2548 CPPFLAGS=	$CPPFLAGS
   2549 LDFLAGS=	$LDFLAGS
   2550 LIBS=		$LIBS
   2551 
   2552 .depend \$(OBJS_BP):$gens$genq
   2553 
   2554 # not BSD make only:
   2555 #VPATH=		$srcdir
   2556 #all: \$(PROG)
   2557 #\$(PROG): \$(OBJS_BP)
   2558 #	\$(CC) \$(CFLAGS) \$(LDFLAGS) -o \$@ \$(OBJS_BP) \$(LIBS)
   2559 #\$(OBJS_BP): \$(SRCS_FP) \$(NONSRCS)
   2560 #.c.o:
   2561 #	\$(CC) \$(CFLAGS) \$(CPPFLAGS) -c \$<
   2562 
   2563 # for all make variants:
   2564 #REGRESS_FLAGS=	-f
   2565 #regress:
   2566 #	./test.sh \$(REGRESS_FLAGS)
   2567 check_categories=$check_categories
   2568 
   2569 # for BSD make only:
   2570 #.PATH: $srcdir
   2571 #.include <bsd.prog.mk>
   2572 EOF
   2573 	$e
   2574 	$e Generated Makefrag.inc successfully.
   2575 	exit 0
   2576 fi
   2577 for file in $optfiles; do
   2578 	$e "+ Running genopt on '$file'..."
   2579 	do_genopt "$srcdir/$file" || exit 1
   2580 done
   2581 if test $cm = combine; then
   2582 	objs="-o $mkshexe"
   2583 	for file in $SRCS; do
   2584 		test -f $file || file=$srcdir/$file
   2585 		objs="$objs $file"
   2586 	done
   2587 	emitbc="-fwhole-program --combine"
   2588 	v "$CC $CFLAGS $CPPFLAGS $LDFLAGS $emitbc $objs $LIBS $ccpr"
   2589 elif test 1 = $pm; then
   2590 	for file in $SRCS; do
   2591 		test -f $file || file=$srcdir/$file
   2592 		v "$CC $CFLAGS $CPPFLAGS $emitbc $file" &
   2593 	done
   2594 	wait
   2595 else
   2596 	for file in $SRCS; do
   2597 		test $cm = dragonegg && \
   2598 		    op=`echo x"$file" | sed 's/^x\(.*\)\.c$/\1./'`
   2599 		test -f $file || file=$srcdir/$file
   2600 		v "$CC $CFLAGS $CPPFLAGS $emitbc $file" || exit 1
   2601 		if test $cm = dragonegg; then
   2602 			v "mv ${op}s ${op}ll"
   2603 			v "llvm-as ${op}ll" || exit 1
   2604 		fi
   2605 	done
   2606 fi
   2607 case $cm in
   2608 dragonegg|llvm)
   2609 	rmf $tfn.s
   2610 	v "llvm-link -o - $objs | opt $optflags | llc -o $tfn.s"
   2611 	;;
   2612 esac
   2613 tcfn=$mkshexe
   2614 test $cm = combine || v "$CC $CFLAGS $LDFLAGS -o $tcfn $lobjs $LIBS $ccpr"
   2615 test -f $tcfn || exit 1
   2616 test 1 = $r || v "$NROFF -mdoc <'$srcdir/lksh.1' >lksh.cat1" || rmf lksh.cat1
   2617 test 1 = $r || v "$NROFF -mdoc <'$srcdir/mksh.1' >mksh.cat1" || rmf mksh.cat1
   2618 test 0 = $eq && v $SIZE $tcfn
   2619 i=install
   2620 test -f /usr/ucb/$i && i=/usr/ucb/$i
   2621 test 1 = $eq && e=:
   2622 $e
   2623 $e Installing the shell:
   2624 $e "# $i -c -s -o root -g bin -m 555 $tfn /bin/$tfn"
   2625 if test $legacy = 0; then
   2626 	$e "# grep -x /bin/$tfn /etc/shells >/dev/null || echo /bin/$tfn >>/etc/shells"
   2627 	$e "# $i -c -o root -g bin -m 444 dot.mkshrc /usr/share/doc/mksh/examples/"
   2628 fi
   2629 $e
   2630 $e Installing the manual:
   2631 if test -f mksh.cat1; then
   2632 	$e "# $i -c -o root -g bin -m 444 lksh.cat1" \
   2633 	    "/usr/share/man/cat1/lksh.0"
   2634 	$e "# $i -c -o root -g bin -m 444 mksh.cat1" \
   2635 	    "/usr/share/man/cat1/mksh.0"
   2636 	$e or
   2637 fi
   2638 $e "# $i -c -o root -g bin -m 444 lksh.1 mksh.1 /usr/share/man/man1/"
   2639 $e
   2640 $e Run the regression test suite: ./test.sh
   2641 $e Please also read the sample file dot.mkshrc and the fine manual.
   2642 exit 0
   2643 
   2644 : <<'EOD'
   2645 
   2646 === Environment used ===
   2647 
   2648 ==== build environment ====
   2649 AWK				default: awk
   2650 CC				default: cc
   2651 CFLAGS				if empty, defaults to -xO2 or +O2
   2652 				or -O3 -qstrict or -O2, per compiler
   2653 CPPFLAGS			default empty
   2654 LDFLAGS				default empty; added before sources
   2655 LDSTATIC			set this to '-static'; default unset
   2656 LIBS				default empty; added after sources
   2657 				[Interix] default: -lcrypt (XXX still needed?)
   2658 NOWARN				-Wno-error or similar
   2659 NROFF				default: nroff
   2660 TARGET_OS			default: $(uname -s || uname)
   2661 TARGET_OSREV			[QNX] default: $(uname -r)
   2662 
   2663 ==== feature selectors ====
   2664 USE_PRINTF_BUILTIN		1 to include (unsupported) printf(1) as builtin
   2665 ===== general format =====
   2666 HAVE_STRLEN			ac_test
   2667 HAVE_STRING_H			ac_header
   2668 HAVE_CAN_FSTACKPROTECTORALL	ac_flags
   2669 
   2670 ==== cpp definitions ====
   2671 DEBUG				dont use in production, wants gcc, implies:
   2672 DEBUG_LEAKS			enable freeing resources before exiting
   2673 MKSHRC_PATH			"~/.mkshrc" (do not change)
   2674 MKSH_A4PB			force use of arc4random_pushb
   2675 MKSH_ASSUME_UTF8		(0=disabled, 1=enabled; default: unset)
   2676 MKSH_BINSHPOSIX			if */sh or */-sh, enable set -o posix
   2677 MKSH_BINSHREDUCED		if */sh or */-sh, enable set -o sh
   2678 MKSH_CLS_STRING			"\033[;H\033[J"
   2679 MKSH_DEFAULT_EXECSHELL		"/bin/sh" (do not change)
   2680 MKSH_DEFAULT_PROFILEDIR		"/etc" (do not change)
   2681 MKSH_DEFAULT_TMPDIR		"/tmp" (do not change)
   2682 MKSH_DISABLE_DEPRECATED		disable code paths scheduled for later removal
   2683 MKSH_DISABLE_EXPERIMENTAL	disable code not yet comfy for (LTS) snapshots
   2684 MKSH_DISABLE_TTY_WARNING	shut up warning about ctty if OS cant be fixed
   2685 MKSH_DONT_EMIT_IDSTRING		omit RCS IDs from binary
   2686 MKSH_MIDNIGHTBSD01ASH_COMPAT	set -o sh: additional compatibility quirk
   2687 MKSH_NOPROSPECTOFWORK		disable jobs, co-processes, etc. (do not use)
   2688 MKSH_NOPWNAM			skip PAM calls, for -static on glibc or Solaris
   2689 MKSH_NO_CMDLINE_EDITING		disable command line editing code entirely
   2690 MKSH_NO_DEPRECATED_WARNING	omit warning when deprecated stuff is run
   2691 MKSH_NO_LIMITS			omit ulimit code
   2692 MKSH_NO_SIGSETJMP		define if sigsetjmp is broken or not available
   2693 MKSH_NO_SIGSUSPEND		use sigprocmask+pause instead of sigsuspend
   2694 MKSH_SMALL			omit some code, optimise hard for size (slower)
   2695 MKSH_SMALL_BUT_FAST		disable some hard-for-size optim. (modern sys.)
   2696 MKSH_S_NOVI=1			disable Vi editing mode (default if MKSH_SMALL)
   2697 MKSH_TYPEDEF_SIG_ATOMIC_T	define to e.g. 'int' if sig_atomic_t is missing
   2698 MKSH_TYPEDEF_SSIZE_T		define to e.g. 'long' if your OS has no ssize_t
   2699 MKSH_UNEMPLOYED			disable job control (but not jobs/co-processes)
   2700 
   2701 === generic installation instructions ===
   2702 
   2703 Set CC and possibly CFLAGS, CPPFLAGS, LDFLAGS, LIBS. If cross-compiling,
   2704 also set TARGET_OS. To disable tests, set e.g. HAVE_STRLCPY=0; to enable
   2705 them, set to a value other than 0 or 1. Ensure /bin/ed is installed. For
   2706 MKSH_SMALL but with Vi mode, add -DMKSH_S_NOVI=0 to CPPFLAGS as well.
   2707 
   2708 Normally, the following command is what you want to run, then:
   2709 $ (sh Build.sh -r -c lto && ./test.sh -f) 2>&1 | tee log
   2710 
   2711 Copy dot.mkshrc to /etc/skel/.mkshrc; install mksh into $prefix/bin; or
   2712 /bin; install the manpage, if omitting the -r flag a catmanpage is made
   2713 using $NROFF. Consider using a forward script as /etc/skel/.mkshrc like
   2714 http://anonscm.debian.org/cgit/collab-maint/mksh.git/plain/debian/.mkshrc
   2715 and put dot.mkshrc as /etc/mkshrc so users need not keep up their HOME.
   2716 
   2717 You may also want to install the lksh binary (also as /bin/sh) built by:
   2718 $ CPPFLAGS="$CPPFLAGS -DMKSH_BINSHPOSIX" sh Build.sh -L -r -c lto
   2719 
   2720 EOD
   2721