-
Notifications
You must be signed in to change notification settings - Fork 30
/
configure
executable file
·1976 lines (1863 loc) · 46.3 KB
/
configure
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Manually written configuration script for yash
# (C) 2007-2024 magicant
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
set +Ceu
makefile="Makefile"
makefilein="Makefile.in"
configlog="config.log"
configstatus="config.status"
configh="config.h"
tempsrc=".temp.c"
tempo=".temp.o"
tempd=".temp.d"
tempout="./.temp.out"
temptxt="./.temp.txt"
dirs=". builtins doc doc/ja lineedit po tests"
target="yash"
version="2.57"
copyright="Copyright (C) 2007-2024 magicant"
# object files to be linked as `yash'
objs='$(MAIN_OBJS)'
# object files compiled into builtins.a
builtin_objs=''
null=""
help="false"
nocreate="false"
debug="false"
enable_array="true"
enable_dirstack="true"
enable_double_bracket="true"
enable_nls="true"
enable_help="true"
enable_history="true"
enable_lineedit="true"
enable_printf="true"
enable_socket="true"
enable_test="true"
enable_ulimit="true"
default_loadpath='$(yashdatadir)'
ctags_args=""
etags_args=""
intl_lib='intl'
term_lib='tinfo curses ncurses ncursesw'
prefix='/usr/local'
exec_prefix='$(prefix)'
bindir='$(exec_prefix)/bin'
datarootdir='$(prefix)/share'
datadir='$(datarootdir)'
localedir='$(datarootdir)/locale'
mandir='$(datarootdir)/man'
docdir='$(datarootdir)/doc/'"$target"
htmldir='$(docdir)'
install_program='$(INSTALL) -c'
install_data='$(INSTALL) -c -m 644'
install_dir='$(INSTALL) -d'
unset checkresult
unset MAKEFLAGS
umask u=rwx
quoted0="'"$(printf '%s\n' "$0" | sed -e "s/'/'\\\\''/g")"'"
quoted_args=
for i
do
if [ x"$i" != x"--no-create" ]
then
quoted_args="${quoted_args} '"$(printf '%s\n' "$i" |
sed -e "s/'/'\\\\''/g")"'"
fi
done
parseenable() {
case "$1" in
--enable-*=yes|--enable-*=true) val=true ;;
--enable-*=no|--enable-*=false) val=false ;;
*=*) echo "$0: $1: invalid option" >&2; exit 2 ;;
--enable-*) val=true ;;
--disable-*) val=false ;;
esac
opt="${1#--*able-}"
opt="${opt%%=*}"
case "$opt" in
array) enable_array=$val ;;
dirstack) enable_dirstack=$val ;;
double-bracket) enable_double_bracket=$val ;;
help) enable_help=$val ;;
history) enable_history=$val ;;
lineedit) enable_lineedit=$val ;;
nls) enable_nls=$val ;;
printf) enable_printf=$val ;;
socket) enable_socket=$val ;;
test) enable_test=$val ;;
ulimit) enable_ulimit=$val ;;
*) echo "$0: $1: invalid option" >&2; exit 2 ;;
esac
}
# parse options
for i
do
case "$i" in
-h|--help)
help="true" ;;
--no-create)
nocreate="true" ;;
-d|--debug)
debug="true" ;;
--prefix=*)
prefix="${i#--prefix=}" ;;
--exec-prefix=*)
exec_prefix="${i#--exec-prefix=}" ;;
--bindir=*)
bindir="${i#--bindir=}" ;;
--datarootdir=*)
datarootdir="${i#--datarootdir=}" ;;
--datadir=*)
datadir="${i#--datadir=}" ;;
--localedir=*)
localedir="${i#--localedir=}" ;;
--mandir=*)
mandir="${i#--mandir=}" ;;
--docdir=*)
docdir="${i#--docdir=}" ;;
--htmldir=*)
htmldir="${i#--htmldir=}" ;;
--enable-*|--disable-*)
parseenable "$i" ;;
--default-loadpath=*)
default_loadpath="${i#--default-loadpath=}" ;;
--with-intl-lib=*)
intl_lib="${i#--with-intl-lib=}" ;;
--with-term-lib=*)
term_lib="${i#--with-term-lib=}" ;;
?*=*)
# parse variable assignment
if echo "$i" | grep -E "^[[:alpha:]][[:alnum:]]*=" >/dev/null
then
export "$i"
else
echo "$0: $i: unknown argument" >&2
exit 1
fi
;;
*)
echo "$0: $i: unknown argument" >&2
exit 1
esac
done
if ${help}
then
exec cat <<END
Usage: sh $0 [options...]
Available options:
--no-create do not create output files
--debug configure for debug build (GCC or Clang required)
Installation options:
--prefix=PREFIX install architecture-independent files in PREFIX
[/usr/local]
--exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
[PREFIX]
--bindir=DIR install executable in DIR [EPREFIX/bin]
--datarootdir=DIR architecture-independent data root [PREFIX/share]
--datadir=DIR architecture-independent data [DATAROOTDIR]
--localedir=DIR localization data [DATAROOTDIR/locale]
--mandir=DIR man documentation [DATAROOTDIR/man]
--docdir=DIR documentation root [DATAROOTDIR/doc/$target]
--htmldir=DIR html documentation [DOCDIR]
Optional features:
--enable-FEATURE[=ARG] enable or disable FEATURE [ARG=yes]
--disable-FEATURE disable FEATURE (same as --enable-FEATURE=no)
--enable-array enable the array builtin
--enable-dirstack enable the directory stack (pushd, popd, dirs)
--enable-double-bracket enable the double-bracket command
--enable-help enable the help builtin
--enable-history enable history
--enable-lineedit enable command line editing
--enable-nls enable native language support
--enable-printf enable the echo/printf builtins
--enable-socket enable socket redirection by /dev/tcp, /dev/udp
--enable-test enable the test builtin
--enable-ulimit enable the ulimit builtin
--default-loadpath=DIR specify the default \$YASH_LOADPATH value
Optional packages:
--with-intl-lib=LIBS search space-separated LIBS for NLS
--with-term-lib=LIBS search space-separated LIBS for terminal handling
Influential environment variables:
CC, CFLAGS, CADDS, CPPFLAGS, CPPADDS, LDFLAGS, LDADDS, LDLIBS, AR, ARFLAGS,
ARCHIVER, LINGUAS, XGETTEXT, XGETTEXTFLAGS, MSGFMT, MSGFMTFLAGS, MSGMERGE,
MSGMERGEFLAGS, MSGINIT, MSGCONV, MSGFILTER,
ASCIIDOC, ASCIIDOCFLAGS, ASCIIDOCATTRS, A2X, A2XFLAGS,
INSTALL, INSTALL_PROGRAM, INSTALL_DATA, INSTALL_DIR,
CTAGS, CTAGSARGS, ETAGS, ETAGSARGS, CSCOPE, CSCOPEARGS
END
exit
fi
clean_up () {
rm -f "${tempsrc}" "${tempo}" "${tempout}" "${temptxt}" "${tempd}"
}
trap 'clean_up' EXIT
trap 'clean_up; exit 1' HUP INT QUIT ABRT TERM PIPE USR1 USR2
trap '' ALRM
exec 5>"${configlog}"
{
printf '===== Configuration log: generated by %s\n' "${0##*/}"
echo
LC_TIME=C date
echo
printf '# Invocation command line was:\n%%'
for i in "$0" "$@"
do
printf ' %s' "$(printf '%s\n' "$i" |
sed -e '\|[^[:alnum:]./=-]| {
s/'"'"'/'"'\\''"'/g
s/\(.*\)/'"'"'\1'"'"'/
}')"
done
echo
echo
printf '# uname -i = %s\n' "$(uname -i 2>/dev/null || echo \?)"
printf '# uname -n = %s\n' "$(uname -n 2>/dev/null || echo \?)"
printf '# uname -m = %s\n' "$(uname -m 2>/dev/null || echo \?)"
printf '# uname -o = %s\n' "$(uname -o 2>/dev/null || echo \?)"
printf '# uname -p = %s\n' "$(uname -p 2>/dev/null || echo \?)"
printf '# uname -r = %s\n' "$(uname -r 2>/dev/null || echo \?)"
printf '# uname -s = %s\n' "$(uname -s 2>/dev/null || echo \?)"
printf '# uname -v = %s\n' "$(uname -v 2>/dev/null || echo \?)"
printf '# uname -a = %s\n' "$(uname -a 2>/dev/null || echo \?)"
echo
printf '# PATH=%s\n' "$PATH"
echo
} >&5
checking () {
printf 'checking %s... ' "$1"
printf '\nchecking %s...\n' "$1" >&5
}
checkby () {
printf '%% %s\n' "$*" >&5
"$@" >&5 2>&1
laststatus=$?
if [ ${laststatus} -eq 0 ]
then
checkresult="yes"
else
printf '# exit status: %d\n' "${laststatus}" >&5
checkresult="no"
return ${laststatus}
fi
}
trymake () {
checkby ${CC-${cc}} ${CFLAGS-${cflags}} ${CADDS-${null}} \
${CPPFLAGS-${cppflags}} ${CPPADDS-${null}} \
${LDFLAGS-${ldflags}} ${LDADDS-${null}} -o "${tempout}" "${tempsrc}" \
"$@" ${LDLIBS-${ldlibs}}
}
trycompile () {
checkby ${CC-${cc}} ${CFLAGS-${cflags}} ${CADDS-${null}} \
${CPPFLAGS-${cppflags}} ${CPPADDS-${null}} \
-c -o "${tempo}" "${tempsrc}" "$@"
}
trylink () {
checkby ${CC-${cc}} ${LDFLAGS-${ldflags}} ${LDADDS-${null}} \
-o "${tempout}" "${tempo}" "$@" ${LDLIBS-${ldlibs}}
}
tryexec () {
checkby "${tempout}"
}
checked () {
if [ $# -ge 1 ]
then
checkresult="$1"
fi
printf '%s\n' "${checkresult}"
printf '# result: %s\n' "${checkresult}" >&5
}
defconfigh () {
printf '# defining %s=%s in %s\n' "$1" "${2-1}" "${configh}" >&5
confighdefs="${confighdefs}
#define ${1} ${2-1}"
}
fail () {
echo "configuration failed" >&2
exit 1
}
cc="${CC-c99}"
cflags="${CFLAGS--O1 -g}"
cppflags="${CPPFLAGS-${null}}"
ldflags="${LDFLAGS-${null}}"
ldlibs="${LDLIBS-${null}}"
ar="${AR-ar}"
arflags="${ARFLAGS--rc}"
xgettext="${XGETTEXT-xgettext}"
xgettextflags="${XGETTEXTFLAGS--kgt -kNgt -kngt:1,2 \
--flag=sb_vprintf:1:c-format --flag=sb_printf:1:c-format \
--flag=malloc_vprintf:1:c-format --flag=malloc_printf:1:c-format \
--flag=xerror:1:c-format --flag=serror:1:c-format \
--flag=le_compdebug:1:c-format}"
msginit="${MSGINIT-msginit}"
msgfmt="${MSGFMT-msgfmt}"
msgfmtflags="${MSGFMTFLAGS--c}"
msgmerge="${MSGMERGE-msgmerge}"
msgmergeflags="${MSGMERGEFLAGS-${null}}"
msgconv="${MSGCONV-msgconv}"
msgfilter="${MSGFILTER-msgfilter}"
asciidoc="${ASCIIDOC-asciidoc}"
asciidocflags="${ASCIIDOCFLAGS-}"
asciidocattrs="${ASCIIDOCATTRS--a docdate=\"\`date +%Y-%m-%d\`\" \
-a yashversion=\"\$(VERSION)\" -a linkcss -a disable-javascript}"
a2x="${A2X-a2x}"
a2xflags="${A2XFLAGS-}"
ctags="${CTAGS-ctags}"
etags="${ETAGS-etags}"
cscope="${CSCOPE-cscope}"
confighdefs=''
# check OS type
checking 'operating system'
ostype=$(uname -s | tr "[:upper:]" "[:lower:]")
checked "${ostype}"
case "${ostype}" in
darwin)
defconfigh "_DARWIN_C_SOURCE"
;;
sunos)
defconfigh "__EXTENSIONS__"
;;
esac
# check POSIX conformance
checking 'POSIX conformance'
posixver=$(getconf _POSIX_VERSION 2>/dev/null)
if [ -n "${posixver}" ] && [ x"${posixver}" != x"undefined" ]
then
checked "${posixver}"
else
checked "no"
posixver=""
fi
checking 'SUS conformance'
xopenver=$(getconf _XOPEN_VERSION 2>/dev/null)
if [ -n "${xopenver}" ] && [ x"${xopenver}" != x"undefined" ]
then
checked "${xopenver}"
else
checked "no"
xopenver=""
fi
case "${ostype}" in
freebsd)
# FreeBSD doesn't have a feature test macro to enable non-POSIX
# extensions. We don't define _POSIX_C_SOURCE or _XOPEN_SOURCE so that
# non-POSIX extensions are available.
posix=
xopen=
;;
*)
posix=${posixver}
xopen=${xopenver}
;;
esac
# define options for debugging
if ${debug}
then
cflags="${CFLAGS--pedantic -MMD -Wall -Wextra -O1 -fno-inline -ggdb}"
else
defconfigh "NDEBUG"
fi
# check if the compiler works
checking 'whether the compiler works'
cat >"${tempsrc}" <<END
int main(void) { return 0; }
END
if
trymake && tryexec
then
checked "yes"
elif
[ x"${cc}" = x"c99" ] && [ x"${CC+set}" != x"set" ] && (
cc='gcc'
trymake && tryexec
)
then
checked "yes (using gcc)"
cc='gcc'
elif
[ x"${cc}" = x"c99" ] && [ x"${CC+set}" != x"set" ] && (
cc='clang'
trymake && tryexec
)
then
checked "yes (using clang)"
cc='clang'
else
checked "no"
printf 'Compiler "%s" not found or not working.\n' "${CC-${cc}}" >&2
printf 'The compiler is expected to accept these options: %s\n' \
"${CFLAGS-${cflags}} ${CADDS-${null}}" >&2
fail
fi
# check if the compiler accepts the -O2 option if we are not debugging
if ! ${debug} && [ x"${CFLAGS+set}" != x"set" ]
then
checking 'whether the compiler accepts -O2 flag'
savecflags=${cflags}
cflags="-O2 -g"
cat >"${tempsrc}" <<END
int main(void) { return 0; }
END
if
trycompile
then
checked "yes"
else
checked "no"
cflags=${savecflags}
fi
unset savecflags
fi
# find compiler option for C99 support
checking 'additional option to compile C99 code'
cat >"${tempsrc}" <<END
int main(int argc, char **argv) {
if (argc == 0) return 0;
int vla[argc];
vla[0] = 42;
// one-line comment
struct s { int v; } i = { .v = argv[0][0] };
return vla[0] + i.v;
}
END
if
trycompile
then
checked "none needed"
elif
[ x"${CFLAGS+set}" != x"set" ] &&
cflags="${cflags} -std=c99" &&
trycompile
then
checked "with -std=c99"
else
checked "failed"
printf 'Compiler "%s" does not seem to support C99.\n' "${CC-${cc}}" >&2
printf 'The compiler was tested with these options: %s\n' \
"${CFLAGS-${cflags}} ${CADDS-${null}}" >&2
fail
fi
# check if make supports include statements
checking 'whether make supports include statements'
if
cat >"${temptxt}" <<END
_TEST_:
@echo >/dev/null
END
checkby eval "${MAKE-make} -f - _TEST_ <<END
.POSIX:
include ${temptxt}
END
"
then
checked "yes"
make_supports_include=true make_include='include'
else
checked "no"
make_supports_include=false make_include='# include'
fi
# check if make sets the $SHELL macro
checking 'whether make sets $SHELL macro'
checkby eval "SHELL=false ${MAKE-make} -f - <<END
.POSIX:
_TEST_:
\\\$(SHELL) -c :
END
"
checked
if [ x"${checkresult}" = x"yes" ]
then
make_shell='# SHELL = sh'
else
make_shell='SHELL = sh'
fi
# check if the pax command is available
if [ x"${ARCHIVER+set}" != x"set" ]
then
checking 'for the pax command'
>|"${tempsrc}"
checkby pax -w -x ustar -f "${tempout}" "${tempsrc}"
checked
if [ x"${checkresult}" = x"yes" ]
then
archiver='pax -w -x ustar -f'
else
archiver='tar cf'
fi
fi
# check if the install command is available
if [ x"${INSTALL+set}" != x"set" ]
then
checking 'for the install command'
>|"${tempsrc}"
checkby install -c -m 644 "${tempsrc}" "${tempout}"
checked
if [ x"${checkresult}" = x"yes" ]
then
install='install'
else
install='$(topdir)/install-sh'
fi
fi
# check if defining _POSIX_C_SOURCE and _XOPEN_SOURCE as values larger than
# _POSIX_VERSION and _XOPEN_VERSION is accepted.
if [ -n "${posix}" ]
then
checking 'what values _POSIX_C_SOURCE and _XOPEN_SOURCE should have'
if
cat >"${tempsrc}" <<END
#define _POSIX_C_SOURCE 200809L
#define _XOPEN_SOURCE 700
#include <unistd.h>
int main(void) { fork(); return 0; }
END
trycompile
then
checked "_POSIX_C_SOURCE=200809L, _XOPEN_SOURCE=700"
posix=200809 xopen=700
elif
cat >"${tempsrc}" <<END
#define _POSIX_C_SOURCE 200112L
#define _XOPEN_SOURCE 600
#include <unistd.h>
int main(void) { fork(); return 0; }
END
trycompile
then
checked "_POSIX_C_SOURCE=200112L, _XOPEN_SOURCE=600"
posix=200112 xopen=600
else
checked "failed"
fi
fi
if [ -n "${posix}" ]
then
defconfigh "_POSIX_C_SOURCE" "${posix}L"
fi
if [ -n "${xopen}" ]
then
defconfigh "_XOPEN_SOURCE" "${xopen}"
fi
# check if we need -lm
if [ x"${LDLIBS+set}" != x"set" ]
then
checking 'if loader flag -lm can be omitted'
cat >"${tempsrc}" <<END
${confighdefs}
#include <math.h>
int main(int argc, char **argv) {
return fmod(argc, 1.1) == trunc(argc) || argv == 0;
}
END
trymake
checked
if [ x"${checkresult}" = x"no" ]
then
ldlibs="${ldlibs} -lm"
fi
fi
# enable/disable socket redirection
if ${enable_socket}
then
checking 'for socket library'
cat >"${tempsrc}" <<END
${confighdefs}
#include <netdb.h>
#include <sys/socket.h>
int main(void) {
struct addrinfo ai = {
.ai_flags = 0, .ai_family = AF_UNSPEC, .ai_protocol = 0,
.ai_socktype = 1 ? SOCK_STREAM : SOCK_DGRAM,
.ai_addrlen = 0, .ai_addr = (void*)0, .ai_canonname = (void*)0,
.ai_next = (void*)0
};
gai_strerror(getaddrinfo("", "", &ai, (void*)0));
connect(socket(ai.ai_family, ai.ai_socktype, ai.ai_protocol),
ai.ai_addr, ai.ai_addrlen);
freeaddrinfo(&ai);
}
END
saveldlibs="${ldlibs}"
if
trymake
then
checked "yes"
else
for lib in '-lxnet' '-lsocket' '-lnsl' '-lsocket -lnsl'
do
ldlibs="${saveldlibs} ${lib}"
if trymake
then
checked "with ${lib}"
break
fi
done
fi
case "${checkresult}" in
yes|with*)
defconfigh "YASH_ENABLE_SOCKET"
unset saveldlibs
;;
no)
checked "no"
printf 'The socket library is unavailable!\n' >&2
printf 'Add the "--disable-socket" option and try again.\n' >&2
fail
;;
esac
fi
# check if gettext is available
if ${enable_nls}
then
checking 'for ngettext'
cat >"${tempsrc}" <<END
${confighdefs}
#include <libintl.h>
int main(void) { const char *s = ngettext("foo", "bar", 1); return s == 0; }
END
trycompile
checked
if [ x"${checkresult}" = x"yes" ]
then
defconfigh "HAVE_NGETTEXT"
fi
checking 'for gettext library'
cat >"${tempsrc}" <<END
${confighdefs}
#include <libintl.h>
int main(void) {
bindtextdomain("", "");
textdomain("");
const char *s = gettext("");
#if HAVE_NGETTEXT
s = ngettext("", "", 0);
#endif
return s == 0;
}
END
if
trycompile
then
saveldlibs="${ldlibs}"
if trylink
then
checked "yes"
else
for lib in ${intl_lib}
do
ldlibs="${saveldlibs} -l${lib}"
if trylink
then
checked "with -l${lib}"
break
fi
done
fi
fi
case "${checkresult}" in
yes|with*)
defconfigh "HAVE_GETTEXT"
unset saveldlibs
;;
no)
checked "no"
printf 'The gettext library is unavailable!\n' >&2
printf 'Add the "--disable-nls" option and try again.\n' >&2
fail
;;
esac
fi
# check if terminfo is available
if ${enable_lineedit}
then
for i in curses.h:CURSES_H ncurses.h:NCURSES_H \
ncurses/ncurses.h:NCURSES_NCURSES_H \
ncursesw/ncurses.h:NCURSESW_NCURSES_H
do
checking "for ${i%:*}"
cat >"${tempsrc}" <<END
${confighdefs}
#include <${i%:*}>
int main(void) { return ERR; }
END
trycompile
checked
if [ x"${checkresult}" = x"yes" ]
then
defconfigh "HAVE_${i#*:}"
break
fi
done
for i in term.h:TERM_H ncurses/term.h:NCURSES_TERM_H \
ncursesw/term.h:NCURSESW_TERM_H
do
checking "for ${i%:*}"
cat >"${tempsrc}" <<END
${confighdefs}
#if HAVE_CURSES_H
#include <curses.h>
#elif HAVE_NCURSES_H
#include <ncurses.h>
#elif HAVE_NCURSES_NCURSES_H
#include <ncurses/ncurses.h>
#elif HAVE_NCURSESW_NCURSES_H
#include <ncursesw/ncurses.h>
#endif
#include <${i%:*}>
#ifndef putchar
int putchar(int);
#endif
int main(void) {
/* Undeclared identifiers are a syntax error in C99, but many compilers assume
* implicit declarations when they appear in a function call. We force compilers
* to reject undeclared functions by using them in a non-call expression. */
(void) setupterm, (void) tigetflag, (void) tigetnum, (void) tigetstr;
(void) tparm, (void) tputs, (void) del_curterm, (void) cur_term;
/* Check if we can actually call them with arguments of suitable types */
int i1 = setupterm("", 1, (int*)0);
int i2 = tigetflag("");
int i3 = tigetnum("");
char *s1 = tigetstr("");
char *s2 = tparm(s1, (long) i1, (long) i2, (long) i3, 0L, 0L, 0L, 0L, 0L, 0L);
int i4 = tputs(s2, 1, putchar);
(void) del_curterm(cur_term);
return i4;
}
END
trycompile
checked
if [ x"${checkresult}" = x"yes" ]
then
defconfigh "HAVE_${i#*:}"
break
fi
done
checking 'for terminfo library'
cat >"${tempsrc}" <<END
${confighdefs}
#include <stdio.h>
#if HAVE_CURSES_H
#include <curses.h>
#elif HAVE_NCURSES_H
#include <ncurses.h>
#elif HAVE_NCURSES_NCURSES_H
#include <ncurses/ncurses.h>
#elif HAVE_NCURSESW_NCURSES_H
#include <ncursesw/ncurses.h>
#endif
#if HAVE_TERM_H
#include <term.h>
#elif HAVE_NCURSES_TERM_H
#include <ncurses/term.h>
#elif HAVE_NCURSESW_TERM_H
#include <ncursesw/term.h>
#endif
int main(void) {
int i1 = setupterm((char*)0, 1, (int*)0);
int i2 = tigetflag("");
int i3 = tigetnum("");
char *s1 = tigetstr("");
char *s2 = tparm(s1, (long) i1, (long) i2, (long) i3, 0L, 0L, 0L, 0L, 0L, 0L);
int i4 = tputs(s2, 1, putchar);
del_curterm(cur_term);
return i4;
}
END
if
trycompile
then
saveldlibs="${ldlibs}"
if trylink
then
checked "yes"
else
for lib in ${term_lib}
do
ldlibs="${saveldlibs} -l${lib}"
if trylink
then
checked "with -l${lib}"
break
fi
done
fi
fi
case "${checkresult}" in
yes|with*)
defconfigh "YASH_ENABLE_LINEEDIT"
unset saveldlibs
;;
no)
checked "no"
printf 'The terminfo (curses) library is unavailable!\n' >&2
printf 'Add the "--disable-lineedit" option and try again.\n' >&2
fail
;;
esac
fi
# check whether system has /proc/self/exe or similar utility file
if
checking 'for /proc/self/exe'
checkby /proc/self/exe -c true
checked
[ x"${checkresult}" = x"yes" ]
then
defconfigh "HAVE_PROC_SELF_EXE"
elif
checking 'for /proc/curproc/file'
checkby /proc/curproc/file -c true
checked
[ x"${checkresult}" = x"yes" ]
then
defconfigh "HAVE_PROC_CURPROC_FILE"
elif
checking 'for /proc/$$/object/a.out'
checkby eval '/proc/$$/object/a.out -c true'
checked
[ x"${checkresult}" = x"yes" ]
then
defconfigh "HAVE_PROC_OBJECT_AOUT"
fi
# check for strnlen
checking 'for strnlen'
cat >"${tempsrc}" <<END
${confighdefs}
#include <string.h>
#ifndef strnlen
size_t strnlen(const char*, size_t);
#endif
int main(void) { return strnlen("12345", 3) != 3; }
END
trymake && tryexec
checked
if [ x"${checkresult}" = x"yes" ]
then
defconfigh "HAVE_STRNLEN"
fi
# check for strdup
checking 'for strdup'
cat >"${tempsrc}" <<END
${confighdefs}
#include <stdlib.h>
#include <string.h>
#ifndef strdup
char *strdup(const char*);
#endif
int main(void) {
char *dup = strdup("12345");
if (!dup) return 1;
int cmp = strcmp(dup, "12345");
free(dup);
return cmp != 0;
}
END
trymake && tryexec
checked
if [ x"${checkresult}" = x"yes" ]
then
defconfigh "HAVE_STRDUP"
fi
# check for wcsnlen
checking 'for wcsnlen'
cat >"${tempsrc}" <<END
${confighdefs}
#include <wchar.h>
#ifndef wcsnlen
size_t wcsnlen(const wchar_t*, size_t);
#endif
int main(void) { return wcsnlen(L"12345", 3) != 3; }
END
trymake && tryexec
checked
if [ x"${checkresult}" = x"yes" ]
then
defconfigh "HAVE_WCSNLEN"
fi
# check for wcsdup
checking 'for wcsdup'
cat >"${tempsrc}" <<END
${confighdefs}
#include <stdlib.h>
#include <wchar.h>
#ifndef wcsdup
wchar_t *wcsdup(const wchar_t*);
#endif
int main(void) {
wchar_t *dup = wcsdup(L"12345");
if (!dup) return 1;
int cmp = wcscmp(dup, L"12345");
free(dup);
return cmp != 0;
}
END
trymake && tryexec
checked
if [ x"${checkresult}" = x"yes" ]
then
defconfigh "HAVE_WCSDUP"
fi
# check for wcscasecmp
checking 'for wcscasecmp'
cat >"${tempsrc}" <<END
${confighdefs}
#include <wchar.h>
#ifndef wcscasecmp
int wcscasecmp(const wchar_t*, const wchar_t*);
#endif
int main(void) { return wcscasecmp(L"1a2b3c", L"1A2B3C") != 0; }
END
trymake && tryexec
checked
if [ x"${checkresult}" = x"yes" ]
then
defconfigh "HAVE_WCSCASECMP"
fi
# check for wcsnrtombs
checking 'for wcsnrtombs'
cat >"${tempsrc}" <<END
${confighdefs}
#include <stdint.h>
#include <string.h>
#include <wchar.h>
#ifndef wcsnrtombs
size_t wcsnrtombs(char *restrict, const wchar_t **restrict, size_t, size_t,
mbstate_t *restrict);
#endif
int main(void) {
mbstate_t s;
char out[10];
const wchar_t w[] = L"abcde";