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