2 srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.727 2017/08/29 13:38:28 tg Exp $'
4 # Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
5 # 2011, 2012, 2013, 2014, 2015, 2016, 2017
6 # mirabilos <m@mirbsd.org>
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.
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.
23 # People analysing the output must whitelist conftest.c for any kind
24 # of compiler warning checks (mirtoconf is by design not quiet).
26 # Used environment documentation is at the end of this file.
31 case $ZSH_VERSION:$VERSION in
32 :zsh*) ZSH_VERSION=2 ;;
35 if test -n "${ZSH_VERSION+x}" && (emulate sh) >/dev/null 2>&1; then
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
49 safeIFS=" $safeIFS$nl"
51 allu=QWERTYUIOPASDFGHJKLZXCVBNM
52 alll=qwertyuiopasdfghjklzxcvbnm
54 alls=______________________________________________________________
56 case `echo a | tr '\201' X` in
69 echo >&2 "E: in '$srcfile': '$line'"
71 echo >&2 "E: invalid input in '$srcfile': '$line'"
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
86 sym=`echo "$line" | sed 's/^[<>]/|/'`
87 o_str=$o_str$nl"<$optclo$islo$sym"
96 cond=`echo "$cond" | sed 's/^ //'`
100 cond=`echo "$cond" | sed 's/^!//'`
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 +++ */'
121 while IFS= read line; do
126 o_sym=`echo "$line" | sed 's/^.//'`
127 o_gen=$o_gen$nl"#undef F0"
128 o_gen=$o_gen$nl"#undef FN"
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"
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)"
151 o_gen=$o_gen$nl"#elif defined($sym)"
153 ddefs="$ddefs$nl#undef $sym"
167 cond=`echo "$line" | sed 's/^[^|]*|//'`
173 IFS= read line || genopt_die Unexpected EOF
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"
181 case $state:$o_sym in
182 3:) genopt_die Expected optc sym at EOF ;;
184 *) genopt_die Missing EOF marker ;;
186 echo "$o_str" | sort | while IFS='|' read x opts cond; do
188 test -n "$x" || continue
190 test -n "$cond" && echo "$cond"
192 test -n "$cond" && echo "#endif"
195 echo "#ifndef $o_sym$o_gen"
205 if test x"$BUILDSH_RUN_GENOPT" = x"1"; then
209 if test x"$1" = x"-G"; then
214 echo "For the build logs, demonstrate that /dev/null and /dev/tty exist:"
215 ls -l /dev/null /dev/tty
226 eval "$@" >vv.out 2>&1
227 sed "s
\a^
\a${_c}
\a" <vv.out
237 Build.sh|check.pl|check.t|dot.mkshrc|*.1|*.c|*.h|*.ico|*.opt) ;;
251 oldish_ed=stdout-ed,no-stderr-ed
260 echo :"$@" | sed 's/^://' | tr $alll $allu
263 # clean up after ac_testrun()
267 test 0 = $fv || fr=yes
268 $e "$bi==> $fd...$ao $ui$fr$ao$fx"
272 # ac_cache label: sets f, fu, fv?=0
287 # ac_testinit label [!] checkif[!]0 [setlabelifcheckis[!]0] useroutput
288 # returns 1 if value was cached/implied, 0 otherwise: call ac_testdone
291 test x"$2" = x"!" && shift
292 test x"$2" = x"" || shift
298 if test x"$2" = x""; then
301 if test x"$2" = x"!"; then
305 eval ft=\$HAVE_`upper $2`
309 if test $fc = "$ft"; then
319 # pipe .c | ac_test[n] [!] label [!] checkif[!]0 [setlabelifcheckis[!]0] useroutput
321 if test x"$1" = x"!"; then
327 ac_testinit "$@" || return 1
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
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'
346 test -n "$vscan" && grep $vscan vv.out >/dev/null 2>&1 && fv=$fr
350 ac_testnnd "$@" || return
351 rmf conftest.c conftest.o ${tcfn}* vv.out
355 # ac_ifcpp cppexpr [!] label [!] checkif[!]0 [setlabelifcheckis[!]0] useroutput
360 extern int thiswillneverbedefinedIhope(void);
361 int main(void) { return (isatty(0) +
365 /* force a failure: expr is false */
366 thiswillneverbedefinedIhope()
370 test x"$1" = x"!" && shift
378 CPPFLAGS="$CPPFLAGS $*"
382 test x"$1" = x"" || fu=$1
384 test x"$2" = x"" && eval fv=\$HAVE_$fu
385 add_cppflags -DHAVE_$fu=$fv
393 # ac_flags [-] add varname cflags [text] [ldflags]
395 if test x"$1" = x"-"; then
406 test x"$ft" = x"" && ft="if $f can be used"
409 if test -n "$fl"; then
410 save_LDFLAGS=$LDFLAGS
411 LDFLAGS="$LDFLAGS $fl"
413 if test 1 = $hf; then
414 ac_testn can_$vn '' "$ft"
416 ac_testn can_$vn '' "$ft" <<-'EOF'
417 /* evil apo'stroph in comment test */
419 int main(void) { return (isatty(0)); }
422 eval fv=\$HAVE_CAN_`upper $vn`
423 if test -n "$fl"; then
424 test 11 = $fa$fv || LDFLAGS=$save_LDFLAGS
426 test 11 = $fa$fv || CFLAGS=$save_CFLAGS
429 # ac_header [!] header [prereq ...]
431 if test x"$1" = x"!"; then
438 hv=`echo "$hf" | tr -d "$lfcr" | tr -c $alll$allu$alln $alls`
439 echo "/* NeXTstep bug workaround */" >x
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
454 echo "#include <$i>" >>x
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
463 test 1 = $na || ac_cppflags
467 if test x"$1" = x"!"; then
474 test $fr = "$i" && case " $SRCS " in
476 *) SRCS="$SRCS $2" ;;
481 curdir=`pwd` srcdir=`dirname "$0" 2>/dev/null`
487 echo >&2 Source directory should not contain space or tab or newline.
488 echo >&2 Errors may occur.
491 echo Source directory must not contain single quotes.
495 dstversion=`sed -n '/define MKSH_VERSION/s/^.*"\([^"]*\)".*$/\1/p' "$srcdir/sh.h"`
496 add_cppflags -DMKSH_BUILDSH
503 optflags=-std-compile-opts
514 c:combine|c:dragonegg|c:llvm|c:lto)
519 echo "$me: Unknown option -c '$i'!" >&2
537 echo "$me: Do not call me with '-G'!" >&2
541 # checker, debug, valgrind build
543 CFLAGS="$CFLAGS -g3 -fno-builtin"
558 optflags=-std-compile-opts
579 echo "Build.sh $srcversion"
580 echo "for mksh $dstversion"
584 echo "$me: Unknown option '$i'!" >&2
588 echo "$me: Unknown option -'$last' '$i'!" >&2
593 if test -n "$last"; then
594 echo "$me: Option -'$last' not followed by argument!" >&2
598 test -z "$tfn" && if test $legacy = 0; then
603 if test -d $tfn || test -d $tfn.exe; then
604 echo "$me: Error: ./$tfn is a directory!" >&2
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
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"
613 if test $legacy = 0; then
614 check_categories="$check_categories shell:legacy-no int:32"
616 check_categories="$check_categories shell:legacy-yes"
617 add_cppflags -DMKSH_LEGACY_MODE
621 add_cppflags -DMKSH_EBCDIC
624 if test $textmode = 0; then
625 check_categories="$check_categories shell:textmode-no shell:binmode-yes"
627 check_categories="$check_categories shell:textmode-yes shell:binmode-no"
628 add_cppflags -DMKSH_WITH_TEXTMODE
631 if test x"$srcdir" = x"."; then
632 CPPFLAGS="-I. $CPPFLAGS"
634 CPPFLAGS="-I. -I'$srcdir' $CPPFLAGS"
636 test -n "$LDSTATIC" && if test -n "$LDFLAGS"; then
637 LDFLAGS="$LDFLAGS $LDSTATIC"
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
646 if test -z "$TARGET_OS"; then
647 echo "$me: Set TARGET_OS, your uname is broken!" >&2
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'
657 if test x"$TARGET_OS" = x"Android"; then
658 check_categories="$check_categories android"
663 if test x"$TARGET_OS" = x"Minix"; then
665 WARNING: additional checks before running Build.sh required!
666 You can avoid these by calling Build.sh correctly, see below.
668 cat >conftest.c <<'EOF'
669 #include <sys/types.h>
671 #ifdef _NETBSD_SOURCE
679 vv ']' "${CC-cc} -E $CFLAGS $CPPFLAGS $NOWARN conftest.c | grep ct= | tr -d \\\\015 >x"
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
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.
705 # Configuration depending on OS revision, on OSes that need them
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/'`
713 test x"$TARGET_OSREV" = x"" && TARGET_OSREV=`uname -r`
717 # Configuration depending on OS name
720 : "${HAVE_CAN_OTWO=0}"
721 add_cppflags -DMKSH_NO_SIGSETJMP
722 add_cppflags -DMKSH_TYPEDEF_SIG_ATOMIC_T=int
725 add_cppflags -D_ALL_SOURCE
726 : "${HAVE_SETLOCALE_CTYPE=0}"
731 oswarn="; it has minor issues"
734 oswarn="; you must recompile mksh with"
735 oswarn="$oswarn${nl}itself in a second stage"
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
745 : "${HAVE_SETLOCALE_CTYPE=0}"
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
755 : "${HAVE_SETLOCALE_CTYPE=0}"
758 add_cppflags -D_DARWIN_C_SOURCE
765 oswarn="; it has minor issues"
766 add_cppflags -D_GNU_SOURCE
767 : "${HAVE_SETLOCALE_CTYPE=0}"
772 *) add_cppflags -D_GNU_SOURCE ;;
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
781 *) add_cppflags -D_GNU_SOURCE ;;
783 add_cppflags -DSETUID_CAN_FAIL_WITH_EAGAIN
786 add_cppflags -DMKSH_ASSUME_UTF8
787 HAVE_ISSET_MKSH_ASSUME_UTF8=1
788 HAVE_ISOFF_MKSH_ASSUME_UTF8=0
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_CMDLINE_EDITING
800 add_cppflags -DMKSH__NO_SETEUGID
801 oswarn=' and will currently not work'
802 add_cppflags -DMKSH_UNEMPLOYED
803 add_cppflags -DMKSH_NOPROSPECTOFWORK
804 # these taken from Harvey-OS github and need re-checking
805 add_cppflags -D_setjmp=setjmp -D_longjmp=longjmp
806 : "${HAVE_CAN_NO_EH_FRAME=0}"
807 : "${HAVE_CAN_FNOSTRICTALIASING=0}"
808 : "${HAVE_CAN_FSTACKPROTECTORSTRONG=0}"
815 add_cppflags -D_ALL_SOURCE
817 : "${HAVE_SETLOCALE_CTYPE=0}"
820 : "${HAVE_SETLOCALE_CTYPE=0}"
825 *) add_cppflags -D_GNU_SOURCE ;;
827 add_cppflags -DSETUID_CAN_FAIL_WITH_EAGAIN
831 oswarn="; it has minor issues"
836 add_cppflags -DMKSH__NO_SETEUGID
837 add_cppflags -DMKSH_UNEMPLOYED
838 add_cppflags -D_MINIX_SOURCE
839 oldish_ed=no-stderr-ed # no /bin/ed, maybe see below
840 : "${HAVE_SETLOCALE_CTYPE=0}"
843 add_cppflags -DMKSH_UNEMPLOYED
844 add_cppflags -DMKSH_NO_LIMITS
845 add_cppflags -D_POSIX_SOURCE -D_POSIX_1_SOURCE=2 -D_MINIX
846 oldish_ed=no-stderr-ed # /usr/bin/ed(!) is broken
847 : "${HAVE_SETLOCALE_CTYPE=0}"
852 add_cppflags -DMKSH_ASSUME_UTF8=0
853 HAVE_ISSET_MKSH_ASSUME_UTF8=1
854 HAVE_ISOFF_MKSH_ASSUME_UTF8=1
855 # almost same as CYGWIN* (from RT|Chatzilla)
856 : "${HAVE_SETLOCALE_CTYPE=0}"
857 # broken on this OE (from ir0nh34d)
858 : "${HAVE_STDINT_H=0}"
863 add_cppflags -D_NEXT_SOURCE
864 add_cppflags -D_POSIX_SOURCE
867 add_cppflags -DMKSH_NO_SIGSETJMP
868 # NeXTstep cannot get a controlling tty
869 add_cppflags -DMKSH_UNEMPLOYED
870 case $TARGET_OSREV in
872 # OpenStep 4.2 is broken by default
873 oswarn="; it needs libposix.a"
879 add_cppflags -DMKSH_UNEMPLOYED
880 add_cppflags -DMKSH_NO_LIMITS
881 # but no idea what else could be needed
882 oswarn="; it has unknown issues"
885 : "${HAVE_SETLOCALE_CTYPE=0}"
888 add_cppflags -DMKSH_ASSUME_UTF8=0
889 HAVE_ISSET_MKSH_ASSUME_UTF8=1
890 HAVE_ISOFF_MKSH_ASSUME_UTF8=1
892 HAVE_MKNOD=0 # setmode() incompatible
893 oswarn="; it is being ported"
894 check_categories="$check_categories nosymlink"
898 add_cppflags -DMKSH_UNEMPLOYED
899 add_cppflags -DMKSH_NOPROSPECTOFWORK
900 add_cppflags -DMKSH_NO_LIMITS
901 add_cppflags -DMKSH_DOSPATH
902 if test $textmode = 0; then
904 y='standard OS/2 tools'
907 y='standard Unix mksh and other tools'
910 OS/2 Note: mksh can be built with or without 'textmode'.
911 Without 'textmode' it will behave like a standard Unix utility,
912 compatible to mksh on all other platforms, using only ASCII LF
913 (0x0A) as line ending character. This is supported by the mksh
915 With 'textmode', mksh will be modified to behave more like other
916 OS/2 utilities, supporting ASCII CR+LF (0x0D 0x0A) as line ending
917 at the cost of deviation from standard mksh. This is supported by
920 ] You are currently compiling with textmode ${x}abled, introducing
921 ] incompatibilities with $y.
925 add_cppflags -DMKSH_ASSUME_UTF8=0
926 HAVE_ISSET_MKSH_ASSUME_UTF8=1
927 HAVE_ISOFF_MKSH_ASSUME_UTF8=1
930 add_cppflags -DMKSH_FOR_Z_OS
931 add_cppflags -D_ALL_SOURCE
932 oswarn='; EBCDIC support is incomplete'
935 HAVE_SIG_T=0 # incompatible
936 add_cppflags -D_OSF_SOURCE
937 add_cppflags -D_POSIX_C_SOURCE=200112L
938 add_cppflags -D_XOPEN_SOURCE=600
939 add_cppflags -D_XOPEN_SOURCE_EXTENDED
940 : "${HAVE_SETLOCALE_CTYPE=0}"
943 add_cppflags -D_POSIX_SOURCE
944 add_cppflags -D_LIMITS_EXTENSION
945 add_cppflags -D_BSD_EXTENSION
946 add_cppflags -D_SUSV2_SOURCE
947 add_cppflags -DMKSH_ASSUME_UTF8
948 HAVE_ISSET_MKSH_ASSUME_UTF8=1
949 HAVE_ISOFF_MKSH_ASSUME_UTF8=0
950 add_cppflags -DMKSH_NO_CMDLINE_EDITING
951 add_cppflags -DMKSH__NO_SETEUGID
952 oswarn=' and will currently not work'
953 add_cppflags -DMKSH_UNEMPLOYED
954 # this is for detecting kencc
955 add_cppflags -DMKSH_MAYBE_KENCC
958 HAVE_SIG_T=0 # incompatible
959 oswarn=' and will currently not work'
960 : "${HAVE_SETLOCALE_CTYPE=0}"
963 add_cppflags -D__NO_EXT_QNX
964 add_cppflags -D__EXT_UNIX_MISC
965 case $TARGET_OSREV in
966 [012345].*|6.[0123].*|6.4.[01])
967 oldish_ed=no-stderr-ed # oldish /bin/ed is broken
970 : "${HAVE_SETLOCALE_CTYPE=0}"
973 case $TARGET_OSREV in
976 add_cppflags -DMKSH_UNEMPLOYED
982 oswarn='; this is an unknown version of'
983 oswarn="$oswarn$nl$TARGET_OS ${TARGET_OSREV}, please tell me what to do"
986 : "${HAVE_SYS_SIGLIST=0}${HAVE__SYS_SIGLIST=0}"
989 oswarn="; it has minor issues"
992 add_cppflags -D_BSD_SOURCE
993 add_cppflags -D__EXTENSIONS__
996 add_cppflags -D_GNU_SOURCE
997 add_cppflags -DMKSH_NO_SIGSUSPEND
998 oswarn=' and will currently not work'
1001 : "${CC=cc -YPOSIX}"
1002 add_cppflags -DMKSH_TYPEDEF_SSIZE_T=int
1003 : "${HAVE_SETLOCALE_CTYPE=0}"
1007 : "${HAVE_SYS_SIGLIST=0}${HAVE__SYS_SIGLIST=0}"
1013 oswarn="; it will compile, but the target"
1014 oswarn="$oswarn${nl}platform itself is very flakey/unreliable"
1015 : "${HAVE_SETLOCALE_CTYPE=0}"
1018 # generic target for SVR4 Unix with uname -s = uname -n
1019 # this duplicates the * target below
1020 oswarn='; it may or may not work'
1021 test x"$TARGET_OSREV" = x"" && TARGET_OSREV=`uname -r`
1024 oswarn='; it may or may not work'
1025 test x"$TARGET_OSREV" = x"" && TARGET_OSREV=`uname -r`
1031 : "${AWK=awk}${CC=cc}${NROFF=nroff}${SIZE=size}"
1032 test 0 = $r && echo | $NROFF -v 2>&1 | grep GNU >/dev/null 2>&1 && \
1033 echo | $NROFF -c >/dev/null 2>&1 && NROFF="$NROFF -c"
1035 # this aids me in tracing FTBFSen without access to the buildd
1036 $e "Hi from$ao $bi$srcversion$ao on:"
1039 vv '|' "oslevel >&2"
1040 vv '|' "uname -a >&2"
1043 vv '|' "hwprefs machine_type os_type os_class >&2"
1044 vv '|' "sw_vers >&2"
1045 vv '|' "system_profiler SPSoftwareDataType SPHardwareDataType >&2"
1046 vv '|' "/bin/sh --version >&2"
1047 vv '|' "xcodebuild -version >&2"
1048 vv '|' "uname -a >&2"
1049 vv '|' "sysctl kern.version hw.machine hw.model hw.memsize hw.availcpu hw.cpufrequency hw.byteorder hw.cpu64bit_capable >&2"
1052 vv '|' "uname -a >&2"
1053 vv '|' "hinv -v >&2"
1056 vv '|' "uname -a >&2"
1057 vv '|' "/usr/sbin/sizer -v >&2"
1059 SCO_SV|UnixWare|UNIX_SV)
1060 vv '|' "uname -a >&2"
1061 vv '|' "uname -X >&2"
1064 vv '|' "uname -a >&2"
1067 test -z "$oswarn" || echo >&2 "
1068 Warning: mksh has not yet been ported to or tested on your
1069 operating system '$TARGET_OS'$oswarn. If you can provide
1070 a shell account to the developer, this may improve; please
1071 drop us a success or failure notice or even send in diffs.
1073 $e "$bi$me: Building the MirBSD Korn Shell$ao $ui$dstversion$ao on $TARGET_OS ${TARGET_OSREV}..."
1076 # Start of mirtoconf checks
1078 $e $bi$me: Scanning for functions... please ignore any errors.$ao
1081 # Compiler: which one?
1084 # - ICC defines __GNUC__ too
1085 # - GCC defines __hpux too
1086 # - LLVM+clang defines __GNUC__ too
1087 # - nwcc defines __GNUC__ too
1089 $e ... which compiler type seems to be used
1090 cat >conftest.c <<'EOF'
1092 #if defined(__ICC) || defined(__INTEL_COMPILER)
1094 #elif defined(__xlC__) || defined(__IBMC__)
1096 #elif defined(__SUNPRO_C)
1098 #elif defined(__ACK__)
1100 #elif defined(__BORLANDC__)
1102 #elif defined(__WATCOMC__)
1104 #elif defined(__MWERKS__)
1106 #elif defined(__HP_cc)
1108 #elif defined(__DECC) || (defined(__osf__) && !defined(__GNUC__))
1110 #elif defined(__PGI)
1112 #elif defined(__DMC__)
1114 #elif defined(_MSC_VER)
1116 #elif defined(__ADSPBLACKFIN__) || defined(__ADSPTS__) || defined(__ADSP21000__)
1118 #elif defined(__IAR_SYSTEMS_ICC__)
1122 #elif defined(__PCC__)
1124 #elif defined(__TenDRA__)
1126 #elif defined(__TINYC__)
1128 #elif defined(__llvm__) && defined(__clang__)
1130 #elif defined(__NWCC__)
1132 #elif defined(__GNUC__)
1134 #elif defined(_COMPILER_VERSION)
1136 #elif defined(__sgi)
1138 #elif defined(__hpux) || defined(__hpua)
1140 #elif defined(__ultrix)
1142 #elif defined(__USLC__)
1144 #elif defined(__LCC__)
1146 #elif defined(MKSH_MAYBE_KENCC)
1147 /* and none of the above matches */
1154 #if defined(__KLIBC__) && !defined(__OS2__)
1163 vv ']' "$CPP $CFLAGS $CPPFLAGS $NOWARN conftest.c | \
1164 sed -n '/^ *[ce]t *= */s/^ *\([ce]t\) *= */\1=/p' | tr -d \\\\015 >x"
1168 cat >conftest.c <<'EOF'
1170 int main(void) { return (isatty(0)); }
1174 # work around "the famous ACK const bug"
1175 CPPFLAGS="-Dconst= $CPPFLAGS"
1178 echo >&2 'Warning: Analog Devices C++ compiler for Blackfin, TigerSHARC
1179 and SHARC (21000) DSPs detected. This compiler has not yet
1180 been tested for compatibility with mksh. Continue at your
1181 own risk, please report success/failure to the developers.'
1184 echo >&2 "Warning: Borland C++ Builder detected. This compiler might
1185 produce broken executables. Continue at your own risk,
1186 please report success/failure to the developers."
1189 # does not work with current "ccc" compiler driver
1190 vv '|' "$CC $CFLAGS $CPPFLAGS $LDFLAGS $NOWARN $LIBS -version"
1191 # one of these two works, for now
1192 vv '|' "${CLANG-clang} -version"
1193 vv '|' "${CLANG-clang} --version"
1194 # ensure compiler and linker are in sync unless overridden
1195 case $CCC_CC:$CCC_LD in
1197 *:) CCC_LD=$CCC_CC; export CCC_LD ;;
1199 : "${HAVE_STRING_POOLING=i1}"
1202 vv '|' "$CC $CFLAGS $CPPFLAGS $LDFLAGS $NOWARN $LIBS -V"
1203 vv '|' "$CC $CFLAGS $CPPFLAGS $LDFLAGS $NOWARN -Wl,-V conftest.c $LIBS"
1206 echo >&2 "Warning: Digital Mars Compiler detected. When running under"
1207 echo >&2 " UWIN, mksh tends to be unstable due to the limitations"
1208 echo >&2 " of this platform. Continue at your own risk,"
1209 echo >&2 " please report success/failure to the developers."
1212 vv '|' "$CC $CFLAGS $CPPFLAGS $LDFLAGS $NOWARN -v conftest.c $LIBS"
1213 vv '|' 'echo `$CC $CFLAGS $CPPFLAGS $LDFLAGS $NOWARN $LIBS \
1214 -dumpmachine` gcc`$CC $CFLAGS $CPPFLAGS $LDFLAGS $NOWARN \
1215 $LIBS -dumpversion`'
1216 : "${HAVE_STRING_POOLING=i2}"
1219 vv '|' "$CC $CFLAGS $CPPFLAGS $LDFLAGS $NOWARN -V conftest.c $LIBS"
1222 echo >&2 'Warning: IAR Systems (http://www.iar.com) compiler for embedded
1223 systems detected. This unsupported compiler has not yet
1224 been tested for compatibility with mksh. Continue at your
1225 own risk, please report success/failure to the developers.'
1228 vv '|' "$CC $CFLAGS $CPPFLAGS $LDFLAGS $NOWARN $LIBS -V"
1231 vv '|' "$CC $CFLAGS $CPPFLAGS $LDFLAGS $NOWARN -v conftest.c $LIBS"
1234 vv '|' "$CC $CFLAGS $CPPFLAGS $LDFLAGS $NOWARN -v conftest.c $LIBS"
1235 add_cppflags -D__inline__=__inline
1238 echo >&2 'Warning: Metrowerks C compiler detected. This has not yet
1239 been tested for compatibility with mksh. Continue at your
1240 own risk, please report success/failure to the developers.'
1243 vv '|' "$CC $CFLAGS $CPPFLAGS $LDFLAGS $NOWARN $LIBS -version"
1246 ccpr= # errorlevels are not reliable
1249 if [[ -n $C89_COMPILER ]]; then
1250 C89_COMPILER=`ntpath2posix -c "$C89_COMPILER"`
1254 if [[ -n $C89_LINKER ]]; then
1255 C89_LINKER=`ntpath2posix -c "$C89_LINKER"`
1259 vv '|' "$C89_COMPILER /HELP >&2"
1260 vv '|' "$C89_LINKER /LINK >&2"
1265 vv '|' "$CC $CFLAGS $CPPFLAGS $LDFLAGS $NOWARN $LIBS -version"
1268 vv '|' "$CC $CFLAGS $CPPFLAGS $LDFLAGS $NOWARN $LIBS -v"
1271 echo >&2 'Warning: PGI detected. This unknown compiler has not yet
1272 been tested for compatibility with mksh. Continue at your
1273 own risk, please report success/failure to the developers.'
1276 echo >&2 'Warning: sdcc (http://sdcc.sourceforge.net), the small devices
1277 C compiler for embedded systems detected. This has not yet
1278 been tested for compatibility with mksh. Continue at your
1279 own risk, please report success/failure to the developers.'
1282 vv '|' "$CC $CFLAGS $CPPFLAGS $LDFLAGS $NOWARN -V conftest.c $LIBS"
1285 vv '|' "$CC $CFLAGS $CPPFLAGS $LDFLAGS $NOWARN $LIBS -v"
1288 vv '|' "$CC $CFLAGS $CPPFLAGS $LDFLAGS $NOWARN $LIBS -V 2>&1 | \
1289 grep -F -i -e version -e release"
1292 vv '|' "$CC $CFLAGS $CPPFLAGS $LDFLAGS $NOWARN $LIBS -V"
1293 vv '|' "$CC $CFLAGS $CPPFLAGS $LDFLAGS $NOWARN -Wl,-V conftest.c $LIBS"
1296 case $TARGET_OS:$TARGET_OSREV in
1300 : "${HAVE_CAN_OTWO=0}${HAVE_CAN_OPTIMISE=0}"
1303 vv '|' "$CC $CFLAGS $CPPFLAGS $LDFLAGS $NOWARN -V conftest.c $LIBS"
1306 vv '|' "$CC $CFLAGS $CPPFLAGS $LDFLAGS $NOWARN -v conftest.c $LIBS"
1309 vv '|' "$CC $CFLAGS $CPPFLAGS $LDFLAGS $NOWARN $LIBS -qversion"
1310 vv '|' "$CC $CFLAGS $CPPFLAGS $LDFLAGS $NOWARN $LIBS -qversion=verbose"
1314 test x"$ct" = x"untested" && $e "!!! detecting preprocessor failed"
1317 vv '|' "$CC $CFLAGS $CPPFLAGS $LDFLAGS $NOWARN -v conftest.c $LIBS"
1318 vv '|' "$CC $CFLAGS $CPPFLAGS $LDFLAGS $NOWARN -V conftest.c $LIBS"
1323 vv '|' "llc -version"
1329 add_cppflags -DMKSH_NO_LIMITS
1332 # nothing special detected, don’t worry
1339 $e "$bi==> which compiler type seems to be used...$ao $ui$ct$etd$ao"
1340 rmf conftest.c conftest.o conftest a.out* a.exe* conftest.exe* vv.out
1343 # Compiler: works as-is, with -Wno-error and -Werror
1348 ac_flags 0 compiler_works '' 'if the compiler works'
1349 test 1 = $HAVE_CAN_COMPILER_WORKS || exit 1
1350 HAVE_COMPILER_KNOWN=0
1351 test $ct = unknown || HAVE_COMPILER_KNOWN=1
1352 if ac_ifcpp 'if 0' compiler_fails '' \
1353 'if the compiler does not fail correctly'; then
1355 : "${HAVE_CAN_DELEXE=x}"
1358 CFLAGS="$CFLAGS ${ccpl}-non_shared"
1359 ac_testn can_delexe compiler_fails 0 'for the -non_shared linker option' <<-EOF
1361 int main(void) { return (isatty(0)); }
1365 CFLAGS="$CFLAGS ${ccpl}/DELEXECUTABLE"
1366 ac_testn can_delexe compiler_fails 0 'for the /DELEXECUTABLE linker option' <<-EOF
1368 int main(void) { return (isatty(0)); }
1375 test 1 = $HAVE_CAN_DELEXE || CFLAGS=$save_CFLAGS
1376 ac_testn compiler_still_fails '' 'if the compiler still does not fail correctly' <<-EOF
1378 test 1 = $HAVE_COMPILER_STILL_FAILS && exit 1
1380 if ac_ifcpp 'ifdef __TINYC__' couldbe_tcc '!' compiler_known 0 \
1381 'if this could be tcc'; then
1383 CPP='cpp -D__TINYC__'
1384 HAVE_COMPILER_KNOWN=1
1389 save_NOWARN="${ccpc}-w"
1393 # -msg_* flags not used yet, or is -w2 correct?
1396 save_NOWARN="${ccpc}-w"
1409 DOWARN="-diag_error 1-10000"
1412 save_NOWARN="${ccpc}/w"
1416 test x"$save_NOWARN" = x"" && save_NOWARN='-errwarn=%none'
1417 ac_flags 0 errwarnnone "$save_NOWARN"
1418 test 1 = $HAVE_CAN_ERRWARNNONE || save_NOWARN=
1419 ac_flags 0 errwarnall "-errwarn=%all"
1420 test 1 = $HAVE_CAN_ERRWARNALL && DOWARN="-errwarn=%all"
1436 save_NOWARN=-qflag=e
1440 save_NOWARN=-qflag=i:e
1446 test x"$save_NOWARN" = x"" && save_NOWARN=-Wno-error
1447 ac_flags 0 wnoerror "$save_NOWARN"
1448 test 1 = $HAVE_CAN_WNOERROR || save_NOWARN=
1449 ac_flags 0 werror -Werror
1450 test 1 = $HAVE_CAN_WERROR && DOWARN=-Werror
1451 test $ct = icc && DOWARN="$DOWARN -wd1419"
1457 # Compiler: extra flags (-O2 -f* -W* etc.)
1459 i=`echo :"$orig_CFLAGS" | sed 's/^://' | tr -c -d $alll$allu$alln`
1460 # optimisation: only if orig_CFLAGS is empty
1461 test x"$i" = x"" && case $ct in
1468 # no special optimisation
1473 int main(void) { return (isatty(0)); }
1474 #define __IDSTRING_CONCAT(l,p) __LINTED__ ## l ## _ ## p
1475 #define __IDSTRING_EXPAND(l,p) __IDSTRING_CONCAT(l,p)
1476 #define pad void __IDSTRING_EXPAND(__LINE__,x)(void) { }
1478 yes pad | head -n 256 >>x
1479 ac_flags - 1 otwo -xO2 <x
1483 ac_flags 1 othree "-O3 -qstrict"
1484 test 1 = $HAVE_CAN_OTHREE || ac_flags 1 otwo -O2
1488 test 1 = $HAVE_CAN_OTWO || ac_flags 1 optimise -O
1491 # other flags: just add them if they are supported
1495 ac_flags 1 strpool "${ccpc}-d" 'if string pooling can be enabled'
1501 ac_flags 0 verb -verbose
1502 ac_flags 1 rodata -readonly_strings
1505 ac_flags 1 decl "${ccpc}-r" 'for strict prototype checks'
1506 ac_flags 1 schk "${ccpc}-s" 'for stack overflow checking'
1509 # The following tests run with -Werror (gcc only) if possible
1510 NOWARN=$DOWARN; phase=u
1511 ac_flags 1 wnodeprecateddecls -Wno-deprecated-declarations
1512 # mksh is not written in CFrustFrust!
1513 ac_flags 1 no_eh_frame -fno-asynchronous-unwind-tables
1514 ac_flags 1 fnostrictaliasing -fno-strict-aliasing
1515 ac_flags 1 fstackprotectorstrong -fstack-protector-strong
1516 test 1 = $HAVE_CAN_FSTACKPROTECTORSTRONG || \
1517 ac_flags 1 fstackprotectorall -fstack-protector-all
1518 test $cm = dragonegg && case " $CC $CFLAGS $LDFLAGS " in
1519 *\ -fplugin=*dragonegg*) ;;
1520 *) ac_flags 1 fplugin_dragonegg -fplugin=dragonegg ;;
1529 checks='1 2 3 4 5 6 7 8'
1535 test $fv = 1 || for what in $checks; do
1536 test $fv = 1 && break
1538 1) t_cflags='-flto=jobserver'
1539 t_ldflags='-fuse-linker-plugin'
1540 t_use=1 t_name=fltojs_lp ;;
1541 2) t_cflags='-flto=jobserver' t_ldflags=''
1542 t_use=1 t_name=fltojs_nn ;;
1543 3) t_cflags='-flto=jobserver'
1544 t_ldflags='-fno-use-linker-plugin -fwhole-program'
1545 t_use=1 t_name=fltojs_np ;;
1547 t_ldflags='-fuse-linker-plugin'
1548 t_use=1 t_name=fltons_lp ;;
1549 5) t_cflags='-flto' t_ldflags=''
1550 t_use=1 t_name=fltons_nn ;;
1552 t_ldflags='-fno-use-linker-plugin -fwhole-program'
1553 t_use=1 t_name=fltons_np ;;
1554 7) t_cflags='-fwhole-program --combine' t_ldflags=''
1555 t_use=0 t_name=combine cm=combine ;;
1556 8) fv=1 cm=normal ;;
1558 test $fv = 1 && break
1559 ac_flags $t_use $t_name "$t_cflags" \
1560 "if gcc supports $t_cflags $t_ldflags" "$t_ldflags"
1562 ac_flags 1 data_abi_align -malign-data=abi
1567 # probably not needed
1568 #ac_flags 1 agcc -Agcc 'for support of GCC extensions'
1572 ac_flags 1 fnobuiltinsetmode -fno-builtin-setmode
1573 ac_flags 1 fnostrictaliasing -fno-strict-aliasing
1574 ac_flags 1 fstacksecuritycheck -fstack-security-check
1578 ac_flags 1 fullwarn -fullwarn 'for remark output support'
1581 ac_flags 1 strpool "${ccpc}/GF" 'if string pooling can be enabled'
1582 echo 'int main(void) { char test[64] = ""; return (*test); }' >x
1583 ac_flags - 1 stackon "${ccpc}/GZ" 'if stack checks can be enabled' <x
1584 ac_flags - 1 stckall "${ccpc}/Ge" 'stack checks for all functions' <x
1585 ac_flags - 1 secuchk "${ccpc}/GS" 'for compiler security checks' <x
1587 ac_flags 1 wall "${ccpc}/Wall" 'to enable all warnings'
1588 ac_flags 1 wp64 "${ccpc}/Wp64" 'to enable 64-bit warnings'
1591 #broken# ac_flags 1 ssp -stackprotect
1595 ac_flags 1 fstackprotectorall -fstack-protector-all
1601 ac_flags 1 ipo -xipo 'for cross-module optimisation'
1605 : #broken# ac_flags 1 boundschk -b
1608 ac_flags 0 ysystem -Ysystem
1609 test 1 = $HAVE_CAN_YSYSTEM && CPPFLAGS="-Ysystem $CPPFLAGS"
1610 ac_flags 1 extansi -Xa
1615 # On IBM z/OS, the following are warnings by default:
1616 # CCN3296: #include file <foo.h> not found.
1617 # CCN3944: Attribute "__foo__" is not supported and is ignored.
1618 # CCN3963: The attribute "foo" is not a valid variable attribute and is ignored.
1619 ac_flags 1 halton '-qhaltonmsg=CCN3296 -qhaltonmsg=CCN3944 -qhaltonmsg=CCN3963'
1620 # CCN3290: Unknown macro name FOO on #undef directive.
1621 # CCN4108: The use of keyword '__attribute__' is non-portable.
1622 ac_flags 1 supprss '-qsuppress=CCN3290 -qsuppress=CCN4108'
1625 ac_flags 1 rodata '-qro -qroconst -qroptr'
1626 ac_flags 1 rtcheck -qcheck=all
1627 #ac_flags 1 rtchkc -qextchk # reported broken
1628 ac_flags 1 wformat '-qformat=all -qformat=nozln'
1631 #ac_flags 1 wp64 -qwarn64 # too verbose for now
1634 # flags common to a subset of compilers (run with -Werror on gcc)
1635 if test 1 = $i; then
1636 ac_flags 1 wall -Wall
1637 ac_flags 1 fwrapv -fwrapv
1640 # “on demand” means: GCC version >= 4
1641 fd='if to rely on compiler for string pooling'
1642 ac_cache string_pooling || case $HAVE_STRING_POOLING in
1643 2) fx=' (on demand, cached)' ;;
1645 i2) fv=2; fx=' (on demand)' ;;
1648 test x"$HAVE_STRING_POOLING" = x"0" || ac_cppflags
1651 # The following tests run with -Werror or similar (all compilers) if possible
1653 test $ct = pcc && phase=u
1656 # Compiler: check for stuff that only generates warnings
1658 ac_test attribute_bounded '' 'for __attribute__((__bounded__))' <<-'EOF'
1659 #if defined(__TenDRA__) || (defined(__GNUC__) && (__GNUC__ < 2))
1660 extern int thiswillneverbedefinedIhope(void);
1661 /* force a failure: TenDRA and gcc 1.42 have false positive here */
1662 int main(void) { return (thiswillneverbedefinedIhope()); }
1665 #undef __attribute__
1666 int xcopy(const void *, void *, size_t)
1667 __attribute__((__bounded__(__buffer__, 1, 3)))
1668 __attribute__((__bounded__(__buffer__, 2, 3)));
1669 int main(int ac, char *av[]) { return (xcopy(av[0], av[--ac], 1)); }
1670 int xcopy(const void *s, void *d, size_t n) {
1672 * if memmove does not exist, we are not on a system
1673 * with GCC with __bounded__ attribute either so poo
1675 memmove(d, s, n); return ((int)n);
1679 ac_test attribute_format '' 'for __attribute__((__format__))' <<-'EOF'
1680 #if defined(__TenDRA__) || (defined(__GNUC__) && (__GNUC__ < 2))
1681 extern int thiswillneverbedefinedIhope(void);
1682 /* force a failure: TenDRA and gcc 1.42 have false positive here */
1683 int main(void) { return (thiswillneverbedefinedIhope()); }
1685 #define fprintf printfoo
1687 #undef __attribute__
1689 extern int fprintf(FILE *, const char *format, ...)
1690 __attribute__((__format__(__printf__, 2, 3)));
1691 int main(int ac, char **av) { return (fprintf(stderr, "%s%d", *av, ac)); }
1694 ac_test attribute_noreturn '' 'for __attribute__((__noreturn__))' <<-'EOF'
1695 #if defined(__TenDRA__) || (defined(__GNUC__) && (__GNUC__ < 2))
1696 extern int thiswillneverbedefinedIhope(void);
1697 /* force a failure: TenDRA and gcc 1.42 have false positive here */
1698 int main(void) { return (thiswillneverbedefinedIhope()); }
1701 #undef __attribute__
1702 void fnord(void) __attribute__((__noreturn__));
1703 int main(void) { fnord(); }
1704 void fnord(void) { exit(0); }
1707 ac_test attribute_pure '' 'for __attribute__((__pure__))' <<-'EOF'
1708 #if defined(__TenDRA__) || (defined(__GNUC__) && (__GNUC__ < 2))
1709 extern int thiswillneverbedefinedIhope(void);
1710 /* force a failure: TenDRA and gcc 1.42 have false positive here */
1711 int main(void) { return (thiswillneverbedefinedIhope()); }
1714 #undef __attribute__
1715 int foo(const char *) __attribute__((__pure__));
1716 int main(int ac, char **av) { return (foo(av[ac - 1]) + isatty(0)); }
1717 int foo(const char *s) { return ((int)s[0]); }
1720 ac_test attribute_unused '' 'for __attribute__((__unused__))' <<-'EOF'
1721 #if defined(__TenDRA__) || (defined(__GNUC__) && (__GNUC__ < 2))
1722 extern int thiswillneverbedefinedIhope(void);
1723 /* force a failure: TenDRA and gcc 1.42 have false positive here */
1724 int main(void) { return (thiswillneverbedefinedIhope()); }
1727 #undef __attribute__
1728 int main(int ac __attribute__((__unused__)), char **av
1729 __attribute__((__unused__))) { return (isatty(0)); }
1732 ac_test attribute_used '' 'for __attribute__((__used__))' <<-'EOF'
1733 #if defined(__TenDRA__) || (defined(__GNUC__) && (__GNUC__ < 2))
1734 extern int thiswillneverbedefinedIhope(void);
1735 /* force a failure: TenDRA and gcc 1.42 have false positive here */
1736 int main(void) { return (thiswillneverbedefinedIhope()); }
1739 #undef __attribute__
1740 static const char fnord[] __attribute__((__used__)) = "42";
1741 int main(void) { return (isatty(0)); }
1745 # End of tests run with -Werror
1750 # mksh: flavours (full/small mksh, omit certain stuff)
1752 if ac_ifcpp 'ifdef MKSH_SMALL' isset_MKSH_SMALL '' \
1753 "if a reduced-feature mksh is requested"; then
1755 : "${HAVE_PERSISTENT_HISTORY=0}"
1756 check_categories="$check_categories smksh"
1758 ac_ifcpp 'if defined(MKSH_BINSHPOSIX) || defined(MKSH_BINSHREDUCED)' \
1759 isset_MKSH_BINSH '' 'if invoking as sh should be handled specially' && \
1760 check_categories="$check_categories binsh"
1761 ac_ifcpp 'ifdef MKSH_UNEMPLOYED' isset_MKSH_UNEMPLOYED '' \
1762 "if mksh will be built without job control" && \
1763 check_categories="$check_categories arge"
1764 ac_ifcpp 'ifdef MKSH_NOPROSPECTOFWORK' isset_MKSH_NOPROSPECTOFWORK '' \
1765 "if mksh will be built without job signals" && \
1766 check_categories="$check_categories arge nojsig"
1767 ac_ifcpp 'ifdef MKSH_ASSUME_UTF8' isset_MKSH_ASSUME_UTF8 '' \
1768 'if the default UTF-8 mode is specified' && : "${HAVE_SETLOCALE_CTYPE=0}"
1769 ac_ifcpp 'if !MKSH_ASSUME_UTF8' isoff_MKSH_ASSUME_UTF8 \
1770 isset_MKSH_ASSUME_UTF8 0 \
1771 'if the default UTF-8 mode is disabled' && \
1772 check_categories="$check_categories noutf8"
1773 #ac_ifcpp 'ifdef MKSH_DISABLE_DEPRECATED' isset_MKSH_DISABLE_DEPRECATED '' \
1774 # "if deprecated features are to be omitted" && \
1775 # check_categories="$check_categories nodeprecated"
1776 #ac_ifcpp 'ifdef MKSH_DISABLE_EXPERIMENTAL' isset_MKSH_DISABLE_EXPERIMENTAL '' \
1777 # "if experimental features are to be omitted" && \
1778 # check_categories="$check_categories noexperimental"
1779 ac_ifcpp 'ifdef MKSH_MIDNIGHTBSD01ASH_COMPAT' isset_MKSH_MIDNIGHTBSD01ASH_COMPAT '' \
1780 'if the MidnightBSD 0.1 ash compatibility mode is requested' && \
1781 check_categories="$check_categories mnbsdash"
1784 # Environment: headers
1786 ac_header sys/time.h sys/types.h
1787 ac_header time.h sys/types.h
1788 test "11" = "$HAVE_SYS_TIME_H$HAVE_TIME_H" || HAVE_BOTH_TIME_H=0
1789 ac_test both_time_h '' 'whether <sys/time.h> and <time.h> can both be included' <<-'EOF'
1790 #include <sys/types.h>
1791 #include <sys/time.h>
1794 int main(void) { struct tm tm; return ((int)sizeof(tm) + isatty(0)); }
1796 ac_header sys/bsdtypes.h
1797 ac_header sys/file.h sys/types.h
1798 ac_header sys/mkdev.h sys/types.h
1799 ac_header sys/mman.h sys/types.h
1800 ac_header sys/param.h
1801 ac_header sys/resource.h sys/types.h _time
1802 ac_header sys/select.h sys/types.h
1803 ac_header sys/sysmacros.h
1805 ac_header grp.h sys/types.h
1808 ac_header libutil.h sys/types.h
1810 ac_header stdint.h stdarg.h
1811 # include strings.h only if compatible with string.h
1812 ac_header strings.h sys/types.h string.h
1814 ac_header ulimit.h sys/types.h
1818 # Environment: definitions
1820 echo '#include <sys/types.h>
1822 /* check that off_t can represent 2^63-1 correctly, thx FSF */
1823 #define LARGE_OFF_T ((((off_t)1 << 31) << 31) - 1 + (((off_t)1 << 31) << 31))
1824 int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 &&
1825 LARGE_OFF_T % 2147483647 == 1) ? 1 : -1];
1826 int main(void) { return (isatty(0)); }' >lft.c
1827 ac_testn can_lfs '' "for large file support" <lft.c
1828 save_CPPFLAGS=$CPPFLAGS
1829 add_cppflags -D_FILE_OFFSET_BITS=64
1830 ac_testn can_lfs_sus '!' can_lfs 0 "... with -D_FILE_OFFSET_BITS=64" <lft.c
1831 if test 0 = $HAVE_CAN_LFS_SUS; then
1832 CPPFLAGS=$save_CPPFLAGS
1833 add_cppflags -D_LARGE_FILES=1
1834 ac_testn can_lfs_aix '!' can_lfs 0 "... with -D_LARGE_FILES=1" <lft.c
1835 test 1 = $HAVE_CAN_LFS_AIX || CPPFLAGS=$save_CPPFLAGS
1838 rmf lft* # end of large file support test
1841 # Environment: types
1843 ac_test can_inttypes '!' stdint_h 1 "for standard 32-bit integer types" <<-'EOF'
1844 #include <sys/types.h>
1846 int main(int ac, char **av) { return ((uint32_t)(size_t)*av + (int32_t)ac); }
1848 ac_test can_ucbints '!' can_inttypes 1 "for UCB 32-bit integer types" <<-'EOF'
1849 #include <sys/types.h>
1851 int main(int ac, char **av) { return ((u_int32_t)(size_t)*av + (int32_t)ac); }
1853 ac_test can_int8type '!' stdint_h 1 "for standard 8-bit integer type" <<-'EOF'
1854 #include <sys/types.h>
1856 int main(int ac, char **av) { return ((uint8_t)(size_t)av[ac]); }
1858 ac_test can_ucbint8 '!' can_int8type 1 "for UCB 8-bit integer type" <<-'EOF'
1859 #include <sys/types.h>
1861 int main(int ac, char **av) { return ((u_int8_t)(size_t)av[ac]); }
1864 ac_test rlim_t <<-'EOF'
1865 #include <sys/types.h>
1866 #if HAVE_BOTH_TIME_H
1867 #include <sys/time.h>
1869 #elif HAVE_SYS_TIME_H
1870 #include <sys/time.h>
1874 #if HAVE_SYS_RESOURCE_H
1875 #include <sys/resource.h>
1878 int main(void) { return (((int)(rlim_t)0) + isatty(0)); }
1881 # only testn: added later below
1882 ac_testn sig_t <<-'EOF'
1883 #include <sys/types.h>
1886 volatile sig_t foo = (sig_t)0;
1887 int main(void) { return (foo == (sig_t)0); }
1890 ac_testn sighandler_t '!' sig_t 0 <<-'EOF'
1891 #include <sys/types.h>
1894 volatile sighandler_t foo = (sighandler_t)0;
1895 int main(void) { return (foo == (sighandler_t)0); }
1897 if test 1 = $HAVE_SIGHANDLER_T; then
1898 add_cppflags -Dsig_t=sighandler_t
1902 ac_testn __sighandler_t '!' sig_t 0 <<-'EOF'
1903 #include <sys/types.h>
1906 volatile __sighandler_t foo = (__sighandler_t)0;
1907 int main(void) { return (foo == (__sighandler_t)0); }
1909 if test 1 = $HAVE___SIGHANDLER_T; then
1910 add_cppflags -Dsig_t=__sighandler_t
1914 test 1 = $HAVE_SIG_T || add_cppflags -Dsig_t=nosig_t
1918 # check whether whatever we use for the final link will succeed
1920 if test $cm = makefile; then
1924 ac_testinit link_works '' 'checking if the final link command may succeed'
1926 cat >conftest.c <<-EOF
1928 #define MKSH_INCLUDES_ONLY
1930 __RCSID("$srcversion");
1931 int main(void) { printf("Hello, World!\\n"); return (isatty(0)); }
1935 v "$CC $CFLAGS $CPPFLAGS $NOWARN -emit-llvm -c conftest.c" || fv=0
1937 test $fv = 0 || v "llvm-link -o - conftest.o | opt $optflags | llc -o $tfn.s" || fv=0
1938 test $fv = 0 || v "$CC $CFLAGS $LDFLAGS -o $tcfn $tfn.s $LIBS $ccpr"
1941 v "$CC $CFLAGS $CPPFLAGS $NOWARN -S -flto conftest.c" || fv=0
1942 test $fv = 0 || v "mv conftest.s conftest.ll"
1943 test $fv = 0 || v "llvm-as conftest.ll" || fv=0
1945 test $fv = 0 || v "llvm-link -o - conftest.bc | opt $optflags | llc -o $tfn.s" || fv=0
1946 test $fv = 0 || v "$CC $CFLAGS $LDFLAGS -o $tcfn $tfn.s $LIBS $ccpr"
1949 v "$CC $CFLAGS $CPPFLAGS $LDFLAGS -fwhole-program --combine $NOWARN -o $tcfn conftest.c $LIBS $ccpr"
1953 v "$CC $CFLAGS $CPPFLAGS $NOWARN -c conftest.c" || fv=0
1954 test $fv = 0 || v "$CC $CFLAGS $LDFLAGS -o $tcfn conftest.o $LIBS $ccpr"
1957 test -f $tcfn || fv=0
1959 test $fv = 1 || exit 1
1963 # Environment: errors and signals
1965 test x"NetBSD" = x"$TARGET_OS" && $e Ignore the compatibility warning.
1967 ac_testn sys_errlist '' "the sys_errlist[] array and sys_nerr" <<-'EOF'
1968 extern const int sys_nerr;
1969 extern const char * const sys_errlist[];
1970 extern int isatty(int);
1971 int main(void) { return (*sys_errlist[sys_nerr - 1] + isatty(0)); }
1973 ac_testn _sys_errlist '!' sys_errlist 0 "the _sys_errlist[] array and _sys_nerr" <<-'EOF'
1974 extern const int _sys_nerr;
1975 extern const char * const _sys_errlist[];
1976 extern int isatty(int);
1977 int main(void) { return (*_sys_errlist[_sys_nerr - 1] + isatty(0)); }
1979 if test 1 = "$HAVE__SYS_ERRLIST"; then
1980 add_cppflags -Dsys_nerr=_sys_nerr
1981 add_cppflags -Dsys_errlist=_sys_errlist
1984 ac_cppflags SYS_ERRLIST
1986 for what in name list; do
1988 ac_testn sys_sig$what '' "the sys_sig${what}[] array" <<-EOF
1989 extern const char * const sys_sig${what}[];
1990 extern int isatty(int);
1991 int main(void) { return (sys_sig${what}[0][0] + isatty(0)); }
1993 ac_testn _sys_sig$what '!' sys_sig$what 0 "the _sys_sig${what}[] array" <<-EOF
1994 extern const char * const _sys_sig${what}[];
1995 extern int isatty(int);
1996 int main(void) { return (_sys_sig${what}[0][0] + isatty(0)); }
1998 eval uwhat_v=\$HAVE__SYS_SIG$uwhat
1999 if test 1 = "$uwhat_v"; then
2000 add_cppflags -Dsys_sig$what=_sys_sig$what
2001 eval HAVE_SYS_SIG$uwhat=1
2003 ac_cppflags SYS_SIG$uwhat
2007 # Environment: library functions
2009 ac_test flock <<-'EOF'
2010 #include <sys/types.h>
2014 #include <sys/file.h>
2016 int main(void) { return (flock(0, LOCK_EX | LOCK_UN)); }
2019 ac_test lock_fcntl '!' flock 1 'whether we can lock files with fcntl' <<-'EOF'
2024 lks.l_type = F_WRLCK | F_UNLCK;
2025 return (fcntl(0, F_SETLKW, &lks));
2029 ac_test getrusage <<-'EOF'
2030 #define MKSH_INCLUDES_ONLY
2034 return (getrusage(RUSAGE_SELF, &ru) +
2035 getrusage(RUSAGE_CHILDREN, &ru));
2039 ac_test getsid <<-'EOF'
2041 int main(void) { return ((int)getsid(0)); }
2044 ac_test gettimeofday <<-'EOF'
2045 #define MKSH_INCLUDES_ONLY
2047 int main(void) { struct timeval tv; return (gettimeofday(&tv, NULL)); }
2050 ac_test killpg <<-'EOF'
2052 int main(int ac, char *av[]) { return (av[0][killpg(123, ac)]); }
2055 ac_test memmove <<-'EOF'
2056 #include <sys/types.h>
2060 #include <strings.h>
2062 int main(int ac, char *av[]) {
2063 return (*(int *)(void *)memmove(av[0], av[1], (size_t)ac));
2067 ac_test mknod '' 'if to use mknod(), makedev() and friends' <<-'EOF'
2068 #define MKSH_INCLUDES_ONLY
2070 int main(int ac, char *av[]) {
2072 dv = makedev((unsigned int)ac, (unsigned int)av[0][0]);
2073 return (mknod(av[0], (mode_t)0, dv) ? (int)major(dv) :
2078 ac_test mmap lock_fcntl 0 'for mmap and munmap' <<-'EOF'
2079 #include <sys/types.h>
2081 #include <sys/file.h>
2084 #include <sys/mman.h>
2088 int main(void) { return ((void *)mmap(NULL, (size_t)0,
2089 PROT_READ, MAP_PRIVATE, 0, (off_t)0) == (void *)NULL ? 1 :
2093 ac_test ftruncate mmap 0 'for ftruncate' <<-'EOF'
2095 int main(void) { return (ftruncate(0, 0)); }
2098 ac_test nice <<-'EOF'
2100 int main(void) { return (nice(4)); }
2103 ac_test revoke <<-'EOF'
2104 #include <sys/types.h>
2106 #include <libutil.h>
2109 int main(int ac, char *av[]) { return (ac + revoke(av[0])); }
2112 ac_test setlocale_ctype '' 'setlocale(LC_CTYPE, "")' <<-'EOF'
2115 int main(void) { return ((int)(size_t)(void *)setlocale(LC_CTYPE, "")); }
2118 ac_test langinfo_codeset setlocale_ctype 0 'nl_langinfo(CODESET)' <<-'EOF'
2119 #include <langinfo.h>
2121 int main(void) { return ((int)(size_t)(void *)nl_langinfo(CODESET)); }
2124 ac_test select <<-'EOF'
2125 #include <sys/types.h>
2126 #if HAVE_BOTH_TIME_H
2127 #include <sys/time.h>
2129 #elif HAVE_SYS_TIME_H
2130 #include <sys/time.h>
2134 #if HAVE_SYS_BSDTYPES_H
2135 #include <sys/bsdtypes.h>
2137 #if HAVE_SYS_SELECT_H
2138 #include <sys/select.h>
2141 #include <bstring.h>
2147 #include <strings.h>
2151 struct timeval tv = { 1, 200000 };
2152 fd_set fds; FD_ZERO(&fds); FD_SET(0, &fds);
2153 return (select(FD_SETSIZE, &fds, NULL, NULL, &tv));
2157 ac_test setresugid <<-'EOF'
2158 #include <sys/types.h>
2160 int main(void) { return (setresuid(0,0,0) + setresgid(0,0,0)); }
2163 ac_test setgroups setresugid 0 <<-'EOF'
2164 #include <sys/types.h>
2169 int main(void) { gid_t gid = 0; return (setgroups(0, &gid)); }
2172 if test x"$et" = x"klibc"; then
2174 ac_testn __rt_sigsuspend '' 'whether klibc uses RT signals' <<-'EOF'
2175 #define MKSH_INCLUDES_ONLY
2177 extern int __rt_sigsuspend(const sigset_t *, size_t);
2178 int main(void) { return (__rt_sigsuspend(NULL, 0)); }
2181 # no? damn! legacy crap ahead!
2183 ac_testn __sigsuspend_s '!' __rt_sigsuspend 1 \
2184 'whether sigsuspend is usable (1/2)' <<-'EOF'
2185 #define MKSH_INCLUDES_ONLY
2187 extern int __sigsuspend_s(sigset_t);
2188 int main(void) { return (__sigsuspend_s(0)); }
2190 ac_testn __sigsuspend_xxs '!' __sigsuspend_s 1 \
2191 'whether sigsuspend is usable (2/2)' <<-'EOF'
2192 #define MKSH_INCLUDES_ONLY
2194 extern int __sigsuspend_xxs(int, int, sigset_t);
2195 int main(void) { return (__sigsuspend_xxs(0, 0, 0)); }
2198 if test "000" = "$HAVE___RT_SIGSUSPEND$HAVE___SIGSUSPEND_S$HAVE___SIGSUSPEND_XXS"; then
2199 # no usable sigsuspend(), use pause() *ugh*
2200 add_cppflags -DMKSH_NO_SIGSUSPEND
2204 ac_test strerror '!' sys_errlist 0 <<-'EOF'
2205 extern char *strerror(int);
2206 int main(int ac, char *av[]) { return (*strerror(*av[ac])); }
2209 ac_test strsignal '!' sys_siglist 0 <<-'EOF'
2212 int main(void) { return (strsignal(1)[0]); }
2215 ac_test strlcpy <<-'EOF'
2217 int main(int ac, char *av[]) { return (strlcpy(*av, av[1],
2222 # check headers for declarations
2224 ac_test flock_decl flock 1 'for declaration of flock()' <<-'EOF'
2225 #define MKSH_INCLUDES_ONLY
2228 #include <sys/file.h>
2230 int main(void) { return ((flock)(0, 0)); }
2232 ac_test revoke_decl revoke 1 'for declaration of revoke()' <<-'EOF'
2233 #define MKSH_INCLUDES_ONLY
2235 int main(void) { return ((revoke)("")); }
2237 ac_test sys_errlist_decl sys_errlist 0 "for declaration of sys_errlist[] and sys_nerr" <<-'EOF'
2238 #define MKSH_INCLUDES_ONLY
2240 int main(void) { return (*sys_errlist[sys_nerr - 1] + isatty(0)); }
2242 ac_test sys_siglist_decl sys_siglist 0 'for declaration of sys_siglist[]' <<-'EOF'
2243 #define MKSH_INCLUDES_ONLY
2245 int main(void) { return (sys_siglist[0][0] + isatty(0)); }
2251 fd='if to use persistent history'
2252 ac_cache PERSISTENT_HISTORY || case $HAVE_FTRUNCATE$HAVE_MMAP$HAVE_FLOCK$HAVE_LOCK_FCNTL in
2255 test 1 = $fv || check_categories="$check_categories no-histfile"
2260 # extra checks for legacy mksh
2262 if test $legacy = 1; then
2263 ac_test long_32bit '' 'whether long is 32 bit wide' <<-'EOF'
2264 #define MKSH_INCLUDES_ONLY
2270 #define cta(name, assertion) char name[(assertion) ? 1 : -1]
2271 cta(char_is_8_bits, (CHAR_BIT) == 8);
2272 cta(long_is_32_bits, sizeof(long) == 4);
2274 int main(void) { return (sizeof(struct ctasserts)); }
2277 ac_test long_64bit '!' long_32bit 0 'whether long is 64 bit wide' <<-'EOF'
2278 #define MKSH_INCLUDES_ONLY
2284 #define cta(name, assertion) char name[(assertion) ? 1 : -1]
2285 cta(char_is_8_bits, (CHAR_BIT) == 8);
2286 cta(long_is_64_bits, sizeof(long) == 8);
2288 int main(void) { return (sizeof(struct ctasserts)); }
2291 case $HAVE_LONG_32BIT$HAVE_LONG_64BIT in
2292 10) check_categories="$check_categories int:32" ;;
2293 01) check_categories="$check_categories int:64" ;;
2294 *) check_categories="$check_categories int:u" ;;
2299 # Compiler: Praeprocessor (only if needed)
2301 test 0 = $HAVE_SYS_SIGNAME && if ac_testinit cpp_dd '' \
2302 'checking if the C Preprocessor supports -dD'; then
2303 echo '#define foo bar' >conftest.c
2304 vv ']' "$CPP $CFLAGS $CPPFLAGS $NOWARN -dD conftest.c >x"
2305 grep '#define foo bar' x >/dev/null 2>&1 && fv=1
2306 rmf conftest.c x vv.out
2311 # End of mirtoconf checks
2315 # Some operating systems have ancient versions of ed(1) writing
2316 # the character count to standard output; cope for that
2318 ed x <x 2>/dev/null | grep 3 >/dev/null 2>&1 && \
2319 check_categories="$check_categories $oldish_ed"
2322 if test 0 = $HAVE_SYS_SIGNAME; then
2323 if test 1 = $HAVE_CPP_DD; then
2324 $e Generating list of signal names...
2326 $e No list of signal names available via cpp. Falling back...
2330 echo '#include <signal.h>
2331 #if defined(NSIG_MAX)
2332 #define cfg_NSIG NSIG_MAX
2334 #define cfg_NSIG NSIG
2335 #elif defined(_NSIG)
2336 #define cfg_NSIG _NSIG
2337 #elif defined(SIGMAX)
2338 #define cfg_NSIG (SIGMAX + 1)
2339 #elif defined(_SIGMAX)
2340 #define cfg_NSIG (_SIGMAX + 1)
2342 /*XXX better error out, see sh.h */
2348 # GNU sed 2.03 segfaults when optimising this to sed -n
2349 NSIG=`vq "$CPP $CFLAGS $CPPFLAGS $NOWARN conftest.c" | \
2351 sed '/mksh_cfg.*= *$/{
2355 grep '^ *mksh_cfg *=' | \
2356 sed 's/^ *mksh_cfg *=[ ]*\([()0-9x+-][()0-9x+ -]*\).*$/\1/'`
2358 *mksh_cfg*) $e "Error: NSIG='$NSIG'"; NSIG=0 ;;
2359 *[\ \(\)+-]*) NSIG=`"$AWK" "BEGIN { print $NSIG }" </dev/null` ;;
2362 (printf hallo) >/dev/null 2>&1 || printf=echo
2363 test $printf = echo || test "`printf %d 42`" = 42 || printf=echo
2364 test $printf = echo || NSIG=`printf %d "$NSIG" 2>/dev/null`
2365 $printf "NSIG=$NSIG ... "
2366 sigs="ABRT FPE ILL INT SEGV TERM ALRM BUS CHLD CONT HUP KILL PIPE QUIT"
2367 sigs="$sigs STOP TSTP TTIN TTOU USR1 USR2 POLL PROF SYS TRAP URG VTALRM"
2368 sigs="$sigs XCPU XFSZ INFO WINCH EMT IO DIL LOST PWR SAK CLD IOT STKFLT"
2369 sigs="$sigs ABND DCE DUMP IOERR TRACE DANGER THCONT THSTOP RESV UNUSED"
2370 test 1 = $HAVE_CPP_DD && test $NSIG -gt 1 && sigs="$sigs "`vq \
2371 "$CPP $CFLAGS $CPPFLAGS $NOWARN -dD conftest.c" | \
2372 grep '[ ]SIG[A-Z0-9][A-Z0-9]*[ ]' | \
2373 sed 's/^.*[ ]SIG\([A-Z0-9][A-Z0-9]*\)[ ].*$/\1/' | sort`
2374 test $NSIG -gt 1 || sigs=
2375 for name in $sigs; do
2377 *:$name:*) continue ;;
2379 sigseenone=$sigseenone$name:
2380 echo '#include <signal.h>' >conftest.c
2381 echo int >>conftest.c
2382 echo mksh_cfg= SIG$name >>conftest.c
2383 echo ';' >>conftest.c
2384 # GNU sed 2.03 croaks on optimising this, too
2385 vq "$CPP $CFLAGS $CPPFLAGS $NOWARN conftest.c" | \
2387 sed '/mksh_cfg.*= *$/{
2391 grep '^ *mksh_cfg *=' | \
2392 sed 's/^ *mksh_cfg *=[ ]*\([0-9][0-9x]*\).*$/:\1 '$name/
2393 done | sed -n '/^:[^ ]/s/^://p' | while read nr name; do
2394 test $printf = echo || nr=`printf %d "$nr" 2>/dev/null`
2395 test $nr -gt 0 && test $nr -lt $NSIG || continue
2398 *) echo " { \"$name\", $nr },"
2399 sigseentwo=$sigseentwo$nr:
2400 $printf "$name=$nr " >&2
2403 done 2>&1 >signames.inc
2408 addsrcs '!' HAVE_STRLCPY strlcpy.c
2409 addsrcs USE_PRINTF_BUILTIN printf.c
2410 test 1 = "$USE_PRINTF_BUILTIN" && add_cppflags -DMKSH_PRINTF_BUILTIN
2411 test 1 = "$HAVE_CAN_VERB" && CFLAGS="$CFLAGS -verbose"
2412 add_cppflags -DMKSH_BUILD_R=562
2414 $e $bi$me: Finished configuration testing, now producing output.$ao
2422 add_cppflags -DMKSH_EXE_EXT
2429 *\ *) mkshshebang="#!./$mkshexe" ;;
2430 *) mkshshebang="#!$curdir/$mkshexe" ;;
2434 LC_ALL=C PATH='$PATH'; export LC_ALL PATH
2435 test -n "\$KSH_VERSION" || exit 1
2436 set -A check_categories -- $check_categories
2437 pflag='$curdir/$mkshexe'
2438 sflag='$srcdir/check.t'
2439 usee=0 useU=0 Pflag=0 Sflag=0 uset=0 vflag=1 xflag=0
2440 while getopts "C:e:fPp:QSs:t:U:v" ch; do case \$ch {
2441 (C) check_categories[\${#check_categories[*]}]=\$OPTARG ;;
2442 (e) usee=1; eflag=\$OPTARG ;;
2443 (f) check_categories[\${#check_categories[*]}]=fastbox ;;
2446 (p) pflag=\$OPTARG ;;
2451 (s) sflag=\$OPTARG ;;
2452 (t) uset=1; tflag=\$OPTARG ;;
2453 (U) useU=1; Uflag=\$OPTARG ;;
2459 shift \$((OPTIND - 1))
2460 set -A args -- '$srcdir/check.pl' -p "\$pflag"
2462 args[\${#args[*]}]=-E
2465 for y in "\${check_categories[@]}"; do
2468 if [[ -n \$x ]]; then
2469 args[\${#args[*]}]=-C
2470 args[\${#args[*]}]=\${x#,}
2473 args[\${#args[*]}]=-e
2474 args[\${#args[*]}]=\$eflag
2476 (( Pflag )) && args[\${#args[*]}]=-P
2478 args[\${#args[*]}]=-t
2479 args[\${#args[*]}]=\$tflag
2482 args[\${#args[*]}]=-U
2483 args[\${#args[*]}]=\$Uflag
2485 (( vflag )) && args[\${#args[*]}]=-v
2486 (( xflag )) && args[\${#args[*]}]=-x # force usage by synerr
2487 if [[ -n \$TMPDIR && -d \$TMPDIR/. ]]; then
2488 args[\${#args[*]}]=-T
2489 args[\${#args[*]}]=\$TMPDIR
2491 print Testing mksh for conformance:
2492 grep -F -e Mir''OS: -e MIRBSD "\$sflag"
2493 print "This shell is actually:\\n\\t\$KSH_VERSION"
2494 print 'test.sh built for mksh $dstversion'
2495 cstr='\$os = defined \$^O ? \$^O : "unknown";'
2496 cstr="\$cstr"'print \$os . ", Perl version " . \$];'
2497 for perli in \$PERL perl5 perl no; do
2498 if [[ \$perli = no ]]; then
2499 print Cannot find a working Perl interpreter, aborting.
2502 print "Trying Perl interpreter '\$perli'..."
2503 perlos=\$(\$perli -e "\$cstr")
2505 print "Errorlevel \$rv, running on '\$perlos'"
2507 print "=> not using"
2510 if [[ -n \$perlos ]]; then
2515 (( Sflag )) || echo + \$perli "\${args[@]}" -s "\$sflag" "\$@"
2516 (( Sflag )) || exec \$perli "\${args[@]}" -s "\$sflag" "\$@"$tsts
2517 # use of the -S option for check.t split into multiple chunks
2519 for s in "\$sflag".*; do
2520 echo + \$perli "\${args[@]}" -s "\$s" "\$@"
2521 \$perli "\${args[@]}" -s "\$s" "\$@"$tsts
2523 (( rv = rv ? rv : rc ))
2533 emitbc="-emit-llvm -c"
2539 echo ": # work around NeXTstep bug" >Rebuild.sh
2541 optfiles=`echo *.opt`
2543 for file in $optfiles; do
2544 echo "echo + Running genopt on '$file'..."
2545 echo "(srcfile='$srcdir/$file'; BUILDSH_RUN_GENOPT=1; . '$srcdir/Build.sh')"
2547 echo set -x >>Rebuild.sh
2548 for file in $SRCS; do
2549 op=`echo x"$file" | sed 's/^x\(.*\)\.c$/\1./'`
2550 test -f $file || file=$srcdir/$file
2551 files="$files$sp$file"
2553 echo "$CC $CFLAGS $CPPFLAGS $emitbc $file || exit 1" >>Rebuild.sh
2554 if test $cm = dragonegg; then
2555 echo "mv ${op}s ${op}ll" >>Rebuild.sh
2556 echo "llvm-as ${op}ll || exit 1" >>Rebuild.sh
2557 objs="$objs$sp${op}bc"
2559 objs="$objs$sp${op}o"
2564 echo "rm -f $tfn.s" >>Rebuild.sh
2565 echo "llvm-link -o - $objs | opt $optflags | llc -o $tfn.s" >>Rebuild.sh
2572 echo tcfn=$mkshexe >>Rebuild.sh
2573 echo "$CC $CFLAGS $LDFLAGS -o \$tcfn $lobjs $LIBS $ccpr" >>Rebuild.sh
2574 echo "test -f \$tcfn || exit 1; $SIZE \$tcfn" >>Rebuild.sh
2575 if test $cm = makefile; then
2576 extras='emacsfn.h exprtok.h rlimits.opt sh.h sh_flags.opt var_spec.h'
2577 test 0 = $HAVE_SYS_SIGNAME && extras="$extras signames.inc"
2579 for file in $optfiles; do
2580 genf=`basename "$file" | sed 's/.opt$/.gen/'`
2582 genq="$genq$nl$genf: $srcdir/Build.sh $srcdir/$file
2583 srcfile=$srcdir/$file; BUILDSH_RUN_GENOPT=1; . $srcdir/Build.sh"
2585 cat >Makefrag.inc <<EOF
2586 # Makefile fragment for building mksh $dstversion
2594 NONSRCS_INST= dot.mkshrc \$(MAN)
2595 NONSRCS_NOINST= Build.sh Makefile Rebuild.sh check.pl check.t test.sh
2602 .depend \$(OBJS_BP):$gens$genq
2604 # not BSD make only:
2607 #\$(PROG): \$(OBJS_BP)
2608 # \$(CC) \$(CFLAGS) \$(LDFLAGS) -o \$@ \$(OBJS_BP) \$(LIBS)
2609 #\$(OBJS_BP): \$(SRCS_FP) \$(NONSRCS)
2611 # \$(CC) \$(CFLAGS) \$(CPPFLAGS) -c \$<
2613 # for all make variants:
2616 # ./test.sh \$(REGRESS_FLAGS)
2617 check_categories=$check_categories
2619 # for BSD make only:
2621 #.include <bsd.prog.mk>
2624 $e Generated Makefrag.inc successfully.
2627 for file in $optfiles; do
2628 $e "+ Running genopt on '$file'..."
2629 do_genopt "$srcdir/$file" || exit 1
2631 if test $cm = combine; then
2633 for file in $SRCS; do
2634 test -f $file || file=$srcdir/$file
2637 emitbc="-fwhole-program --combine"
2638 v "$CC $CFLAGS $CPPFLAGS $LDFLAGS $emitbc $objs $LIBS $ccpr"
2639 elif test 1 = $pm; then
2640 for file in $SRCS; do
2641 test -f $file || file=$srcdir/$file
2642 v "$CC $CFLAGS $CPPFLAGS $emitbc $file" &
2646 for file in $SRCS; do
2647 test $cm = dragonegg && \
2648 op=`echo x"$file" | sed 's/^x\(.*\)\.c$/\1./'`
2649 test -f $file || file=$srcdir/$file
2650 v "$CC $CFLAGS $CPPFLAGS $emitbc $file" || exit 1
2651 if test $cm = dragonegg; then
2652 v "mv ${op}s ${op}ll"
2653 v "llvm-as ${op}ll" || exit 1
2660 v "llvm-link -o - $objs | opt $optflags | llc -o $tfn.s"
2664 test $cm = combine || v "$CC $CFLAGS $LDFLAGS -o $tcfn $lobjs $LIBS $ccpr"
2665 test -f $tcfn || exit 1
2666 test 1 = $r || v "$NROFF -mdoc <'$srcdir/lksh.1' >lksh.cat1" || rmf lksh.cat1
2667 test 1 = $r || v "$NROFF -mdoc <'$srcdir/mksh.1' >mksh.cat1" || rmf mksh.cat1
2668 test 0 = $eq && v $SIZE $tcfn
2670 test -f /usr/ucb/$i && i=/usr/ucb/$i
2673 $e Installing the shell:
2674 $e "# $i -c -s -o root -g bin -m 555 $tfn /bin/$tfn"
2675 if test $legacy = 0; then
2676 $e "# grep -x /bin/$tfn /etc/shells >/dev/null || echo /bin/$tfn >>/etc/shells"
2677 $e "# $i -c -o root -g bin -m 444 dot.mkshrc /usr/share/doc/mksh/examples/"
2680 $e Installing the manual:
2681 if test -f mksh.cat1; then
2682 $e "# $i -c -o root -g bin -m 444 lksh.cat1" \
2683 "/usr/share/man/cat1/lksh.0"
2684 $e "# $i -c -o root -g bin -m 444 mksh.cat1" \
2685 "/usr/share/man/cat1/mksh.0"
2688 $e "# $i -c -o root -g bin -m 444 lksh.1 mksh.1 /usr/share/man/man1/"
2690 $e Run the regression test suite: ./test.sh
2691 $e Please also read the sample file dot.mkshrc and the fine manual.
2696 === Environment used ===
2698 ==== build environment ====
2701 CFLAGS if empty, defaults to -xO2 or +O2
2702 or -O3 -qstrict or -O2, per compiler
2703 CPPFLAGS default empty
2704 LDFLAGS default empty; added before sources
2705 LDSTATIC set this to '-static'; default unset
2706 LIBS default empty; added after sources
2707 [Interix] default: -lcrypt (XXX still needed?)
2708 NOWARN -Wno-error or similar
2709 NROFF default: nroff
2710 TARGET_OS default: $(uname -s || uname)
2711 TARGET_OSREV [QNX] default: $(uname -r)
2713 ==== feature selectors ====
2714 USE_PRINTF_BUILTIN 1 to include (unsupported) printf(1) as builtin
2715 ===== general format =====
2717 HAVE_STRING_H ac_header
2718 HAVE_CAN_FSTACKPROTECTORALL ac_flags
2720 ==== cpp definitions ====
2721 DEBUG dont use in production, wants gcc, implies:
2722 DEBUG_LEAKS enable freeing resources before exiting
2723 MKSHRC_PATH "~/.mkshrc" (do not change)
2724 MKSH_A4PB force use of arc4random_pushb
2725 MKSH_ASSUME_UTF8 (0=disabled, 1=enabled; default: unset)
2726 MKSH_BINSHPOSIX if */sh or */-sh, enable set -o posix
2727 MKSH_BINSHREDUCED if */sh or */-sh, enable set -o sh
2728 MKSH_CLS_STRING KSH_ESC_STRING "[;H" KSH_ESC_STRING "[J"
2729 MKSH_DEFAULT_EXECSHELL "/bin/sh" (do not change)
2730 MKSH_DEFAULT_PROFILEDIR "/etc" (do not change)
2731 MKSH_DEFAULT_TMPDIR "/tmp" (do not change)
2732 MKSH_DISABLE_DEPRECATED disable code paths scheduled for later removal
2733 MKSH_DISABLE_EXPERIMENTAL disable code not yet comfy for (LTS) snapshots
2734 MKSH_DISABLE_TTY_WARNING shut up warning about ctty if OS cant be fixed
2735 MKSH_DONT_EMIT_IDSTRING omit RCS IDs from binary
2736 MKSH_MIDNIGHTBSD01ASH_COMPAT set -o sh: additional compatibility quirk
2737 MKSH_NOPROSPECTOFWORK disable jobs, co-processes, etc. (do not use)
2738 MKSH_NOPWNAM skip PAM calls, for -static on glibc or Solaris
2739 MKSH_NO_CMDLINE_EDITING disable command line editing code entirely
2740 MKSH_NO_DEPRECATED_WARNING omit warning when deprecated stuff is run
2741 MKSH_NO_LIMITS omit ulimit code
2742 MKSH_NO_SIGSETJMP define if sigsetjmp is broken or not available
2743 MKSH_NO_SIGSUSPEND use sigprocmask+pause instead of sigsuspend
2744 MKSH_SMALL omit some code, optimise hard for size (slower)
2745 MKSH_SMALL_BUT_FAST disable some hard-for-size optim. (modern sys.)
2746 MKSH_S_NOVI=1 disable Vi editing mode (default if MKSH_SMALL)
2747 MKSH_TYPEDEF_SIG_ATOMIC_T define to e.g. 'int' if sig_atomic_t is missing
2748 MKSH_TYPEDEF_SSIZE_T define to e.g. 'long' if your OS has no ssize_t
2749 MKSH_UNEMPLOYED disable job control (but not jobs/co-processes)
2751 === generic installation instructions ===
2753 Set CC and possibly CFLAGS, CPPFLAGS, LDFLAGS, LIBS. If cross-compiling,
2754 also set TARGET_OS. To disable tests, set e.g. HAVE_STRLCPY=0; to enable
2755 them, set to a value other than 0 or 1. Ensure /bin/ed is installed. For
2756 MKSH_SMALL but with Vi mode, add -DMKSH_S_NOVI=0 to CPPFLAGS as well.
2758 Normally, the following command is what you want to run, then:
2759 $ (sh Build.sh -r -c lto && ./test.sh -f) 2>&1 | tee log
2761 Copy dot.mkshrc to /etc/skel/.mkshrc; install mksh into $prefix/bin; or
2762 /bin; install the manpage, if omitting the -r flag a catmanpage is made
2763 using $NROFF. Consider using a forward script as /etc/skel/.mkshrc like
2764 http://anonscm.debian.org/cgit/collab-maint/mksh.git/plain/debian/.mkshrc
2765 and put dot.mkshrc as /etc/mkshrc so users need not keep up their HOME.
2767 You may also want to install the lksh binary (also as /bin/sh) built by:
2768 $ CPPFLAGS="$CPPFLAGS -DMKSH_BINSHPOSIX" sh Build.sh -L -r -c lto