vis

a vi-like editor based on Plan 9's structural regular expressions

git clone https://9o.is/git/vis.git

configure

(15945B)


      1 #!/bin/sh
      2 # Based on the configure script from musl libc, MIT licensed
      3 
      4 usage () {
      5 cat <<EOF
      6 Usage: $0 [OPTION]... [VAR=VALUE]...
      7 
      8 To assign environment variables (e.g., CC, CFLAGS...), specify them as
      9 VAR=VALUE.  See below for descriptions of some of the useful variables.
     10 
     11 Defaults for the options are specified in brackets.
     12 
     13 Configuration:
     14   --srcdir=DIR            source directory [detected]
     15 
     16 Installation directories:
     17   --prefix=PREFIX         main installation prefix [/usr/local]
     18   --exec-prefix=EPREFIX   installation prefix for executable files [PREFIX]
     19 
     20 Fine tuning of the installation directories:
     21   --bindir=DIR            user executables [EPREFIX/bin]
     22   --sharedir=DIR          share directories [PREFIX/share]
     23   --docdir=DIR            misc. documentation [PREFIX/share/doc]
     24   --mandir=DIR            man pages [PREFIX/share/man]
     25 
     26 Optional features:
     27   --enable-curses         build with Curses terminal output [yes]
     28   --enable-lua            build with Lua support [auto]
     29   --enable-lpeg-static    build with LPeg static linking [auto]
     30   --enable-tre            build with TRE regex support [auto]
     31   --enable-selinux        build with SELinux support [auto]
     32   --enable-acl            build with POSIX ACL support [auto]
     33   --enable-help           build with built-in help texts [yes]
     34 
     35 Some influential environment variables:
     36   CC                      C compiler command [detected]
     37   CFLAGS                  C compiler flags [-Os -pipe ...]
     38   LDFLAGS                 Linker flags
     39 
     40 Use these variables to override the choices made by configure.
     41 
     42 EOF
     43 exit 0
     44 }
     45 
     46 # Helper functions
     47 
     48 quote () {
     49 tr '\n' ' ' <<EOF | grep '^[-[:alnum:]_=,./:]* $' >/dev/null 2>&1 && { echo "$1" ; return 0 ; }
     50 $1
     51 EOF
     52 printf %s\\n "$1" | sed -e "s/'/'\\\\''/g" -e "1s/^/'/" -e "\$s/\$/'/" -e "s#^'\([-[:alnum:]_,./:]*\)=\(.*\)\$#\1='\2#"
     53 }
     54 echo () { printf "%s\n" "$*" ; }
     55 fail () { echo "$*" ; exit 1 ; }
     56 fnmatch () { eval "case \"\$2\" in $1) return 0 ;; *) return 1 ;; esac" ; }
     57 cmdexists () { type "$1" >/dev/null 2>&1 ; }
     58 trycc () { test -z "$CC" && cmdexists "$1" && CC=$1 ; }
     59 
     60 stripdir () {
     61 while eval "fnmatch '*/' \"\${$1}\"" ; do eval "$1=\${$1%/}" ; done
     62 }
     63 
     64 trycppif () {
     65 printf "checking preprocessor condition %s... " "$1"
     66 echo "typedef int x;" > "$tmpc"
     67 echo "#if $1" >> "$tmpc"
     68 echo "#error yes" >> "$tmpc"
     69 echo "#endif" >> "$tmpc"
     70 if $CC $2 -c -o "$tmpo" "$tmpc" >/dev/null 2>&1 ; then
     71 printf "false\n"
     72 return 1
     73 else
     74 printf "true\n"
     75 return 0
     76 fi
     77 }
     78 
     79 tryflag () {
     80 printf "checking whether compiler accepts %s... " "$2"
     81 echo "typedef int x;" > "$tmpc"
     82 if $CC $CFLAGS_TRY $2 -c -o "$tmpo" "$tmpc" >/dev/null 2>&1 ; then
     83 printf "yes\n"
     84 eval "$1=\"\${$1} \$2\""
     85 eval "$1=\${$1# }"
     86 return 0
     87 else
     88 printf "no\n"
     89 return 1
     90 fi
     91 }
     92 
     93 tryldflag () {
     94 printf "checking whether linker accepts %s... " "$2"
     95 echo "typedef int x;" > "$tmpc"
     96 if $CC $LDFLAGS_TRY -nostdlib -shared "$2" -o "$tmpo" "$tmpc" >/dev/null 2>&1 ; then
     97 printf "yes\n"
     98 eval "$1=\"\${$1} \$2\""
     99 eval "$1=\${$1# }"
    100 return 0
    101 else
    102 printf "no\n"
    103 return 1
    104 fi
    105 }
    106 
    107 # Beginning of actual script
    108 
    109 CFLAGS_AUTO=
    110 CFLAGS_TRY=
    111 LDFLAGS_AUTO=
    112 LDFLAGS_TRY=
    113 SRCDIR=
    114 PREFIX=/usr/local
    115 EXEC_PREFIX='$(PREFIX)'
    116 BINDIR='$(EXEC_PREFIX)/bin'
    117 SHAREDIR='$(PREFIX)/share'
    118 DOCDIR='$(PREFIX)/share/doc'
    119 MANDIR='$(PREFIX)/share/man'
    120 
    121 help=yes
    122 curses=yes
    123 lua=auto
    124 lpeg=auto
    125 tre=auto
    126 selinux=auto
    127 acl=auto
    128 
    129 for arg ; do
    130 case "$arg" in
    131 --help|-h) usage ;;
    132 --srcdir=*) SRCDIR=${arg#*=} ;;
    133 --prefix=*) PREFIX=${arg#*=} ;;
    134 --exec-prefix=*) EXEC_PREFIX=${arg#*=} ;;
    135 --bindir=*) BINDIR=${arg#*=} ;;
    136 --sharedir=*) SHAREDIR=${arg#*=} ;;
    137 --docdir=*) DOCDIR=${arg#*=} ;;
    138 --mandir=*) MANDIR=${arg#*=} ;;
    139 --environment-only) environmentonly=yes ;;
    140 --enable-help|--enable-help=yes) help=yes ;;
    141 --disable-help|--enable-help=no) help=no ;;
    142 --enable-curses|--enable-curses=yes) curses=yes ;;
    143 --disable-curses|--enable-curses=no) curses=no ;;
    144 --enable-lua|--enable-lua=yes) lua=yes ;;
    145 --disable-lua|--enable-lua=no) lua=no ;;
    146 --enable-lpeg-static|--enable-lpeg-static=yes) lpeg=yes ;;
    147 --disable-lpeg-static|--enable-lpeg-static=no) lpeg=no ;;
    148 --enable-tre|--enable-tre=yes) tre=yes ;;
    149 --disable-tre|--enable-tre=no) tre=no ;;
    150 --enable-selinux|--enable-selinux=yes) selinux=yes ;;
    151 --disable-selinux|--enable-selinux=no) selinux=no ;;
    152 --enable-acl|--enable-acl=yes) acl=yes ;;
    153 --disable-acl|--enable-acl=no) acl=no ;;
    154 --enable-*|--disable-*|--with-*|--without-*|--*dir=*|--build=*) ;;
    155 -* ) echo "$0: unknown option $arg" ;;
    156 CC=*) CC=${arg#*=} ;;
    157 CFLAGS=*) CFLAGS=${arg#*=} ;;
    158 CPPFLAGS=*) CPPFLAGS=${arg#*=} ;;
    159 LDFLAGS=*) LDFLAGS=${arg#*=} ;;
    160 *=*) ;;
    161 *) ;;
    162 esac
    163 done
    164 
    165 for i in SRCDIR PREFIX EXEC_PREFIX BINDIR SHAREDIR DOCDIR MANDIR ; do
    166 stripdir $i
    167 done
    168 
    169 #
    170 # Get the source dir for out-of-tree builds
    171 #
    172 if test -z "$SRCDIR" ; then
    173 SRCDIR="${0%/configure}"
    174 stripdir SRCDIR
    175 fi
    176 abs_builddir="$(pwd)" || fail "$0: cannot determine working directory"
    177 abs_srcdir="$(cd $SRCDIR && pwd)" || fail "$0: invalid source directory $SRCDIR"
    178 test "$abs_srcdir" = "$abs_builddir" && SRCDIR=.
    179 test "$SRCDIR" != "." -a -f Makefile -a ! -h Makefile && fail "$0: Makefile already exists in the working directory"
    180 
    181 #
    182 # Get a temp filename we can use
    183 #
    184 i=0
    185 set -C
    186 while : ; do i=$(($i+1))
    187 tmpc="./conf$$-$PPID-$i.c"
    188 tmpo="./conf$$-$PPID-$i.o"
    189 2>|/dev/null > "$tmpc" && break
    190 test "$i" -gt 50 && fail "$0: cannot create temporary file $tmpc"
    191 done
    192 set +C
    193 trap 'rm -f "$tmpc" "$tmpo"' EXIT QUIT TERM HUP
    194 trap 'rm -f "$tmpc" "$tmpo" && echo && fail "$0: interrupted"' INT
    195 
    196 #
    197 # Find a C compiler to use
    198 #
    199 printf "checking for C compiler... "
    200 trycc cc
    201 trycc gcc
    202 trycc clang
    203 printf "%s\n" "$CC"
    204 test -n "$CC" || { echo "$0: cannot find a C compiler" ; exit 1 ; }
    205 
    206 printf "checking whether C compiler works... "
    207 echo "typedef int x;" > "$tmpc"
    208 if output=$($CC $CPPFLAGS $CFLAGS -c -o "$tmpo" "$tmpc" 2>&1) ; then
    209 printf "yes\n"
    210 else
    211 printf "no; compiler output follows:\n%s\n" "$output"
    212 exit 1
    213 fi
    214 
    215 #
    216 # Figure out options to force errors on unknown flags.
    217 #
    218 tryflag   CFLAGS_TRY  -Werror=unknown-warning-option
    219 tryflag   CFLAGS_TRY  -Werror=unused-command-line-argument
    220 tryldflag LDFLAGS_TRY -Werror=unknown-warning-option
    221 tryldflag LDFLAGS_TRY -Werror=unused-command-line-argument
    222 
    223 CFLAGS_STD="-std=c99 -U_XOPEN_SOURCE -D_XOPEN_SOURCE=700 -DNDEBUG -MMD"
    224 LDFLAGS_STD="-lc"
    225 
    226 OS=$(uname)
    227 
    228 case "$OS" in
    229 FreeBSD|DragonFly) CFLAGS_STD="$CFLAGS_STD -D_BSD_SOURCE -D__BSD_VISIBLE=1" ;;
    230 NetBSD)  CFLAGS_STD="$CFLAGS_STD -D_NETBSD_SOURCE" ;;
    231 *BSD)    CFLAGS_STD="$CFLAGS_STD -D_BSD_SOURCE" ;;
    232 Darwin)  CFLAGS_STD="$CFLAGS_STD -D_DARWIN_C_SOURCE" ;;
    233 AIX)     CFLAGS_STD="$CFLAGS_STD -D_ALL_SOURCE" ;;
    234 esac
    235 
    236 tryflag CFLAGS -Wall
    237 tryflag CFLAGS -pipe
    238 
    239 # Try flags to optimize binary size
    240 tryflag CFLAGS -O2
    241 tryflag CFLAGS -ffunction-sections
    242 tryflag CFLAGS -fdata-sections
    243 tryldflag LDFLAGS_AUTO -Wl,--gc-sections
    244 
    245 # Try hardening flags
    246 tryflag CFLAGS -fPIE
    247 tryflag CFLAGS_AUTO -fstack-protector-all
    248 tryldflag LDFLAGS -Wl,-z,now
    249 tryldflag LDFLAGS -Wl,-z,relro
    250 tryldflag LDFLAGS_AUTO -pie
    251 
    252 printf "creating config.mk... "
    253 
    254 cmdline=$(quote "$0")
    255 for i ; do cmdline="$cmdline $(quote "$i")" ; done
    256 
    257 exec 3>&1 1>config.mk
    258 
    259 cat << EOF
    260 # This version of config.mk was generated by:
    261 # $cmdline
    262 # Any changes made here will be lost if configure is re-run
    263 SRCDIR = $SRCDIR
    264 PREFIX = $PREFIX
    265 EXEC_PREFIX = $EXEC_PREFIX
    266 BINDIR = $BINDIR
    267 DOCPREFIX = $DOCDIR
    268 MANPREFIX = $MANDIR
    269 SHAREPREFIX = $SHAREDIR
    270 CC = $CC
    271 CFLAGS = $CFLAGS
    272 LDFLAGS = $LDFLAGS
    273 CFLAGS_STD = $CFLAGS_STD
    274 LDFLAGS_STD = $LDFLAGS_STD
    275 CFLAGS_AUTO = $CFLAGS_AUTO
    276 LDFLAGS_AUTO = $LDFLAGS_AUTO
    277 CFLAGS_DEBUG = -U_FORTIFY_SOURCE -UNDEBUG -O0 -g3 -ggdb -Wall -Wextra -pedantic -Wno-missing-field-initializers -Wno-unused-parameter
    278 EOF
    279 exec 1>&3 3>&-
    280 
    281 printf "done\n"
    282 
    283 if test "$environmentonly" = "yes"; then
    284 	exit 0
    285 fi
    286 
    287 have_pkgconfig=no
    288 printf "checking for pkg-config... "
    289 cmdexists pkg-config && have_pkgconfig=yes
    290 printf "%s\n" "$have_pkgconfig"
    291 
    292 if test "$help" = "yes" ; then
    293 	CONFIG_HELP=1
    294 else
    295 	CONFIG_HELP=0
    296 fi
    297 
    298 CONFIG_CURSES=0
    299 
    300 if test "$curses" != "no" ; then
    301 
    302 	printf "checking for libcurses...\n"
    303 
    304 cat > "$tmpc" <<EOF
    305 #include <curses.h>
    306 
    307 int main(int argc, char *argv[]) {
    308 	initscr();
    309 	endwin();
    310 	return 0;
    311 }
    312 EOF
    313 
    314 	for libcurses in ncursesw ncurses curses; do
    315 		printf " checking for %s... " "$libcurses"
    316 
    317 		if test "$have_pkgconfig" = "yes" ; then
    318 			CFLAGS_CURSES=$(pkg-config --cflags $libcurses 2>/dev/null)
    319 			LDFLAGS_CURSES=$(pkg-config --libs $libcurses 2>/dev/null)
    320 			if test $? -eq 0 && $CC $CFLAGS $CFLAGS_CURSES "$tmpc" \
    321 				$LDFLAGS $LDFLAGS_CURSES -o "$tmpo" >/dev/null 2>&1 ; then
    322 				CONFIG_CURSES=1
    323 				printf "yes\n"
    324 				break
    325 			fi
    326 		fi
    327 
    328 		CFLAGS_CURSES=""
    329 		LDFLAGS_CURSES="-l$libcurses"
    330 
    331 		if $CC $CFLAGS $CFLAGS_CURSES "$tmpc" \
    332 			$LDFLAGS $LDFLAGS_CURSES -o "$tmpo" >/dev/null 2>&1 ; then
    333 			CONFIG_CURSES=1
    334 			printf "yes\n"
    335 			break
    336 		else
    337 			CFLAGS_CURSES=""
    338 			LDFLAGS_CURSES=""
    339 			printf "no\n"
    340 		fi
    341 	done
    342 
    343 	test "$curses" = "yes" -a $CONFIG_CURSES -ne 1 && fail "$0: cannot find libcurses"
    344 fi
    345 
    346 # libtermkey is a mandatory dependency
    347 
    348 printf "checking for libtermkey... "
    349 cat > "$tmpc" <<EOF
    350 #include <termkey.h>
    351 
    352 int main(int argc, char *argv[]) {
    353 	TERMKEY_CHECK_VERSION;
    354 	return 0;
    355 }
    356 EOF
    357 
    358 if test "$have_pkgconfig" = "yes" ; then
    359 	CFLAGS_TERMKEY=$(pkg-config --cflags termkey 2>/dev/null)
    360 	LDFLAGS_TERMKEY=$(pkg-config --libs termkey 2>/dev/null)
    361 fi
    362 
    363 if test -z "$LDFLAGS_TERMKEY"; then
    364 	CFLAGS_TERMKEY=""
    365 	LDFLAGS_TERMKEY="-ltermkey"
    366 fi
    367 
    368 if $CC $CFLAGS $CFLAGS_TERMKEY "$tmpc" $LDFLAGS $LDFLAGS_TERMKEY $LDFLAGS_CURSES \
    369 	-o "$tmpo" >/dev/null 2>&1; then
    370 	printf "%s\n" "yes"
    371 else
    372 	printf "%s\n" "no"
    373 	fail "$0: cannot find libtermkey"
    374 fi
    375 
    376 CONFIG_TRE=0
    377 REGEX_SRC=text-regex.c
    378 
    379 if test "$tre" != "no" ; then
    380 
    381 	printf "checking for libtre... "
    382 
    383 cat > "$tmpc" <<EOF
    384 #include <stddef.h>
    385 #include <tre/tre.h>
    386 
    387 int main() {
    388 	regex_t preg;
    389 	tre_str_source *source = NULL;
    390 	regmatch_t pmatch[1];
    391 	tre_regcomp(&preg, "\0", REG_EXTENDED);
    392 	tre_reguexec(&preg, source, 1, pmatch, 0);
    393 	tre_regfree(&preg);
    394 	return 0;
    395 }
    396 EOF
    397 
    398 	if test "$have_pkgconfig" = "yes" ; then
    399 		CFLAGS_TRE=$(pkg-config --cflags tre 2>/dev/null)
    400 		LDFLAGS_TRE=$(pkg-config --libs tre 2>/dev/null)
    401 	fi
    402 
    403 	if test -z "$LDFLAGS_TRE"; then
    404 		CFLAGS_TRE=""
    405 		LDFLAGS_TRE="-ltre"
    406 	fi
    407 
    408 	if $CC $CFLAGS $CFLAGS_TRE "$tmpc" \
    409 		$LDFLAGS $LDFLAGS_TRE -o "$tmpo" >/dev/null 2>&1; then
    410 		CONFIG_TRE=1
    411 		REGEX_SRC=text-regex-tre.c
    412 		printf "%s\n" "yes"
    413 	else
    414 		printf "%s\n" "no"
    415 		CFLAGS_TRE=""
    416 		LDFLAGS_TRE=""
    417 		test "$tre" = "yes" && fail "$0: cannot find libtre"
    418 	fi
    419 fi
    420 
    421 CONFIG_LUA=0
    422 
    423 # enabling builtin lpeg requires lua support
    424 test "$lpeg" = "yes" -a "$lua" = "no" && fail "$0: need lua support for built-in lpeg"
    425 test "$lpeg" = "yes" && lua=yes
    426 
    427 if test "$lua" != "no" ; then
    428 
    429 	printf "checking for liblua >= 5.2 ...\n"
    430 
    431 cat > "$tmpc" <<EOF
    432 #include <lua.h>
    433 #include <lualib.h>
    434 #include <lauxlib.h>
    435 
    436 #if LUA_VERSION_NUM < 502
    437 #error "Need at least Lua 5.2"
    438 #endif
    439 
    440 int main(int argc, char *argv[]) {
    441 	lua_State *L = luaL_newstate();
    442 	luaL_openlibs(L);
    443 	lua_close(L);
    444 	return 0;
    445 }
    446 EOF
    447 
    448 	for liblua in lua lua5.4 lua5.3 lua5.2 lua-5.4 lua-5.3 lua-5.2 lua54 lua53 lua52; do
    449 		printf " checking for %s... " "$liblua"
    450 
    451 		if test "$have_pkgconfig" = "yes" ; then
    452 			CFLAGS_LUA=$(pkg-config --cflags $liblua 2>/dev/null)
    453 			LDFLAGS_LUA=$(pkg-config --libs $liblua 2>/dev/null)
    454 			if test $? -eq 0 && $CC $CFLAGS $CFLAGS_LUA "$tmpc" \
    455 				$LDFLAGS $LDFLAGS_LUA -o "$tmpo" >/dev/null 2>&1 ; then
    456 				CONFIG_LUA=1
    457 				printf "yes\n"
    458 				break
    459 			fi
    460 		fi
    461 
    462 		CFLAGS_LUA=""
    463 		LDFLAGS_LUA="-l$liblua -lm -ldl"
    464 
    465 		if $CC $CFLAGS $CFLAGS_LUA "$tmpc" \
    466 			$LDFLAGS $LDFLAGS_LUA -o "$tmpo" >/dev/null 2>&1 ; then
    467 			CONFIG_LUA=1
    468 			printf "yes\n"
    469 			break
    470 		else
    471 			printf "no\n"
    472 			CFLAGS_LUA=""
    473 			LDFLAGS_LUA=""
    474 		fi
    475 	done
    476 
    477 	test "$lua" = "yes" -a $CONFIG_LUA -ne 1 && fail "$0: cannot find liblua"
    478 
    479 	if test $CONFIG_LUA -eq 1; then
    480 		CFLAGS_LUA="$CFLAGS_LUA -DLUA_COMPAT_5_1 -DLUA_COMPAT_5_2 -DLUA_COMPAT_5_3 -DLUA_COMPAT_ALL"
    481 	fi
    482 fi
    483 
    484 CONFIG_LPEG=0
    485 
    486 if test $CONFIG_LUA -eq 1 -a "$lpeg" != "no" ; then
    487 
    488 	printf "checking for Lua statically linked liblpeg...\n"
    489 
    490 cat > "$tmpc" <<EOF
    491 #include <lua.h>
    492 #include <lualib.h>
    493 #include <lauxlib.h>
    494 
    495 int main(int argc, char *argv[]) {
    496 	lua_State *L = luaL_newstate();
    497 	luaL_openlibs(L);
    498 	extern int luaopen_lpeg(lua_State *L);
    499 	lua_getglobal(L, "package");
    500 	lua_getfield(L, -1, "preload");
    501 	lua_pushcfunction(L, luaopen_lpeg);
    502 	lua_setfield(L, -2, "lpeg");
    503 	lua_pop(L, 2);
    504 	lua_close(L);
    505 	return 0;
    506 }
    507 EOF
    508 
    509 	for liblpeg in lpeg lua5.4-lpeg lua5.3-lpeg lua5.2-lpeg; do
    510 		printf " checking for static %s... " "$liblpeg"
    511 
    512 		if test "$have_pkgconfig" = "yes" ; then
    513 			CFLAGS_LPEG=$(pkg-config --cflags $liblpeg 2>/dev/null)
    514 			LDFLAGS_LPEG=$(pkg-config --libs $liblpeg 2>/dev/null)
    515 			if test $? -eq 0 && $CC $CFLAGS $CFLAGS_LUA $CFLAGS_LPEG "$tmpc" \
    516 				$LDFLAGS $LDFLAGS_LUA $LDFLAGS_LPEG -o "$tmpo" >/dev/null 2>&1 ; then
    517 				CONFIG_LPEG=1
    518 				printf "yes\n"
    519 				break
    520 			fi
    521 		fi
    522 
    523 		CFLAGS_LPEG=""
    524 		LDFLAGS_LPEG="-l$liblpeg"
    525 
    526 		if $CC $CFLAGS $CFLAGS_LUA $CFLAGS_LPEG "$tmpc" \
    527 			$LDFLAGS $LDFLAGS_LUA $LDFLAGS_LPEG -o "$tmpo" >/dev/null 2>&1 ; then
    528 			CONFIG_LPEG=1
    529 			printf "yes\n"
    530 			break
    531 		else
    532 			printf "no\n"
    533 			CFLAGS_LPEG=""
    534 			LDFLAGS_LPEG=""
    535 		fi
    536 	done
    537 
    538 	test "$lpeg" = "yes" -a $CONFIG_LPEG -ne 1 && fail "$0: cannot find liblpeg"
    539 fi
    540 
    541 CONFIG_ACL=0
    542 
    543 if test "$OS" = "Linux" -a "$acl" != "no"; then
    544 	printf "checking for libacl... "
    545 
    546 cat > "$tmpc" <<EOF
    547 #include <sys/types.h>
    548 #include <sys/acl.h>
    549 
    550 int main(int argc, char *argv[]) {
    551 	acl_t acl = acl_get_fd(0);
    552 	return 0;
    553 }
    554 EOF
    555 
    556 	if test "$have_pkgconfig" = "yes" ; then
    557 		CFLAGS_ACL=$(pkg-config --cflags acl 2>/dev/null)
    558 		LDFLAGS_ACL=$(pkg-config --libs acl 2>/dev/null)
    559 	fi
    560 
    561 	if test -z "$LDFLAGS_ACL"; then
    562 		CFLAGS_ACL=""
    563 		LDFLAGS_ACL="-lacl"
    564 	fi
    565 
    566 	if $CC $CFLAGS $CFLAGS_ACL "$tmpc" \
    567 		$LDFLAGS $LDFLAGS_ACL -o "$tmpo" >/dev/null 2>&1; then
    568 		CONFIG_ACL=1
    569 		printf "%s\n" "yes"
    570 	else
    571 		printf "%s\n" "no"
    572 		CFLAGS_ACL=""
    573 		LDFLAGS_ACL=""
    574 		test "$acl" = "yes" && fail "$0: cannot find libacl"
    575 	fi
    576 fi
    577 
    578 CONFIG_SELINUX=0
    579 
    580 if test "$OS" = "Linux" -a "$selinux" != "no"; then
    581 	printf "checking for libselinux... "
    582 
    583 cat > "$tmpc" <<EOF
    584 #include <selinux/selinux.h>
    585 
    586 int main(int argc, char *argv[]) {
    587 	return is_selinux_enabled();
    588 }
    589 EOF
    590 
    591 	if test "$have_pkgconfig" = "yes" ; then
    592 		CFLAGS_SELINUX=$(pkg-config --cflags selinux 2>/dev/null)
    593 		LDFLAGS_SELINUX=$(pkg-config --libs selinux 2>/dev/null)
    594 	fi
    595 
    596 	if test -z "$LDFLAGS_SELINUX"; then
    597 		CFLAGS_SELINUX=""
    598 		LDFLAGS_SELINUX="-lselinux"
    599 	fi
    600 
    601 	if $CC $CFLAGS $CFLAGS_SELINUX "$tmpc" \
    602 		$LDFLAGS $LDFLAGS_SELINUX -o "$tmpo" >/dev/null 2>&1; then
    603 		CONFIG_SELINUX=1
    604 		printf "%s\n" "yes"
    605 	else
    606 		printf "%s\n" "no"
    607 		CFLAGS_SELINUX=""
    608 		LDFLAGS_SELINUX=""
    609 		test "$selinux" = "yes" && fail "$0: cannot find libselinux"
    610 	fi
    611 fi
    612 
    613 printf "checking for memrchr... "
    614 
    615 cat > "$tmpc" <<EOF
    616 #define _GNU_SOURCE
    617 #include <string.h>
    618 
    619 int main(int argc, char *argv[]) {
    620         return !memrchr("\n", '\n', 1);
    621 }
    622 EOF
    623 
    624 if $CC $CFLAGS $CFLAGS_STD "$tmpc" $LDFLAGS -o "$tmpo" >/dev/null 2>&1; then
    625 	HAVE_MEMRCHR=1
    626 	printf "%s\n" "yes"
    627 else
    628 	HAVE_MEMRCHR=0
    629 	printf "%s\n" "no"
    630 fi
    631 
    632 printf "completing config.mk... "
    633 
    634 exec 3>&1 1>>config.mk
    635 
    636 cat << EOF
    637 CONFIG_HELP = $CONFIG_HELP
    638 CFLAGS_TERMKEY = $CFLAGS_TERMKEY
    639 LDFLAGS_TERMKEY = $LDFLAGS_TERMKEY
    640 CONFIG_CURSES = $CONFIG_CURSES
    641 CFLAGS_CURSES = $CFLAGS_CURSES
    642 LDFLAGS_CURSES = $LDFLAGS_CURSES
    643 REGEX_SRC = $REGEX_SRC
    644 CONFIG_TRE = $CONFIG_TRE
    645 CFLAGS_TRE = $CFLAGS_TRE
    646 LDFLAGS_TRE = $LDFLAGS_TRE
    647 CONFIG_LUA = $CONFIG_LUA
    648 CFLAGS_LUA = $CFLAGS_LUA
    649 LDFLAGS_LUA = $LDFLAGS_LUA
    650 CONFIG_LPEG = $CONFIG_LPEG
    651 CFLAGS_LPEG = $CFLAGS_LPEG
    652 LDFLAGS_LPEG = $LDFLAGS_LPEG
    653 CONFIG_ACL = $CONFIG_ACL
    654 CFLAGS_ACL = $CFLAGS_ACL
    655 LDFLAGS_ACL = $LDFLAGS_ACL
    656 CONFIG_SELINUX = $CONFIG_SELINUX
    657 CFLAGS_SELINUX = $CFLAGS_SELINUX
    658 LDFLAGS_SELINUX = $LDFLAGS_SELINUX
    659 CFLAGS_LIBC = -DHAVE_MEMRCHR=$HAVE_MEMRCHR
    660 EOF
    661 exec 1>&3 3>&-
    662 
    663 test "$SRCDIR" = "." || ln -sf $SRCDIR/Makefile .
    664 
    665 printf "done\n"