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