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