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