1# Manually written configuration script for yash 2# (C) 2007-2020 magicant 3# 4# This program is free software: you can redistribute it and/or modify 5# it under the terms of the GNU General Public License as published by 6# the Free Software Foundation, either version 2 of the License, or 7# (at your option) any later version. 8# 9# This program is distributed in the hope that it will be useful, 10# but WITHOUT ANY WARRANTY; without even the implied warranty of 11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12# GNU General Public License for more details. 13# 14# You should have received a copy of the GNU General Public License 15# along with this program. If not, see <http://www.gnu.org/licenses/>. 16 17set +Ceu 18 19makefile="Makefile" 20makefilein="Makefile.in" 21configlog="config.log" 22configstatus="config.status" 23configh="config.h" 24tempsrc=".temp.c" 25tempo=".temp.o" 26tempd=".temp.d" 27tempout="./.temp.out" 28temptxt="./.temp.txt" 29dirs=". builtins doc doc/ja lineedit po tests" 30 31target="yash" 32version="2.51" 33copyright="Copyright (C) 2007-2020 magicant" 34 35# object files to be linked as `yash' 36objs='$(MAIN_OBJS)' 37# object files compiled into builtins.a 38builtin_objs='' 39 40null="" 41 42help="false" 43nocreate="false" 44debug="false" 45enable_array="true" 46enable_dirstack="true" 47enable_double_bracket="true" 48enable_nls="true" 49enable_help="true" 50enable_history="true" 51enable_lineedit="true" 52enable_printf="true" 53enable_socket="true" 54enable_test="true" 55enable_ulimit="true" 56default_loadpath='$(yashdatadir)' 57ctags_args="" 58etags_args="" 59intl_lib='intl' 60term_lib='tinfo curses ncurses ncursesw' 61prefix='/usr/local' 62exec_prefix='$(prefix)' 63bindir='$(exec_prefix)/bin' 64datarootdir='$(prefix)/share' 65datadir='$(datarootdir)' 66localedir='$(datarootdir)/locale' 67mandir='$(datarootdir)/man' 68docdir='$(datarootdir)/doc/'"$target" 69htmldir='$(docdir)' 70install_program='$(INSTALL) -c' 71install_data='$(INSTALL) -c -m 644' 72install_dir='$(INSTALL) -d' 73unset checkresult 74unset MAKEFLAGS 75umask u=rwx 76 77quoted0="'"$(printf '%s\n' "$0" | sed -e "s/'/'\\\\''/g")"'" 78quoted_args= 79for i 80do 81 if [ x"$i" != x"--no-create" ] 82 then 83 quoted_args="${quoted_args} '"$(printf '%s\n' "$i" | 84 sed -e "s/'/'\\\\''/g")"'" 85 fi 86done 87 88parseenable() { 89 case "$1" in 90 --enable-*=yes|--enable-*=true) val=true ;; 91 --enable-*=no|--enable-*=false) val=false ;; 92 *=*) echo "$0: $1: invalid option" >&2; exit 2 ;; 93 --enable-*) val=true ;; 94 --disable-*) val=false ;; 95 esac 96 opt="${1#--*able-}" 97 opt="${opt%%=*}" 98 case "$opt" in 99 array) enable_array=$val ;; 100 dirstack) enable_dirstack=$val ;; 101 double-bracket) enable_double_bracket=$val ;; 102 help) enable_help=$val ;; 103 history) enable_history=$val ;; 104 lineedit) enable_lineedit=$val ;; 105 nls) enable_nls=$val ;; 106 printf) enable_printf=$val ;; 107 socket) enable_socket=$val ;; 108 test) enable_test=$val ;; 109 ulimit) enable_ulimit=$val ;; 110 *) echo "$0: $1: invalid option" >&2; exit 2 ;; 111 esac 112} 113 114# parse options 115for i 116do 117 case "$i" in 118 -h|--help) 119 help="true" ;; 120 --no-create) 121 nocreate="true" ;; 122 -d|--debug) 123 debug="true" ;; 124 --prefix=*) 125 prefix="${i#--prefix=}" ;; 126 --exec-prefix=*) 127 exec_prefix="${i#--exec-prefix=}" ;; 128 --bindir=*) 129 bindir="${i#--bindir=}" ;; 130 --datarootdir=*) 131 datarootdir="${i#--datarootdir=}" ;; 132 --datadir=*) 133 datadir="${i#--datadir=}" ;; 134 --localedir=*) 135 localedir="${i#--localedir=}" ;; 136 --mandir=*) 137 mandir="${i#--mandir=}" ;; 138 --docdir=*) 139 docdir="${i#--docdir=}" ;; 140 --htmldir=*) 141 htmldir="${i#--htmldir=}" ;; 142 --enable-*|--disable-*) 143 parseenable "$i" ;; 144 --default-loadpath=*) 145 default_loadpath="${i#--default-loadpath=}" ;; 146 --with-intl-lib=*) 147 intl_lib="${i#--with-intl-lib=}" ;; 148 --with-term-lib=*) 149 term_lib="${i#--with-term-lib=}" ;; 150 ?*=*) 151 # parse variable assignment 152 if echo "$i" | grep -E "^[[:alpha:]][[:alnum:]]*=" >/dev/null 153 then 154 export "$i" 155 else 156 echo "$0: $i: unknown argument" >&2 157 exit 1 158 fi 159 ;; 160 *) 161 echo "$0: $i: unknown argument" >&2 162 exit 1 163 esac 164done 165 166if ${help} 167then 168 exec cat <<END 169Usage: sh $0 [options...] 170 171Available options: 172 --no-create do not create output files 173 --debug configure for debug build (GCC required) 174 175Installation options: 176 --prefix=PREFIX install architecture-independent files in PREFIX 177 [/usr/local] 178 --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX 179 [PREFIX] 180 --bindir=DIR install executable in DIR [EPREFIX/bin] 181 --datarootdir=DIR architecture-independent data root [PREFIX/share] 182 --datadir=DIR architecture-independent data [DATAROOTDIR] 183 --localedir=DIR localization data [DATAROOTDIR/locale] 184 --mandir=DIR man documentation [DATAROOTDIR/man] 185 --docdir=DIR documentation root [DATAROOTDIR/doc/$target] 186 --htmldir=DIR html documentation [DOCDIR] 187 188Optional features: 189 --enable-FEATURE[=ARG] enable or disable FEATURE [ARG=yes] 190 --disable-FEATURE disable FEATURE (same as --enable-FEATURE=no) 191 --enable-array enable the array builtin 192 --enable-dirstack enable the directory stack (pushd, popd, dirs) 193 --enable-double-bracket enable the double-bracket command 194 --enable-help enable the help builtin 195 --enable-history enable history 196 --enable-lineedit enable command line editing 197 --enable-nls enable native language support 198 --enable-printf enable the echo/printf builtins 199 --enable-socket enable socket redirection by /dev/tcp, /dev/udp 200 --enable-test enable the test builtin 201 --enable-ulimit enable the ulimit builtin 202 --default-loadpath=DIR specify the default \$YASH_LOADPATH value 203 204Optional packages: 205 --with-intl-lib=LIBS search space-separated LIBS for NLS 206 --with-term-lib=LIBS search space-separated LIBS for terminal handling 207 208Influential environment variables: 209 CC, CFLAGS, CADDS, CPPFLAGS, CPPADDS, LDFLAGS, LDADDS, LDLIBS, AR, ARFLAGS, 210 ARCHIVER, LINGUAS, XGETTEXT, XGETTEXTFLAGS, MSGFMT, MSGFMTFLAGS, MSGMERGE, 211 MSGMERGEFLAGS, MSGINIT, MSGCONV, MSGFILTER, 212 ASCIIDOC, ASCIIDOCFLAGS, ASCIIDOCATTRS, A2X, A2XFLAGS, 213 INSTALL, INSTALL_PROGRAM, INSTALL_DATA, INSTALL_DIR, 214 CTAGS, CTAGSARGS, ETAGS, ETAGSARGS, CSCOPE, CSCOPEARGS 215END 216 exit 217fi 218 219clean_up () { 220 rm -f "${tempsrc}" "${tempo}" "${tempout}" "${temptxt}" "${tempd}" 221} 222trap 'clean_up' EXIT 223trap 'clean_up; exit 1' HUP INT QUIT ABRT TERM PIPE USR1 USR2 224trap '' ALRM 225 226exec 5>"${configlog}" 227 228{ 229 printf '===== Configuration log: generated by %s\n' "${0##*/}" 230 echo 231 LC_TIME=C date 232 echo 233 printf '# Invocation command line was:\n%%' 234 for i in "$0" "$@" 235 do 236 printf ' %s' "$(printf '%s\n' "$i" | 237 sed -e '\|[^[:alnum:]./=-]| { 238 s/'"'"'/'"'\\''"'/g 239 s/\(.*\)/'"'"'\1'"'"'/ 240 }')" 241 done 242 echo 243 echo 244 printf '# uname -i = %s\n' "$(uname -i 2>/dev/null || echo \?)" 245 printf '# uname -n = %s\n' "$(uname -n 2>/dev/null || echo \?)" 246 printf '# uname -m = %s\n' "$(uname -m 2>/dev/null || echo \?)" 247 printf '# uname -o = %s\n' "$(uname -o 2>/dev/null || echo \?)" 248 printf '# uname -p = %s\n' "$(uname -p 2>/dev/null || echo \?)" 249 printf '# uname -r = %s\n' "$(uname -r 2>/dev/null || echo \?)" 250 printf '# uname -s = %s\n' "$(uname -s 2>/dev/null || echo \?)" 251 printf '# uname -v = %s\n' "$(uname -v 2>/dev/null || echo \?)" 252 printf '# uname -a = %s\n' "$(uname -a 2>/dev/null || echo \?)" 253 echo 254 printf '# PATH=%s\n' "$PATH" 255 echo 256} >&5 257 258checking () { 259 printf 'checking %s... ' "$1" 260 printf '\nchecking %s...\n' "$1" >&5 261} 262checkby () { 263 printf '%% %s\n' "$*" >&5 264 "$@" >&5 2>&1 265 laststatus=$? 266 if [ ${laststatus} -eq 0 ] 267 then 268 checkresult="yes" 269 else 270 printf '# exit status: %d\n' "${laststatus}" >&5 271 checkresult="no" 272 return ${laststatus} 273 fi 274} 275trymake () { 276 checkby ${CC-${cc}} ${CFLAGS-${cflags}} ${CADDS-${null}} \ 277 ${CPPFLAGS-${cppflags}} ${CPPADDS-${null}} \ 278 ${LDFLAGS-${ldflags}} ${LDADDS-${null}} -o "${tempout}" "${tempsrc}" \ 279 "$@" ${LDLIBS-${ldlibs}} 280} 281trycompile () { 282 checkby ${CC-${cc}} ${CFLAGS-${cflags}} ${CADDS-${null}} \ 283 ${CPPFLAGS-${cppflags}} ${CPPADDS-${null}} \ 284 -c -o "${tempo}" "${tempsrc}" "$@" 285} 286trylink () { 287 checkby ${CC-${cc}} ${LDFLAGS-${ldflags}} ${LDADDS-${null}} \ 288 -o "${tempout}" "${tempo}" "$@" ${LDLIBS-${ldlibs}} 289} 290tryexec () { 291 checkby "${tempout}" 292} 293checked () { 294 if [ $# -ge 1 ] 295 then 296 checkresult="$1" 297 fi 298 printf '%s\n' "${checkresult}" 299 printf '# result: %s\n' "${checkresult}" >&5 300} 301defconfigh () { 302 printf '# defining %s=%s in %s\n' "$1" "${2-1}" "${configh}" >&5 303 confighdefs="${confighdefs} 304#define ${1} ${2-1}" 305} 306fail () { 307 echo "configuration failed" >&2 308 exit 1 309} 310 311 312cc="${CC-c99}" 313cflags="${CFLAGS--O1 -g}" 314cppflags="${CPPFLAGS-${null}}" 315ldflags="${LDFLAGS-${null}}" 316ldlibs="${LDLIBS-${null}}" 317ar="${AR-ar}" 318arflags="${ARFLAGS--rc}" 319xgettext="${XGETTEXT-xgettext}" 320xgettextflags="${XGETTEXTFLAGS--kgt -kNgt -kngt:1,2 \ 321--flag=sb_vprintf:1:c-format --flag=sb_printf:1:c-format \ 322--flag=malloc_vprintf:1:c-format --flag=malloc_printf:1:c-format \ 323--flag=xerror:1:c-format --flag=serror:1:c-format \ 324--flag=le_compdebug:1:c-format}" 325msginit="${MSGINIT-msginit}" 326msgfmt="${MSGFMT-msgfmt}" 327msgfmtflags="${MSGFMTFLAGS--c}" 328msgmerge="${MSGMERGE-msgmerge}" 329msgmergeflags="${MSGMERGEFLAGS-${null}}" 330msgconv="${MSGCONV-msgconv}" 331msgfilter="${MSGFILTER-msgfilter}" 332asciidoc="${ASCIIDOC-asciidoc}" 333asciidocflags="${ASCIIDOCFLAGS-}" 334asciidocattrs="${ASCIIDOCATTRS--a docdate=\"\`date +%Y-%m-%d\`\" \ 335-a yashversion=\"\$(VERSION)\" -a linkcss -a disable-javascript}" 336a2x="${A2X-a2x}" 337a2xflags="${A2XFLAGS-}" 338ctags="${CTAGS-ctags}" 339etags="${ETAGS-etags}" 340cscope="${CSCOPE-cscope}" 341 342confighdefs='' 343 344 345# check OS type 346checking 'operating system' 347ostype=$(uname -s | tr "[:upper:]" "[:lower:]") 348checked "${ostype}" 349case "${ostype}" in 350 darwin) 351 defconfigh "_DARWIN_C_SOURCE" 352 ;; 353 sunos) 354 defconfigh "__EXTENSIONS__" 355 ;; 356esac 357 358 359# check POSIX conformance 360checking 'POSIX conformance' 361posixver=$(getconf _POSIX_VERSION 2>/dev/null) 362if [ -n "${posixver}" ] && [ x"${posixver}" != x"undefined" ] 363then 364 checked "${posixver}" 365else 366 checked "no" 367 posixver="" 368fi 369 370checking 'SUS conformance' 371xopenver=$(getconf _XOPEN_VERSION 2>/dev/null) 372if [ -n "${xopenver}" ] && [ x"${xopenver}" != x"undefined" ] 373then 374 checked "${xopenver}" 375else 376 checked "no" 377 xopenver="" 378fi 379 380case "${ostype}" in 381 freebsd|dragonfly) 382 # FreeBSD doesn't have a feature test macro to enable non-POSIX 383 # extensions. We don't define _POSIX_C_SOURCE or _XOPEN_SOURCE so that 384 # non-POSIX extensions are available. 385 posix= 386 xopen= 387 ;; 388 *) 389 posix=${posixver} 390 xopen=${xopenver} 391 ;; 392esac 393 394 395# define options for debugging 396if ${debug} 397then 398 cc="${CC-gcc -std=c99}" 399 cflags="${CFLAGS--pedantic -MMD -Wall -Wextra -O1 -fno-inline -ggdb}" 400else 401 defconfigh "NDEBUG" 402fi 403 404 405# check if the compiler works 406checking 'whether the compiler works' 407cat >"${tempsrc}" <<END 408int main(void) { return 0; } 409END 410if 411 trymake && tryexec 412then 413 checked "yes" 414elif 415 [ x"${cc}" = x"c99" ] && [ x"${CC+set}" != x"set" ] && ( 416 cc='gcc -std=c99' 417 trymake && tryexec 418 ) 419then 420 checked "yes (using gcc -std=c99)" 421 cc='gcc -std=c99' 422else 423 checked "no" 424 printf 'Compiler "%s" not found or not working.\n' "${CC-${cc}}" >&2 425 printf 'The compiler is expected to accept these options: %s\n' \ 426 "${CFLAGS-${cflags}} ${CADDS-${null}}" >&2 427 fail 428fi 429 430# check if the compiler accepts the -O2 option if we are not debugging 431if ! ${debug} && [ x"${CFLAGS+set}" != x"set" ] 432then 433 checking 'whether the compiler accepts -O2 flag' 434 savecflags=${cflags} 435 cflags="-O2 -g" 436 cat >"${tempsrc}" <<END 437int main(void) { return 0; } 438END 439 if 440 trycompile 441 then 442 checked "yes" 443 else 444 checked "no" 445 cflags=${savecflags} 446 fi 447 unset savecflags 448fi 449 450# check if make supports include statements 451checking 'whether make supports include statements' 452if 453 cat >"${temptxt}" <<END 454_TEST_: 455 @echo >/dev/null 456END 457 checkby eval "${MAKE-make} -f - _TEST_ <<END 458.POSIX: 459include ${temptxt} 460END 461" 462then 463 checked "yes" 464 make_supports_include=true make_include='include' 465else 466 checked "no" 467 make_supports_include=false make_include='# include' 468fi 469 470# check if make sets the $SHELL macro 471checking 'whether make sets $SHELL macro' 472checkby eval "SHELL=false ${MAKE-make} -f - <<END 473.POSIX: 474_TEST_: 475 \\\$(SHELL) -c : 476END 477" 478checked 479if [ x"${checkresult}" = x"yes" ] 480then 481 make_shell='# SHELL = sh' 482else 483 make_shell='SHELL = sh' 484fi 485 486# check if the pax command is available 487if [ x"${ARCHIVER+set}" != x"set" ] 488then 489 checking 'for the pax command' 490 >|"${tempsrc}" 491 checkby pax -w -x ustar -f "${tempout}" "${tempsrc}" 492 checked 493 if [ x"${checkresult}" = x"yes" ] 494 then 495 archiver='pax -w -x ustar -f' 496 else 497 archiver='tar cf' 498 fi 499fi 500 501# check if the install command is available 502if [ x"${INSTALL+set}" != x"set" ] 503then 504 checking 'for the install command' 505 >|"${tempsrc}" 506 checkby install -c -m 644 "${tempsrc}" "${tempout}" 507 checked 508 if [ x"${checkresult}" = x"yes" ] 509 then 510 install='install' 511 else 512 install='$(topdir)/install-sh' 513 fi 514fi 515 516 517# check if defining _POSIX_C_SOURCE and _XOPEN_SOURCE as values larger than 518# _POSIX_VERSION and _XOPEN_VERSION is accepted. 519if [ -n "${posix}" ] 520then 521 checking 'what values _POSIX_C_SOURCE and _XOPEN_SOURCE should have' 522 if 523 cat >"${tempsrc}" <<END 524#define _POSIX_C_SOURCE 200809L 525#define _XOPEN_SOURCE 700 526#include <unistd.h> 527int main(void) { fork(); return 0; } 528END 529 trycompile 530 then 531 checked "_POSIX_C_SOURCE=200809L, _XOPEN_SOURCE=700" 532 posix=200809 xopen=700 533 elif 534 cat >"${tempsrc}" <<END 535#define _POSIX_C_SOURCE 200112L 536#define _XOPEN_SOURCE 600 537#include <unistd.h> 538int main(void) { fork(); return 0; } 539END 540 trycompile 541 then 542 checked "_POSIX_C_SOURCE=200112L, _XOPEN_SOURCE=600" 543 posix=200112 xopen=600 544 else 545 checked "failed" 546 fi 547fi 548if [ -n "${posix}" ] 549then 550 defconfigh "_POSIX_C_SOURCE" "${posix}L" 551fi 552if [ -n "${xopen}" ] 553then 554 defconfigh "_XOPEN_SOURCE" "${xopen}" 555fi 556 557 558# check if we need -lm 559if [ x"${LDLIBS+set}" != x"set" ] 560then 561 checking 'if loader flag -lm can be omitted' 562 cat >"${tempsrc}" <<END 563${confighdefs} 564#include <math.h> 565int main(int argc, char **argv) { 566 return fmod(argc, 1.1) == trunc(argc) || argv == 0; 567} 568END 569 trymake 570 checked 571 if [ x"${checkresult}" = x"no" ] 572 then 573 ldlibs="${ldlibs} -lm" 574 fi 575fi 576 577# enable/disable socket redirection 578if ${enable_socket} 579then 580 checking 'for socket library' 581 cat >"${tempsrc}" <<END 582${confighdefs} 583#include <netdb.h> 584#include <sys/socket.h> 585int main(void) { 586 struct addrinfo ai = { 587 .ai_flags = 0, .ai_family = AF_UNSPEC, .ai_protocol = 0, 588 .ai_socktype = 1 ? SOCK_STREAM : SOCK_DGRAM, 589 .ai_addrlen = 0, .ai_addr = (void*)0, .ai_canonname = (void*)0, 590 .ai_next = (void*)0 591 }; 592 gai_strerror(getaddrinfo("", "", &ai, (void*)0)); 593 connect(socket(ai.ai_family, ai.ai_socktype, ai.ai_protocol), 594 ai.ai_addr, ai.ai_addrlen); 595 freeaddrinfo(&ai); 596} 597END 598 saveldlibs="${ldlibs}" 599 if 600 trymake 601 then 602 checked "yes" 603 else 604 for lib in '-lxnet' '-lsocket' '-lnsl' '-lsocket -lnsl' 605 do 606 ldlibs="${saveldlibs} ${lib}" 607 if trymake 608 then 609 checked "with ${lib}" 610 break 611 fi 612 done 613 fi 614 case "${checkresult}" in 615 yes|with*) 616 defconfigh "YASH_ENABLE_SOCKET" 617 unset saveldlibs 618 ;; 619 no) 620 checked "no" 621 printf 'The socket library is unavailable!\n' >&2 622 printf 'Add the "--disable-socket" option and try again.\n' >&2 623 fail 624 ;; 625 esac 626fi 627 628# check if gettext is available 629if ${enable_nls} 630then 631 checking 'for ngettext' 632 cat >"${tempsrc}" <<END 633${confighdefs} 634#include <libintl.h> 635int main(void) { const char *s = ngettext("foo", "bar", 1); return s == 0; } 636END 637 trycompile 638 checked 639 if [ x"${checkresult}" = x"yes" ] 640 then 641 defconfigh "HAVE_NGETTEXT" 642 fi 643 644 checking 'for gettext library' 645 cat >"${tempsrc}" <<END 646${confighdefs} 647#include <libintl.h> 648int main(void) { 649 bindtextdomain("", ""); 650 textdomain(""); 651 const char *s = gettext(""); 652#if HAVE_NGETTEXT 653 s = ngettext("", "", 0); 654#endif 655 return s == 0; 656} 657END 658 if 659 trycompile 660 then 661 saveldlibs="${ldlibs}" 662 if trylink 663 then 664 checked "yes" 665 else 666 for lib in ${intl_lib} 667 do 668 ldlibs="${saveldlibs} -l${lib}" 669 if trylink 670 then 671 checked "with -l${lib}" 672 break 673 fi 674 done 675 fi 676 fi 677 case "${checkresult}" in 678 yes|with*) 679 defconfigh "HAVE_GETTEXT" 680 unset saveldlibs 681 ;; 682 no) 683 checked "no" 684 printf 'The gettext library is unavailable!\n' >&2 685 printf 'Add the "--disable-nls" option and try again.\n' >&2 686 fail 687 ;; 688 esac 689fi 690 691# check if terminfo is available 692if ${enable_lineedit} 693then 694 for i in curses.h:CURSES_H ncurses.h:NCURSES_H \ 695 ncurses/ncurses.h:NCURSES_NCURSES_H \ 696 ncursesw/ncurses.h:NCURSESW_NCURSES_H 697 do 698 checking "for ${i%:*}" 699 cat >"${tempsrc}" <<END 700${confighdefs} 701#include <${i%:*}> 702int main(void) { return ERR; } 703END 704 trycompile 705 checked 706 if [ x"${checkresult}" = x"yes" ] 707 then 708 defconfigh "HAVE_${i#*:}" 709 break 710 fi 711 done 712 713 for i in term.h:TERM_H ncurses/term.h:NCURSES_TERM_H \ 714 ncursesw/term.h:NCURSESW_TERM_H 715 do 716 checking "for ${i%:*}" 717 cat >"${tempsrc}" <<END 718${confighdefs} 719#if HAVE_CURSES_H 720#include <curses.h> 721#elif HAVE_NCURSES_H 722#include <ncurses.h> 723#elif HAVE_NCURSES_NCURSES_H 724#include <ncurses/ncurses.h> 725#elif HAVE_NCURSESW_NCURSES_H 726#include <ncursesw/ncurses.h> 727#endif 728#include <${i%:*}> 729int main(void) { 730 int (*f1)(char *, int, int *) = setupterm; f1("", 0, 0); 731 int (*f2)(char *) = tigetflag; f2(""); 732 int (*f3)(char *) = tigetnum; f3(""); 733 char *(*f4)(char *) = tigetstr; f4(""); 734 int (*f5)(const char *, int, int (*)(int)) = tputs; f5("", 0, 0); 735/* char *(*f6)(char *, long,long,long,long,long,long,long,long,long) = tparm; 736 f6("", 0, 0, 0, 0, 0, 0, 0, 0, 0); */ 737 int (*f7)(TERMINAL *) = del_curterm; f7(cur_term); 738} 739END 740 trycompile 741 checked 742 if [ x"${checkresult}" = x"yes" ] 743 then 744 defconfigh "HAVE_${i#*:}" 745 break 746 fi 747 done 748 749 checking 'for terminfo library' 750 cat >"${tempsrc}" <<END 751${confighdefs} 752#include <stdio.h> 753#if HAVE_CURSES_H 754#include <curses.h> 755#elif HAVE_NCURSES_H 756#include <ncurses.h> 757#elif HAVE_NCURSES_NCURSES_H 758#include <ncurses/ncurses.h> 759#elif HAVE_NCURSESW_NCURSES_H 760#include <ncursesw/ncurses.h> 761#endif 762#if HAVE_TERM_H 763#include <term.h> 764#elif HAVE_NCURSES_TERM_H 765#include <ncurses/term.h> 766#elif HAVE_NCURSESW_TERM_H 767#include <ncursesw/term.h> 768#endif 769int main(void) { 770int i1 = setupterm((char*)0, 1, (int*)0); 771int i2 = tigetflag(""); 772int i3 = tigetnum(""); 773char *s1 = tigetstr(""); 774char *s2 = tparm(s1, (long) i1, (long) i2, (long) i3, 0L, 0L, 0L, 0L, 0L, 0L); 775int i4 = tputs(s2, 1, putchar); 776del_curterm(cur_term); 777return i4; 778} 779END 780 if 781 trycompile 782 then 783 saveldlibs="${ldlibs}" 784 if trylink 785 then 786 checked "yes" 787 else 788 for lib in ${term_lib} 789 do 790 ldlibs="${saveldlibs} -l${lib}" 791 if trylink 792 then 793 checked "with -l${lib}" 794 break 795 fi 796 done 797 fi 798 fi 799 case "${checkresult}" in 800 yes|with*) 801 defconfigh "YASH_ENABLE_LINEEDIT" 802 unset saveldlibs 803 ;; 804 no) 805 checked "no" 806 printf 'The terminfo (curses) library is unavailable!\n' >&2 807 printf 'Add the "--disable-lineedit" option and try again.\n' >&2 808 fail 809 ;; 810 esac 811fi 812 813 814# check whether system has /proc/self/exe or similar utility file 815if 816 checking 'for /proc/self/exe' 817 checkby /proc/self/exe -c true 818 checked 819 [ x"${checkresult}" = x"yes" ] 820then 821 defconfigh "HAVE_PROC_SELF_EXE" 822elif 823 checking 'for /proc/curproc/file' 824 checkby /proc/curproc/file -c true 825 checked 826 [ x"${checkresult}" = x"yes" ] 827then 828 defconfigh "HAVE_PROC_CURPROC_FILE" 829elif 830 checking 'for /proc/$$/object/a.out' 831 checkby eval '/proc/$$/object/a.out -c true' 832 checked 833 [ x"${checkresult}" = x"yes" ] 834then 835 defconfigh "HAVE_PROC_OBJECT_AOUT" 836fi 837 838 839# check for strnlen 840checking 'for strnlen' 841cat >"${tempsrc}" <<END 842${confighdefs} 843#include <string.h> 844#ifndef strnlen 845size_t strnlen(const char*, size_t); 846#endif 847int main(void) { return strnlen("12345", 3) != 3; } 848END 849trymake && tryexec 850checked 851if [ x"${checkresult}" = x"yes" ] 852then 853 defconfigh "HAVE_STRNLEN" 854fi 855 856# check for strdup 857checking 'for strdup' 858cat >"${tempsrc}" <<END 859${confighdefs} 860#include <string.h> 861#ifndef strdup 862char *strdup(const char*); 863#endif 864int main(void) { 865 char *dup = strdup("12345"); 866 if (!dup) return 1; 867 int cmp = strcmp(dup, "12345"); 868 free(dup); 869 return cmp != 0; 870} 871END 872trymake && tryexec 873checked 874if [ x"${checkresult}" = x"yes" ] 875then 876 defconfigh "HAVE_STRDUP" 877fi 878 879# check for wcsnlen 880checking 'for wcsnlen' 881cat >"${tempsrc}" <<END 882${confighdefs} 883#include <wchar.h> 884#ifndef wcsnlen 885size_t wcsnlen(const wchar_t*, size_t); 886#endif 887int main(void) { return wcsnlen(L"12345", 3) != 3; } 888END 889trymake && tryexec 890checked 891if [ x"${checkresult}" = x"yes" ] 892then 893 defconfigh "HAVE_WCSNLEN" 894fi 895 896# check for wcsdup 897checking 'for wcsdup' 898cat >"${tempsrc}" <<END 899${confighdefs} 900#include <wchar.h> 901#ifndef wcsdup 902wchar_t *wcsdup(const wchar_t*); 903#endif 904int main(void) { 905 char *dup = wcsdup("12345"); 906 if (!dup) return 1; 907 int cmp = wcscmp(dup, "12345"); 908 free(dup); 909 return cmp != 0; 910} 911END 912trymake && tryexec 913checked 914if [ x"${checkresult}" = x"yes" ] 915then 916 defconfigh "HAVE_WCSDUP" 917fi 918 919# check for wcscasecmp 920checking 'for wcscasecmp' 921cat >"${tempsrc}" <<END 922${confighdefs} 923#include <wchar.h> 924#ifndef wcscasecmp 925int wcscasecmp(const wchar_t*, const wchar_t*); 926#endif 927int main(void) { return wcscasecmp(L"1a2b3c", L"1A2B3C") != 0; } 928END 929trymake && tryexec 930checked 931if [ x"${checkresult}" = x"yes" ] 932then 933 defconfigh "HAVE_WCSCASECMP" 934fi 935 936# check for wcsnrtombs 937checking 'for wcsnrtombs' 938cat >"${tempsrc}" <<END 939${confighdefs} 940#include <stdint.h> 941#include <string.h> 942#include <wchar.h> 943#ifndef wcsnrtombs 944size_t wcsnrtombs(char *restrict, const wchar_t **restrict, size_t, size_t, 945 mbstate_t *restrict); 946#endif 947int main(void) { 948mbstate_t s; 949char out[10]; 950const wchar_t w[] = L"abcde"; 951const wchar_t *in = w; 952memset(&s, 0, sizeof s); 953return wcsnrtombs(out, &in, SIZE_MAX, sizeof out, &s) != 5 || 954 in != NULL || 955 strcmp(out, "abcde") != 0 || 956 wcsnrtombs(out, (in = &w[1], &in), 3, sizeof out, &s) != 3 || 957 in != &w[4] || 958 strncmp(out, "bcd", 3) != 0; 959} 960END 961trymake && tryexec 962checked 963if [ x"${checkresult}" = x"yes" ] 964then 965 defconfigh "HAVE_WCSNRTOMBS" 966fi 967 968# check for wcstold 969checking 'for wcstold' 970cat >"${tempsrc}" <<END 971${confighdefs} 972#include <wchar.h> 973#ifndef wcstold 974long double wcstold(const wchar_t *restrict, wchar_t **restrict); 975#endif 976int main(void) { return wcstold(L"10.0", (wchar_t **) 0) != 10.0; } 977END 978trymake && tryexec 979checked 980if [ x"${checkresult}" = x"yes" ] 981then 982 defconfigh "HAVE_WCSTOLD" 983fi 984 985# check for wcwidth 986checking 'for wcwidth' 987cat >"${tempsrc}" <<END 988${confighdefs} 989#include <wchar.h> 990#ifndef wcwidth 991int wcwidth(wchar_t); 992#endif 993int main(void) { return wcwidth(L'\0'); } 994END 995trymake && tryexec 996checked 997if [ x"${checkresult}" = x"yes" ] 998then 999 defconfigh "HAVE_WCWIDTH" 1000fi 1001 1002# check if sys/stat.h defines S_ISVTX 1003checking 'if <sys/stat.h> defines S_ISVTX' 1004cat >"${tempsrc}" <<END 1005${confighdefs} 1006#include <sys/stat.h> 1007int main(void) { return S_ISVTX & 0; } 1008END 1009trymake 1010checked 1011if [ x"${checkresult}" = x"yes" ] 1012then 1013 defconfigh "HAVE_S_ISVTX" 1014fi 1015 1016# check if unsetenv returns int 1017checking 'if unsetenv returns int' 1018cat >"${tempsrc}" <<END 1019${confighdefs} 1020#include <stdlib.h> 1021int main(void) { return 0 != unsetenv("x"); } 1022END 1023trymake 1024checked 1025if [ x"${checkresult}" = x"yes" ] 1026then 1027 defconfigh "UNSETENV_RETURNS_INT" 1028fi 1029 1030# check if the "st_atim"/"st_atimespec"/"st_atimensec"/"__st_atimensec" member 1031# of the "stat" structure is available 1032if ${enable_test} 1033then 1034 if 1035 checking 'for st_atim' 1036 cat >"${tempsrc}" <<END 1037 ${confighdefs} 1038#include <sys/stat.h> 1039int main(void) { 1040struct stat st; 1041st.st_atim = (struct timespec) { .tv_sec = 0, .tv_nsec = 0 }; 1042struct timespec ts = st.st_atim; 1043return ts.tv_nsec != 0; 1044} 1045END 1046 trymake 1047 checked 1048 [ x"${checkresult}" = x"yes" ] 1049 then 1050 defconfigh "HAVE_ST_ATIM" 1051 elif 1052 checking 'for st_atimespec' 1053 cat >"${tempsrc}" <<END 1054${confighdefs} 1055#include <sys/stat.h> 1056int main(void) { 1057struct stat st; 1058st.st_atimespec = (struct timespec) { .tv_sec = 0, .tv_nsec = 0 }; 1059struct timespec ts = st.st_atimespec; 1060return ts.tv_nsec != 0; 1061} 1062END 1063 trymake 1064 checked 1065 [ x"${checkresult}" = x"yes" ] 1066 then 1067 defconfigh "HAVE_ST_ATIMESPEC" 1068 elif 1069 checking 'for st_atimensec' 1070 cat >"${tempsrc}" <<END 1071${confighdefs} 1072#include <sys/stat.h> 1073int main(void) { 1074struct stat st; 1075st.st_atimensec = 0; 1076return st.st_atimensec != 0; 1077} 1078END 1079 trymake 1080 checked 1081 [ x"${checkresult}" = x"yes" ] 1082 then 1083 defconfigh "HAVE_ST_ATIMENSEC" 1084 elif 1085 checking 'for __st_atimensec' 1086 cat >"${tempsrc}" <<END 1087${confighdefs} 1088#include <sys/stat.h> 1089int main(void) { 1090struct stat st; 1091st.__st_atimensec = 0; 1092return st.__st_atimensec != 0; 1093} 1094END 1095 trymake 1096 checked 1097 [ x"${checkresult}" = x"yes" ] 1098 then 1099 defconfigh "HAVE___ST_ATIMENSEC" 1100 fi 1101fi 1102 1103# check if the "st_mtim"/"st_mtimespec"/"st_mtimensec"/"__st_mtimensec" member 1104# of the "stat" structure is available 1105if 1106 checking 'for st_mtim' 1107 cat >"${tempsrc}" <<END 1108 ${confighdefs} 1109#include <sys/stat.h> 1110int main(void) { 1111struct stat st; 1112st.st_mtim = (struct timespec) { .tv_sec = 0, .tv_nsec = 0 }; 1113struct timespec ts = st.st_mtim; 1114return ts.tv_nsec != 0; 1115} 1116END 1117 trymake 1118 checked 1119 [ x"${checkresult}" = x"yes" ] 1120then 1121 defconfigh "HAVE_ST_MTIM" 1122elif 1123 checking 'for st_mtimespec' 1124 cat >"${tempsrc}" <<END 1125${confighdefs} 1126#include <sys/stat.h> 1127int main(void) { 1128struct stat st; 1129st.st_mtimespec = (struct timespec) { .tv_sec = 0, .tv_nsec = 0 }; 1130struct timespec ts = st.st_mtimespec; 1131return ts.tv_nsec != 0; 1132} 1133END 1134 trymake 1135 checked 1136 [ x"${checkresult}" = x"yes" ] 1137then 1138 defconfigh "HAVE_ST_MTIMESPEC" 1139elif 1140 checking 'for st_mtimensec' 1141 cat >"${tempsrc}" <<END 1142${confighdefs} 1143#include <sys/stat.h> 1144int main(void) { 1145struct stat st; 1146st.st_mtimensec = 0; 1147return st.st_mtimensec != 0; 1148} 1149END 1150 trymake 1151 checked 1152 [ x"${checkresult}" = x"yes" ] 1153then 1154 defconfigh "HAVE_ST_MTIMENSEC" 1155elif 1156 checking 'for __st_mtimensec' 1157 cat >"${tempsrc}" <<END 1158${confighdefs} 1159#include <sys/stat.h> 1160int main(void) { 1161struct stat st; 1162st.__st_mtimensec = 0; 1163return st.__st_mtimensec != 0; 1164} 1165END 1166 trymake 1167 checked 1168 [ x"${checkresult}" = x"yes" ] 1169then 1170 defconfigh "HAVE___ST_MTIMENSEC" 1171fi 1172 1173# check if WCONTINUED and WIFCONTINUED are available 1174checking 'for WCONTINUED and WIFCONTINUED' 1175cat >"${tempsrc}" <<END 1176${confighdefs} 1177#include <errno.h> 1178#include <sys/wait.h> 1179static int s; 1180int main(void) { 1181if (WIFCONTINUED(s)) { } 1182return waitpid(-1, &s, WNOHANG|WCONTINUED) < 0 && errno == EINVAL; 1183} 1184END 1185trymake && tryexec 1186checked 1187if [ x"${checkresult}" = x"yes" ] 1188then 1189 defconfigh "HAVE_WCONTINUED" 1190fi 1191 1192# check for faccessat/eaccess 1193if 1194 checking 'for faccessat' 1195 cat >"${tempsrc}" <<END 1196${confighdefs} 1197#include <fcntl.h> 1198#include <unistd.h> 1199#ifndef faccessat 1200extern int faccessat(int, const char *, int, int); 1201#endif 1202int main(void) { 1203faccessat(AT_FDCWD, ".", F_OK | R_OK | W_OK | X_OK, AT_EACCESS); 1204} 1205END 1206 trymake 1207 checked 1208 [ x"${checkresult}" = x"yes" ] 1209then 1210 defconfigh "HAVE_FACCESSAT" 1211elif 1212 checking 'for eaccess' 1213 cat >"${tempsrc}" <<END 1214${confighdefs} 1215#include <unistd.h> 1216#ifndef eaccess 1217extern int eaccess(const char *, int); 1218#endif 1219int main(void) { eaccess(".", F_OK | R_OK | W_OK | X_OK); } 1220END 1221 trymake 1222 checked 1223 [ x"${checkresult}" = x"yes" ] 1224then 1225 defconfigh "HAVE_EACCESS" 1226fi 1227 1228# check for strsignal 1229checking 'for strsingal' 1230cat >"${tempsrc}" <<END 1231${confighdefs} 1232#include <signal.h> 1233#include <string.h> 1234#ifndef strsignal 1235char *strsignal(int); 1236#endif 1237int main(void) { (void) strsignal(SIGKILL); } 1238END 1239trymake 1240checked 1241if [ x"${checkresult}" = x"yes" ] 1242then 1243 defconfigh "HAVE_STRSIGNAL" 1244fi 1245 1246# check for setpwent & getpwent & endpwent 1247checking 'for setpwent/getpwent/endpwent' 1248cat >"${tempsrc}" <<END 1249${confighdefs} 1250#include <pwd.h> 1251#ifndef setpwent 1252void setpwent(void); 1253#endif 1254#ifndef getpwent 1255struct passwd *getpwent(void); 1256#endif 1257#ifndef endpwent 1258void endpwent(void); 1259#endif 1260struct passwd *p; 1261int main(void) { setpwent(); p = getpwent(); endpwent(); } 1262END 1263trymake 1264checked 1265if [ x"${checkresult}" = x"yes" ] 1266then 1267 defconfigh "HAVE_GETPWENT" 1268 1269 # check for pw_gecos 1270 checking 'for pw_gecos' 1271 cat >"${tempsrc}" <<END 1272${confighdefs} 1273#include <pwd.h> 1274const char *s; 1275struct passwd pwd; 1276int main(void) { pwd.pw_gecos = ""; s = pwd.pw_gecos; } 1277END 1278 trycompile 1279 checked 1280 if [ x"${checkresult}" = x"yes" ] 1281 then 1282 defconfigh "HAVE_PW_GECOS" 1283 fi 1284fi 1285 1286# check for setgrent & getgrent & endgrent 1287checking 'for setgrent/getgrent/endgrent' 1288cat >"${tempsrc}" <<END 1289${confighdefs} 1290#include <grp.h> 1291/* don't declare setgrent to avoid conflict on BSD */ 1292#ifndef getgrent 1293struct group *getgrent(void); 1294#endif 1295#ifndef endgrent 1296void endgrent(void); 1297#endif 1298struct group *g; 1299int main(void) { setgrent(); g = getgrent(); endgrent(); } 1300END 1301trymake 1302checked 1303if [ x"${checkresult}" = x"yes" ] 1304then 1305 defconfigh "HAVE_GETGRENT" 1306fi 1307 1308# check for sethostent & gethostent & endhostent 1309# This check may fail if socket redirection is disabled 1310# because the -lxnet compiler option is not specified. 1311checking 'for sethostent/gethostent/endhostent' 1312cat >"${tempsrc}" <<END 1313${confighdefs} 1314#include <netdb.h> 1315/* don't declare sethostent and endhostent to avoid conflict on SunOS */ 1316#ifndef gethostent 1317struct hostent *gethostent(void); 1318#endif 1319struct hostent *h; 1320int main(void) { sethostent(1); h = gethostent(); endhostent(); } 1321END 1322trymake 1323checked 1324if [ x"${checkresult}" = x"yes" ] 1325then 1326 defconfigh "HAVE_GETHOSTENT" 1327fi 1328 1329# check for paths.h 1330checking 'for paths.h' 1331cat >"${tempsrc}" <<END 1332${confighdefs} 1333#include <paths.h> 1334#include <stdio.h> 1335int main(void) { printf("%s\n", _PATH_BSHELL); } 1336END 1337trycompile 1338checked 1339if [ x"${checkresult}" = x"yes" ] 1340then 1341 defconfigh "HAVE_PATHS_H" 1342fi 1343 1344# check if getcwd accepts (NULL,0) as argument 1345checking "if getcwd(NULL,0) returns malloc'ed string" 1346cat >"${tempsrc}" <<END 1347${confighdefs} 1348#include <errno.h> 1349#include <stdlib.h> 1350#include <string.h> 1351#include <unistd.h> 1352char *xgetcwd(void) { 1353 size_t pwdlen = 80; 1354 char *pwd = malloc(pwdlen); 1355 if (!pwd) return NULL; 1356 while (getcwd(pwd, pwdlen) == NULL) { 1357 if (errno == ERANGE) { 1358 pwdlen *= 2; 1359 pwd = realloc(pwd, pwdlen); 1360 if (!pwd) return NULL; 1361 } else { 1362 free(pwd); 1363 return NULL; 1364 } 1365 } 1366 return pwd; 1367} 1368int main(void) { 1369 char *wd1 = getcwd(NULL, 0); 1370 if (!wd1) return 1; 1371 char *wd2 = xgetcwd(); 1372 if (!wd2 || strcmp(wd1, wd2) != 0) return 1; 1373 char *wd11 = realloc(wd1, strlen(wd1) + 10); 1374 if (!wd11 || strcmp(wd11, wd2) != 0) return 1; 1375 free(wd11); free(wd2); return 0; 1376} 1377END 1378trymake && tryexec 1379checked 1380if [ x"${checkresult}" = x"yes" ] 1381then 1382 defconfigh "GETCWD_AUTO_MALLOC" 1383fi 1384 1385# check if ioctl supports TIOCGWINSZ 1386if ${enable_lineedit} 1387then 1388 checking 'if ioctl supports TIOCGWINSZ' 1389 cat >"${tempsrc}" <<END 1390${confighdefs} 1391#include <sys/ioctl.h> 1392int main(void) { 1393 struct winsize ws; 1394 ioctl(0, TIOCGWINSZ, &ws); 1395 (void) ws.ws_row, (void) ws.ws_col; 1396} 1397END 1398 trymake 1399 checked 1400 if [ x"${checkresult}" = x"yes" ] 1401 then 1402 defconfigh "HAVE_TIOCGWINSZ" 1403 fi 1404fi 1405 1406# check if wide-oriented I/O is working 1407checking 'if wide-oriented I/O is fully working' 1408cat >"${tempsrc}" <<END 1409${confighdefs} 1410#include <stdio.h> 1411#include <wchar.h> 1412#define LEN 12345 1413int main(void) 1414{ 1415 FILE *f; 1416 fpos_t pos; 1417 f = fopen("${tempsrc}", "w+"); 1418 if (f == NULL) return 1; 1419 if (fwprintf(f, L"123\n") != 4) return 2; 1420 if (fseek(f, 0, SEEK_SET) != 0) return 3; 1421 if (fgetwc(f) != L'1') return 4; 1422 if (fgetwc(f) != L'2') return 5; 1423 if (fgetpos(f, &pos) != 0) return 6; 1424 if (fseek(f, 0, SEEK_SET) != 0) return 7; 1425 if (fgetwc(f) != L'1') return 8; 1426 if (fsetpos(f, &pos) != 0) return 9; 1427 if (fgetwc(f) != L'3') return 10; 1428 if (fseek(f, 0, SEEK_SET) != 0) return 11; 1429 for (size_t i = 0; i < LEN; i++) 1430 if (fputwc(L'0', f) != L'0') return 12; 1431 if (fgetpos(f, &pos) != 0) return 13; 1432 if (fputwc(L'1', f) != L'1') return 14; 1433 if (fseek(f, 0, SEEK_SET) != 0) return 15; 1434 if (fgetwc(f) != L'0') return 16; 1435 if (fsetpos(f, &pos) != 0) return 17; 1436 if (fgetwc(f) != L'1') return 18; 1437 if (fseek(f, 0, SEEK_SET) != 0) return 19; 1438 for (size_t i = 0; i < LEN; i++) 1439 if (fgetwc(f) != L'0') return 20; 1440 if (fgetwc(f) != L'1') return 21; 1441 if (fclose(f) != 0) return 22; 1442 return 0; 1443} 1444END 1445trymake && tryexec 1446checked 1447if [ x"${checkresult}" = x"no" ] 1448then 1449 defconfigh "WIO_BROKEN" 1450fi 1451 1452# check if fgetws is working 1453checking 'if fgetws is fully working' 1454cat >"${tempsrc}" <<END 1455${confighdefs} 1456#include <stdio.h> 1457#include <wchar.h> 1458int main(void) 1459{ 1460 wchar_t buf[100]; 1461 FILE *f = fopen("${tempsrc}", "w+"); 1462 if (f == NULL) return 1; 1463 if (fwprintf(f, L"123\n") != 4) return 2; 1464 if (fseek(f, 0, SEEK_SET) != 0) return 3; 1465 if (fgetws(buf, 2, f) == NULL) return 4; 1466 if (wcscmp(buf, L"1") != 0) return 5; 1467 if (fclose(f) != 0) return 6; 1468 return 0; 1469} 1470END 1471trymake && tryexec 1472checked 1473if [ x"${checkresult}" = x"no" ] 1474then 1475 defconfigh "FGETWS_BROKEN" 1476fi 1477 1478echo >&5 1479 1480# enable/disable the array builtin 1481if ${enable_array} 1482then 1483 defconfigh "YASH_ENABLE_ARRAY" 1484fi 1485 1486# enable/disable the double-bracket command 1487if ${enable_double_bracket} 1488then 1489 defconfigh "YASH_ENABLE_DOUBLE_BRACKET" 1490fi 1491 1492# enable/disable the directory stack 1493if ${enable_dirstack} 1494then 1495 defconfigh "YASH_ENABLE_DIRSTACK" 1496fi 1497 1498# enable/disable the help builtin 1499if ${enable_help} 1500then 1501 defconfigh "YASH_ENABLE_HELP" 1502fi 1503 1504# enable/disable history 1505if ${enable_history} 1506then 1507 defconfigh "YASH_ENABLE_HISTORY" 1508 objs="$objs "'$(HISTORY_OBJS)' 1509else 1510 if ${enable_lineedit} 1511 then 1512 printf 'History is required for lineedit but disabled.\n' >&2 1513 printf 'Add the "--disable-lineedit" option and try again.\n' >&2 1514 fail 1515 fi 1516fi 1517 1518# enable/disable the echo/printf builtins 1519if ${enable_printf} 1520then 1521 defconfigh "YASH_ENABLE_PRINTF" 1522 builtin_objs="$builtin_objs "'$(PRINTF_OBJS)' 1523fi 1524 1525# enable/disable the test builtin 1526if ${enable_test} 1527then 1528 defconfigh "YASH_ENABLE_TEST" 1529 builtin_objs="$builtin_objs "'$(TEST_OBJS)' 1530else 1531 if ${enable_double_bracket} 1532 then 1533 cat >&2 <<END 1534The test built-in is required for the double-bracket command, but disabled. 1535Add the "--disable-double-bracket" option and try again. 1536END 1537 fail 1538 fi 1539fi 1540 1541# check for getrlimit and setrlimit 1542if ${enable_ulimit} 1543then 1544 checking "for getrlimit and setrlimit" 1545 cat >"${tempsrc}" <<END 1546${confighdefs} 1547#include <stdint.h> /* required before <sys/resource.h> on freebsd */ 1548#include <sys/time.h> /* required before <sys/resource.h> on old Mac OS X */ 1549#include <sys/resource.h> 1550int main(void) { 1551struct rlimit l = { .rlim_cur = RLIM_INFINITY, .rlim_max = RLIM_INFINITY }; 1552getrlimit(RLIMIT_FSIZE, &l); 1553setrlimit(RLIMIT_FSIZE, &l); 1554} 1555END 1556 trymake 1557 checked 1558 if [ x"${checkresult}" = x"yes" ] 1559 then 1560 defconfigh "YASH_ENABLE_ULIMIT" 1561 builtin_objs="$builtin_objs "'$(ULIMIT_OBJS)' 1562 else 1563 printf 'The getrlimit and setrlimit functions are unavailable.\n' >&2 1564 printf 'Add the "--disable-ulimit" option and try again.\n' >&2 1565 fail 1566 fi 1567 1568 # check for RLIM_SAVED_CUR & RLIM_SAVED_MAX 1569 for i in CUR MAX 1570 do 1571 checking "for RLIM_SAVED_${i}" 1572 cat >"${tempsrc}" <<END 1573${confighdefs} 1574#include <stdint.h> /* required before <sys/resource.h> on freebsd */ 1575#include <sys/time.h> /* required before <sys/resource.h> on old Mac OS X */ 1576#include <sys/resource.h> 1577int main(void) { 1578struct rlimit l = { .rlim_cur = RLIM_SAVED_${i}, .rlim_max = RLIM_SAVED_${i} }; 1579return l.rlim_cur == l.rlim_max; 1580} 1581END 1582 trymake 1583 checked 1584 if [ x"${checkresult}" = x"yes" ] 1585 then 1586 defconfigh "HAVE_RLIM_SAVED_${i}" 1587 fi 1588 done 1589 1590 # check for RLIMIT_*** 1591 for i in AS LOCKS MEMLOCK MSGQUEUE NICE NPROC RSS RTPRIO SIGPENDING 1592 do 1593 checking "for RLIMIT_${i}" 1594 cat >"${tempsrc}" <<END 1595${confighdefs} 1596#include <stdint.h> /* required before <sys/resource.h> on freebsd */ 1597#include <sys/time.h> /* required before <sys/resource.h> on old Mac OS X */ 1598#include <sys/resource.h> 1599#if HAVE_RLIMIT_AS 1600int main(void) { return RLIMIT_${i} == RLIMIT_AS; getrlimit(RLIMIT_${i}, 0); } 1601#else 1602int main(void) { return 0; getrlimit(RLIMIT_${i}, 0); } 1603#endif 1604END 1605 trymake && tryexec 1606 checked 1607 if [ x"${checkresult}" = x"yes" ] 1608 then 1609 defconfigh "HAVE_RLIMIT_${i}" 1610 fi 1611 done 1612fi 1613 1614 1615# check if ctags/etags accepts the --recurse option 1616if [ x"${CTAGSARGS+set}" != x"set" ] 1617then 1618 checking "if ctags accepts --recurse option" 1619 rm -fr "${temptxt}" 1620 printf 'int f(int){}\n' >|"${tempsrc}" 1621 checkby ${ctags} --recurse -f "${temptxt}" "${tempsrc}" 1622 checked 1623 if [ x"${checkresult}" = x"yes" ] 1624 then 1625 CTAGSARGS='--recurse' 1626 else 1627 CTAGSARGS='*.[ch]' 1628 fi 1629fi 1630if [ x"${ETAGSARGS+set}" != x"set" ] 1631then 1632 checking "if etags accepts --recurse option" 1633 rm -fr "${temptxt}" 1634 printf 'int f(int){}\n' >|"${tempsrc}" 1635 checkby ${etags} --recurse -o "${temptxt}" "${tempsrc}" 1636 checked 1637 if [ x"${checkresult}" = x"yes" ] 1638 then 1639 ETAGSARGS='--recurse' 1640 else 1641 ETAGSARGS='*.[ch]' 1642 fi 1643fi 1644 1645# set cscope invocation parameter 1646: ${CSCOPEARGS=-bR} 1647 1648 1649if [ -n "${builtin_objs}" ] 1650then 1651 objs="${objs} "'$(BUILTINS_ARCHIVE)' 1652fi 1653if ${enable_lineedit} 1654then 1655 objs="${objs} "'$(LINEEDIT_ARCHIVE)' 1656fi 1657 1658if [ x"${LINGUAS+set}" = x"set" ] 1659then 1660 CATALOGS='' 1661 for i in ${LINGUAS} 1662 do 1663 CATALOGS="${CATALOGS} ${i}.mo" 1664 done 1665else 1666 CATALOGS='$(MOFILES)' 1667fi 1668 1669MAKE_INCLUDE="${MAKE_INCLUDE-${make_include}}" 1670MAKE_SHELL="${MAKE_SHELL-${make_shell}}" 1671CC="${CC-${cc}}" 1672CFLAGS="${CFLAGS-${cflags}}${CADDS:+ ${CADDS}}" 1673CPPFLAGS="${CPPFLAGS-${cppflags}}${CPPADDS:+ ${CPPADDS}}" 1674LDFLAGS="${LDFLAGS-${ldflags}}${LDADDS:+ ${LDADDS}}" 1675LDLIBS="${LDLIBS-${ldlibs}}" 1676AR="${AR-${ar}}" 1677ARFLAGS="${ARFLAGS-${arflags}}" 1678ARCHIVER="${ARCHIVER-${archiver}}" 1679XGETTEXT="${XGETTEXT-${xgettext}}" 1680XGETTEXTFLAGS="${XGETTEXTFLAGS-${xgettextflags}}" 1681MSGINIT="${MSGINIT-${msginit}}" 1682MSGFMT="${MSGFMT-${msgfmt}}" 1683MSGFMTFLAGS="${MSGFMTFLAGS-${msgfmtflags}}" 1684MSGMERGE="${MSGMERGE-${msgmerge}}" 1685MSGMERGEFLAGS="${MSGMERGEFLAGS-${msgmergeflags}}" 1686MSGCONV="${MSGCONV-${msgconv}}" 1687MSGFILTER="${MSGFILTER-${msgfilter}}" 1688ASCIIDOC="${ASCIIDOC-${asciidoc}}" 1689ASCIIDOCFLAGS="${ASCIIDOCFLAGS-${asciidocflags}}" 1690ASCIIDOCATTRS="${ASCIIDOCATTRS-${asciidocattrs}}" 1691A2X="${A2X-${a2x}}" 1692A2XFLAGS="${A2XFLAGS-${a2xflags}}" 1693CTAGS="${CTAGS-${ctags}}" 1694ETAGS="${ETAGS-${etags}}" 1695CSCOPE="${CSCOPE-${cscope}}" 1696DIRS="${dirs}" 1697OBJS="${objs}" 1698BUILTIN_OBJS="${builtin_objs}" 1699TARGET="${target}" 1700VERSION="${version}" 1701COPYRIGHT="${copyright}" 1702INSTALL="${INSTALL-${install}}" 1703INSTALL_PROGRAM="${INSTALL_PROGRAM-${install_program}}" 1704INSTALL_DATA="${INSTALL_DATA-${install_data}}" 1705INSTALL_DIR="${INSTALL_DIR-${install_dir}}" 1706case "${prefix}" in 1707 / ) prefix= ;; 1708 //) prefix=/ ;; 1709esac 1710case "${exec_prefix}" in 1711 / ) exec_prefix= ;; 1712 //) exec_prefix=/ ;; 1713esac 1714case "${bindir}" in 1715 / ) bindir= ;; 1716 //) bindir=/ ;; 1717esac 1718case "${datarootdir}" in 1719 / ) datarootdir= ;; 1720 //) datarootdir=/ ;; 1721esac 1722case "${datadir}" in 1723 / ) datadir= ;; 1724 //) datadir=/ ;; 1725esac 1726case "${localedir}" in 1727 / ) localedir= ;; 1728 //) localedir=/ ;; 1729esac 1730case "${mandir}" in 1731 / ) mandir= ;; 1732 //) mandir=/ ;; 1733esac 1734case "${docdir}" in 1735 / ) docdir= ;; 1736 //) docdir=/ ;; 1737esac 1738case "${htmldir}" in 1739 / ) htmldir= ;; 1740 //) htmldir=/ ;; 1741esac 1742 1743sed_subst_cmd=" 1744s!@MAKE_INCLUDE@!${MAKE_INCLUDE}!g 1745s!@MAKE_SHELL@!${MAKE_SHELL}!g 1746s!@CC@!${CC}!g 1747s!@CFLAGS@!${CFLAGS}!g 1748s!@CPPFLAGS@!${CPPFLAGS}!g 1749s!@LDFLAGS@!${LDFLAGS}!g 1750s!@LDLIBS@!${LDLIBS}!g 1751s!@AR@!${AR}!g 1752s!@ARFLAGS@!${ARFLAGS}!g 1753s!@ARCHIVER@!${ARCHIVER}!g 1754s!@XGETTEXT@!${XGETTEXT}!g 1755s!@XGETTEXTFLAGS@!${XGETTEXTFLAGS}!g 1756s!@MSGINIT@!${MSGINIT}!g 1757s!@MSGFMT@!${MSGFMT}!g 1758s!@MSGFMTFLAGS@!${MSGFMTFLAGS}!g 1759s!@MSGMERGE@!${MSGMERGE}!g 1760s!@MSGMERGEFLAGS@!${MSGMERGEFLAGS}!g 1761s!@MSGCONV@!${MSGCONV}!g 1762s!@MSGFILTER@!${MSGFILTER}!g 1763s!@ASCIIDOC@!${ASCIIDOC}!g 1764s!@ASCIIDOCFLAGS@!${ASCIIDOCFLAGS}!g 1765s!@ASCIIDOCATTRS@!${ASCIIDOCATTRS}!g 1766s!@A2X@!${A2X}!g 1767s!@A2XFLAGS@!${A2XFLAGS}!g 1768s!@CATALOGS@!${CATALOGS}!g 1769s!@CTAGS@!${CTAGS}!g 1770s!@CTAGSARGS@!${CTAGSARGS}!g 1771s!@ETAGS@!${ETAGS}!g 1772s!@ETAGSARGS@!${ETAGSARGS}!g 1773s!@CSCOPE@!${CSCOPE}!g 1774s!@CSCOPEARGS@!${CSCOPEARGS}!g 1775s!@DIRS@!${DIRS}!g 1776s!@OBJS@!${OBJS}!g 1777s!@BUILTIN_OBJS@!${BUILTIN_OBJS}!g 1778s!@TARGET@!${TARGET}!g 1779s!@VERSION@!${VERSION}!g 1780s!@COPYRIGHT@!${COPYRIGHT}!g 1781s!@INSTALL@!${INSTALL}!g 1782s!@INSTALL_PROGRAM@!${INSTALL_PROGRAM}!g 1783s!@INSTALL_DATA@!${INSTALL_DATA}!g 1784s!@INSTALL_DIR@!${INSTALL_DIR}!g 1785s!@prefix@!${prefix}!g 1786s!@exec_prefix@!${exec_prefix}!g 1787s!@bindir@!${bindir}!g 1788s!@datarootdir@!${datarootdir}!g 1789s!@datadir@!${datadir}!g 1790s!@localedir@!${localedir}!g 1791s!@mandir@!${mandir}!g 1792s!@docdir@!${docdir}!g 1793s!@htmldir@!${htmldir}!g 1794s!@default_loadpath@!${default_loadpath}!g 1795s!@enable_nls@!${enable_nls}!g 1796" 1797printf '\n\n===== Output variables =====\n%s\n' "${sed_subst_cmd}" >&5 1798 1799 1800# create dependency files if there are none 1801find . -name '*.c' -exec sh -c ' 1802dfile="${1%.c}.d" 1803[ -f "$dfile" ] && exit 1804printf "touching %s\n" "$dfile" 1805>>"$dfile" 1806printf "Touched %s\n" "$dfile" >&5 1807' x {} \; 1808 1809# create config.status 1810printf 'creating %s... ' "${configstatus}" 1811cat >"${configstatus}" <<CONFIG_STATUS_END 1812# ${configstatus##*/}: generated by ${0##*/} 1813# $(LC_TIME=C date) 1814 1815help=false 1816recheck=false 1817dirs='${dirs}' 1818 1819targets='${configh}' 1820for i in \${dirs} 1821do 1822 targets="\${targets} \${i}/${makefile}" 1823done 1824 1825# parse options 1826while [ \$# -gt 0 ] 1827do 1828 case "\$1" in 1829 -h|--help) 1830 help=true ;; 1831 --recheck) 1832 recheck=true ;; 1833 --) 1834 shift 1835 break ;; 1836 -*) 1837 echo "\$0: \$i: unknown option" >&2 1838 exit 1 ;; 1839 *) 1840 break ;; 1841 esac 1842 shift 1843done 1844 1845if \$help 1846then 1847 exec cat <<END 1848This shell script instantiates files from templates according to the 1849configuration result 1850 1851Usage: sh \$0 [options...] [files...] 1852 1853Available options: 1854 --recheck update config.status by reconfiguring in the same conditions 1855 1856Configuration files: 1857\${targets} 1858END 1859 exit 1860fi 1861 1862if \$recheck 1863then 1864 exec \${CONFIG_SHELL-sh} ${quoted0}${quoted_args} --no-create 1865 exit 1866fi 1867 1868if [ \$# -eq 0 ] 1869then 1870 set \${targets} 1871fi 1872 1873for target 1874do 1875 printf 'creating %s... ' "\${target}" 1876 case \${target} in 1877 '${configh}') 1878 cat >'${configh}' <<END 1879/* ${configh##*/}: generated by \${0##*/} */ 1880#ifndef YASH_CONFIG_H 1881#define YASH_CONFIG_H 1882${confighdefs} 1883#endif 1884END 1885 ;; 1886 '${makefile}' | */'${makefile}') 1887 dir=\$(dirname "\${target}") 1888 sed -e '${sed_subst_cmd}' -e "1i\\\\ 1889# \${target##*/}: generated by \${0##*/}" "\${dir}/${makefilein}" >"\${target}" 1890 if ! ${make_supports_include} && 1891 ls "\${dir}"/*.d >/dev/null 2>&1 1892 then 1893 printf '(including dependencies) ' 1894 cat "\${dir}"/*.d >>"\${target}" 1895 fi 1896 ;; 1897 esac 1898 printf 'done\n' 1899done 1900CONFIG_STATUS_END 1901chmod a+x "${configstatus}" 1902printf 'done\n' 1903printf 'Created %s\n' "${configstatus}" >&5 1904if ! ${nocreate} 1905then 1906 printf '%% %s\n' "${CONFIG_SHELL-sh} ${configstatus}" >&5 1907 ${CONFIG_SHELL-sh} ${configstatus} 1908fi 1909 1910 1911# print warning if POSIX conformance is missing 1912if [ -z "${posixver}" ] || [ "${posixver}" -lt 200112 ] 1913then 1914 echo "WARNING: yash is designed for systems that conform to POSIX.1-2001" 1915 echo " but your system does not" 1916fi 1917 1918 1919# vim: set ft=sh ts=8 sts=4 sw=4 noet tw=80: 1920