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