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