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