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