=================================================================== RCS file: /cvs/mandoc/configure,v retrieving revision 1.65 retrieving revision 1.70 diff -u -p -r1.65 -r1.70 --- mandoc/configure 2018/02/27 11:16:23 1.65 +++ mandoc/configure 2019/03/06 16:04:31 1.70 @@ -1,8 +1,8 @@ #!/bin/sh # -# $Id: configure,v 1.65 2018/02/27 11:16:23 schwarze Exp $ +# $Id: configure,v 1.70 2019/03/06 16:04:31 schwarze Exp $ # -# Copyright (c) 2014, 2015, 2016, 2017 Ingo Schwarze +# Copyright (c) 2014-2019 Ingo Schwarze # # Permission to use, copy, modify, and distribute this software for any # purpose with or without fee is hereby granted, provided that the above @@ -27,7 +27,7 @@ set -e # 3: config.log exec 3> config.log -echo "config.log: writing..." +echo "file config.log: writing..." # --- default settings ------------------------------------------------- # Initialize all variables here, @@ -37,18 +37,18 @@ SOURCEDIR=`dirname "$0"` MANPATH_BASE="/usr/share/man:/usr/X11R6/man" MANPATH_DEFAULT="/usr/share/man:/usr/X11R6/man:/usr/local/man" +OSENUM= OSNAME= UTF8_LOCALE= CC=`printf "all:\\n\\t@echo \\\$(CC)\\n" | env -i make -sf -` -CFLAGS="-g -W -Wall -Wmissing-prototypes -Wstrict-prototypes -Wwrite-strings" -CFLAGS="${CFLAGS} -Wno-unused-parameter" +CFLAGS= LDADD= LDFLAGS= LD_NANOSLEEP= LD_OHASH= LD_RECVMSG= -STATIC="-static" +STATIC= BUILD_CGI=0 BUILD_CATMAN=0 @@ -65,6 +65,7 @@ HAVE_FTS_COMPARE_CONST= HAVE_GETLINE= HAVE_GETSUBOPT= HAVE_ISBLANK= +HAVE_LESS_T= HAVE_MKDTEMP= HAVE_NANOSLEEP= HAVE_NTOHL= @@ -91,6 +92,9 @@ HAVE_SYS_ENDIAN= HAVE_VASPRINTF= HAVE_WCHAR= +NEED_GNU_SOURCE=0 +NEED_OPENBSD_SOURCE=0 + PREFIX="/usr/local" BINDIR= SBINDIR= @@ -127,27 +131,25 @@ LN="ln -f" # --- manual settings from configure.local ----------------------------- if [ -r ./configure.local ]; then - echo "configure.local: reading..." 1>&2 - echo "configure.local: reading..." 1>&3 + echo "file configure.local: reading..." 1>&2 + echo "file configure.local: reading..." 1>&3 cat ./configure.local 1>&3 . ./configure.local else - echo "configure.local: no (fully automatic configuration)" 1>&2 - echo "configure.local: no (fully automatic configuration)" 1>&3 + echo "file configure.local: no (fully automatic configuration)" 1>&2 + echo "file configure.local: no (fully automatic configuration)" 1>&3 fi echo 1>&3 -# --- tests for config.h ---------------------------------------------- +# --- tests functions -------------------------------------------------- -COMP="${CC} ${CFLAGS} -Wno-unused -Werror" - # Check whether this HAVE_ setting is manually overridden. # If yes, use the override, if no, do not decide anything yet. -# Arguments: lower-case test name, manual value +# Arguments: test file name, test var name, manual value ismanual() { [ -z "${3}" ] && return 1 - echo "${1}: manual (HAVE_${2}=${3})" 1>&2 - echo "${1}: manual (HAVE_${2}=${3})" 1>&3 + echo "tested ${1}: HAVE_${2}=${3} (manual)" 1>&2 + echo "tested ${1}: HAVE_${2}=${3} (manual)" 1>&3 echo 1>&3 return 0 } @@ -155,31 +157,36 @@ ismanual() { # Run a single autoconfiguration test. # In case of success, enable the feature. # In case of failure, do not decide anything yet. -# Arguments: lower-case test name, upper-case test name, additional CFLAGS +# Arguments: test file name, test var name, additional CFLAGS singletest() { + n=${1}${3}${4} cat 1>&3 << __HEREDOC__ -${1}${3}: testing... -${COMP} -o test-${1} test-${1}.c ${3} +testing ${n} ... +${COMP} -o test-${1} test-${1}.c ${3} ${4} __HEREDOC__ - if ${COMP} -o "test-${1}" "${SOURCEDIR}/test-${1}.c" ${3} 1>&3 2>&3 + if ${COMP} -o "test-${1}" "${SOURCEDIR}/test-${1}.c" ${3} ${4} 1>&3 2>&3 then - echo "${1}${3}: ${CC} succeeded" 1>&3 + echo "partial result of ${n}: ${CC} succeeded" 1>&3 else - echo "${1}${3}: ${CC} failed with $?" 1>&3 + echo "result of ${n}: ${CC} failed with exit status $?" 1>&3 + echo "result of compiling ${n}: no" 1>&3 echo 1>&3 return 1 fi if ./test-${1} 1>&3 2>&3; then - echo "${1}${3}: yes" 1>&2 - echo "${1}${3}: yes" 1>&3 + echo "tested ${n}: yes" 1>&2 + echo "result of running ${n}: yes" 1>&3 echo 1>&3 eval HAVE_${2}=1 + [ "X$3" = "X-D_GNU_SOURCE" ] && NEED_GNU_SOURCE=1 + [ "X$3" = "X-D_OPENBSD_SOURCE" ] && NEED_OPENBSD_SOURCE=1 rm "test-${1}" return 0 else - echo "${1}${3}: execution failed with $?" 1>&3 + echo "result of ${n}: execution failed with exit status $?" 1>&3 + echo "result of running ${n}: no" 1>&3 echo 1>&3 rm "test-${1}" return 1 @@ -188,12 +195,12 @@ __HEREDOC__ # Run a complete autoconfiguration test, including the check for # a manual override and disabling the feature on failure. -# Arguments: lower case name, upper case name, additional CFLAGS +# Arguments: test file name, test var name, additional CFLAGS runtest() { eval _manual=\${HAVE_${2}} ismanual "${1}" "${2}" "${_manual}" && return 0 - singletest "${1}" "${2}" "${3}" && return 0 - echo "${1}${3}: no" 1>&2 + singletest "${1}" "${2}" "${3}" "${4}" && return 0 + echo "tested ${1}${3}${4}: no" 1>&2 eval HAVE_${2}=0 return 1 } @@ -202,19 +209,79 @@ runtest() { get_locale() { [ -n "${HAVE_WCHAR}" ] && [ "${HAVE_WCHAR}" -eq 0 ] && return 0 ismanual UTF8_LOCALE UTF8_LOCALE "$UTF8_LOCALE" && return 0 - echo "UTF8_LOCALE: testing..." 1>&3 + echo "testing UTF8_LOCALE ..." 1>&3 UTF8_LOCALE=`locale -a | grep -i '^en_US\.UTF-*8$' | head -n 1` if [ -z "${UTF8_LOCALE}" ]; then UTF8_LOCALE=`locale -a | grep -i '\.UTF-*8' | head -n 1` [ -n "${UTF8_LOCALE}" ] || return 1 fi - echo "UTF8_LOCALE=${UTF8_LOCALE}" 1>&2 - echo "UTF8_LOCALE=${UTF8_LOCALE}" 1>&3 + echo "selected UTF8_LOCALE=${UTF8_LOCALE}" 1>&2 + echo "selected UTF8_LOCALE=${UTF8_LOCALE}" 1>&3 echo 1>&3 return 0; } +# --- operating system ------------------------------------------------- +if [ -n "${OSENUM}" ]; then + echo "OSENUM specified manually: ${OSENUM}" 1>&2 + echo "OSENUM specified manually: ${OSENUM}" 1>&3 +else + OSDETECT=`uname` + if [ "X${OSDETECT}" = "XNetBSD" ]; then + OSENUM=MANDOC_OS_NETBSD + elif [ "X${OSDETECT}" = "XOpenBSD" ]; then + OSENUM=MANDOC_OS_OPENBSD + else + OSENUM=MANDOC_OS_OTHER + fi + echo "tested operating system: ${OSDETECT} -> OSENUM=${OSENUM}" 1>&2 + echo "tested operating system: ${OSDETECT} -> OSENUM=${OSENUM}" 1>&3 + unset OSDETECT +fi +echo 1>&3 + +# --- compiler options ------------------------------------------------- + +DEFCFLAGS="-g -W -Wall -Wmissing-prototypes -Wstrict-prototypes -Wwrite-strings -Wno-unused-parameter" + +if [ -n "${CFLAGS}" ]; then + COMP="${CC} ${CFLAGS} -Wno-unused -Werror" +else + COMP="${CC} ${DEFCFLAGS} -Wno-unused -Werror" +fi +echo -n "tested ${CC} -W: " 1>&2 +echo -n "testing ${CC} -W: " 1>&3 +runtest noop WFLAG || true + +if [ -n "${CFLAGS}" ]; then + echo "CFLAGS specified manually:" 1>&3 +elif [ ${HAVE_WFLAG} -eq 0 ]; then + CFLAGS="-g" +else + CFLAGS="${DEFCFLAGS}" +fi +echo "selected CFLAGS=\"${CFLAGS}\"" 1>&2 +echo "selected CFLAGS=\"${CFLAGS}\"" 1>&3 +echo 1>&3 + +COMP="${CC} ${CFLAGS}" +[ ${HAVE_WFLAG} -eq 0 ] || COMP="${COMP} -Wno-unused -Werror" + +if [ -n "${STATIC}" ]; then + echo "selected STATIC=\"${STATIC}\" (manual)" 1>&2 + echo "selected STATIC=\"${STATIC}\" (manual)" 1>&3 + echo 1>&3 +else + runtest noop STATIC -static || true + [ ${HAVE_STATIC} -eq 0 ] || STATIC="-static" + echo "selected STATIC=\"${STATIC}\"" 1>&2 + echo "selected STATIC=\"${STATIC}\"" 1>&3 + echo 1>&3 +fi + +# --- tests for config.h ---------------------------------------------- + # --- library functions --- runtest dirent-namlen DIRENT_NAMLEN || true runtest be32toh ENDIAN || true @@ -222,7 +289,8 @@ runtest be32toh SYS_ENDIAN -DSYS_ENDIAN || true runtest EFTYPE EFTYPE || true runtest err ERR || true runtest getline GETLINE || true -runtest getsubopt GETSUBOPT || true +singletest getsubopt GETSUBOPT || \ + runtest getsubopt GETSUBOPT -D_GNU_SOURCE || true runtest isblank ISBLANK || true runtest mkdtemp MKDTEMP || true runtest ntohl NTOHL || true @@ -231,19 +299,25 @@ runtest PATH_MAX PATH_MAX || true runtest pledge PLEDGE || true runtest sandbox_init SANDBOX_INIT || true runtest progname PROGNAME || true -runtest reallocarray REALLOCARRAY || true -runtest recallocarray RECALLOCARRAY || true +singletest reallocarray REALLOCARRAY || \ + runtest reallocarray REALLOCARRAY -D_OPENBSD_SOURCE || true +singletest recallocarray RECALLOCARRAY || \ + runtest recallocarray RECALLOCARRAY -D_OPENBSD_SOURCE || true runtest rewb-bsd REWB_BSD || true runtest rewb-sysv REWB_SYSV || true -runtest strcasestr STRCASESTR || true +singletest strcasestr STRCASESTR || \ + runtest strcasestr STRCASESTR -D_GNU_SOURCE || true runtest stringlist STRINGLIST || true runtest strlcat STRLCAT || true runtest strlcpy STRLCPY || true runtest strndup STRNDUP || true -runtest strptime STRPTIME || true +singletest strptime STRPTIME || \ + runtest strptime STRPTIME -D_GNU_SOURCE || true runtest strsep STRSEP || true -runtest strtonum STRTONUM || true -runtest vasprintf VASPRINTF || true +singletest strtonum STRTONUM || \ + runtest strtonum STRTONUM -D_OPENBSD_SOURCE || true +singletest vasprintf VASPRINTF || \ + runtest vasprintf VASPRINTF -D_GNU_SOURCE || true if [ ${HAVE_ENDIAN} -eq 0 -a \ ${HAVE_SYS_ENDIAN} -eq 0 -a \ @@ -261,13 +335,30 @@ else runtest fts FTS || true fi +if ismanual "less -T" LESS_T ${HAVE_LESS_T}; then + : +elif less -ET /dev/null test-noop.c 1>/dev/null 2>&3; then + HAVE_LESS_T=1 + echo "tested less -T: yes" 1>&2 + echo "tested less -T: yes" 1>&3 + echo 1>&3 +else + HAVE_LESS_T=0 + echo "tested less -T: no" 1>&2 + echo "tested less -T: no" 1>&3 + echo 1>&3 +fi + # --- wide character and locale support --- if get_locale; then - runtest wchar WCHAR -DUTF8_LOCALE=\"${UTF8_LOCALE}\" || true + singletest wchar WCHAR -DUTF8_LOCALE=\"${UTF8_LOCALE}\" || \ + runtest wchar WCHAR -D_GNU_SOURCE \ + -DUTF8_LOCALE=\"${UTF8_LOCALE}\" || true else HAVE_WCHAR=0 - echo "wchar: no (no UTF8_LOCALE)" 1>&2 - echo "wchar: no (no UTF8_LOCALE)" 1>&3 + echo "tested wchar: no (no UTF8_LOCALE)" 1>&2 + echo "tested wchar: no (no UTF8_LOCALE)" 1>&3 + echo 1>&3 fi # --- nanosleep --- @@ -330,8 +421,8 @@ fi # --- LDADD --- LDADD="${LDADD} ${LD_NANOSLEEP} ${LD_RECVMSG} ${LD_OHASH} -lz" -echo "LDADD=\"${LDADD}\"" 1>&2 -echo "LDADD=\"${LDADD}\"" 1>&3 +echo "selected LDADD=\"${LDADD}\"" 1>&2 +echo "selected LDADD=\"${LDADD}\"" 1>&3 echo 1>&3 # --- write config.h --- @@ -347,12 +438,11 @@ cat << __HEREDOC__ #define __attribute__(x) #endif -#if defined(__linux__) || defined(__MINT__) -#define _GNU_SOURCE /* See test-*.c what needs this. */ -#endif - __HEREDOC__ +[ ${NEED_GNU_SOURCE} -eq 0 ] || echo "#define _GNU_SOURCE" +[ ${NEED_OPENBSD_SOURCE} -eq 0 ] || echo "#define _OPENBSD_SOURCE" + [ ${HAVE_GETLINE} -eq 0 -o \ ${HAVE_REALLOCARRAY} -eq 0 -o ${HAVE_RECALLOCARRAY} -eq 0 -o \ ${HAVE_STRLCAT} -eq 0 -o ${HAVE_STRLCPY} -eq 0 -o \ @@ -365,6 +455,7 @@ echo echo "#define MAN_CONF_FILE \"/etc/${MANM_MANCONF}\"" echo "#define MANPATH_BASE \"${MANPATH_BASE}\"" echo "#define MANPATH_DEFAULT \"${MANPATH_DEFAULT}\"" +echo "#define OSENUM ${OSENUM}" [ -n "${OSNAME}" ] && echo "#define OSNAME \"${OSNAME}\"" [ -n "${UTF8_LOCALE}" ] && echo "#define UTF8_LOCALE \"${UTF8_LOCALE}\"" [ -n "${HOMEBREWDIR}" ] && echo "#define HOMEBREWDIR \"${HOMEBREWDIR}\"" @@ -386,6 +477,7 @@ cat << __HEREDOC__ #define HAVE_GETLINE ${HAVE_GETLINE} #define HAVE_GETSUBOPT ${HAVE_GETSUBOPT} #define HAVE_ISBLANK ${HAVE_ISBLANK} +#define HAVE_LESS_T ${HAVE_LESS_T} #define HAVE_MKDTEMP ${HAVE_MKDTEMP} #define HAVE_NTOHL ${HAVE_NTOHL} #define HAVE_PLEDGE ${HAVE_PLEDGE} @@ -468,8 +560,8 @@ fi [ ${HAVE_VASPRINTF} -eq 0 ] && \ echo "extern int vasprintf(char **, const char *, va_list);" -echo "config.h: written" 1>&2 -echo "config.h: written" 1>&3 +echo "file config.h: written" 1>&2 +echo "file config.h: written" 1>&3 # --- tests for Makefile.local ----------------------------------------- @@ -538,7 +630,7 @@ INSTALL_DATA = ${INSTALL_DATA} LN = ${LN} __HEREDOC__ -echo "Makefile.local: written" 1>&2 -echo "Makefile.local: written" 1>&3 +echo "file Makefile.local: written" 1>&2 +echo "file Makefile.local: written" 1>&3 exit 0