[BACK]Return to configure CVS log [TXT][DIR] Up to [cvsweb.bsd.lv] / mandoc

Diff for /mandoc/configure between version 1.3 and 1.54

version 1.3, 2014/04/23 21:06:41 version 1.54, 2016/11/19 15:24:51
Line 1 
Line 1 
 #!/bin/sh  #!/bin/sh
 #  #
 # Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org>  # $Id$
 #  #
   # Copyright (c) 2014, 2015, 2016 Ingo Schwarze <schwarze@openbsd.org>
   #
 # Permission to use, copy, modify, and distribute this software for any  # Permission to use, copy, modify, and distribute this software for any
 # purpose with or without fee is hereby granted, provided that the above  # purpose with or without fee is hereby granted, provided that the above
 # copyright notice and this permission notice appear in all copies.  # copyright notice and this permission notice appear in all copies.
Line 15 
Line 17 
 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.  # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
   
 set -e  set -e
 exec > config.h 2> config.log  
   
 CFLAGS="${CFLAGS} -Wno-unused -Werror"  [ -w config.log ] && mv config.log config.log.old
   [ -w config.h   ] && mv config.h config.h.old
   
   # Output file descriptor usage:
   # 1 (stdout): config.h, Makefile.local
   # 2 (stderr): original stderr, usually to the console
   # 3: config.log
   
   exec 3> config.log
   echo "config.log: writing..."
   
   # --- default settings -------------------------------------------------
   # Initialize all variables here,
   # such that nothing can leak in from the environment.
   
   MANPATH_DEFAULT="/usr/share/man:/usr/X11R6/man:/usr/local/man"
   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"
   LDADD=
   LDFLAGS=
   LD_NANOSLEEP=
   LD_OHASH=
   STATIC="-static"
   
   BUILD_CGI=0
   INSTALL_LIBMANDOC=0
   
   HAVE_DIRENT_NAMLEN=
   HAVE_EFTYPE=
   HAVE_ENDIAN=
   HAVE_ERR=
   HAVE_FTS=
   HAVE_FTS_COMPARE_CONST=
   HAVE_GETLINE=
   HAVE_GETSUBOPT=
   HAVE_ISBLANK=
   HAVE_MKDTEMP=
   HAVE_NANOSLEEP=
   HAVE_NTOHL=
   HAVE_OHASH=
   HAVE_PATH_MAX=
   HAVE_PLEDGE=
   HAVE_PROGNAME=
   HAVE_REALLOCARRAY=
   HAVE_REWB_BSD=
   HAVE_REWB_SYSV=
   HAVE_SANDBOX_INIT=
   HAVE_STRCASESTR=
   HAVE_STRINGLIST=
   HAVE_STRLCAT=
   HAVE_STRLCPY=
   HAVE_STRPTIME=
   HAVE_STRSEP=
   HAVE_STRTONUM=
   HAVE_SYS_ENDIAN=
   HAVE_VASPRINTF=
   HAVE_WCHAR=
   
   PREFIX="/usr/local"
   BINDIR=
   SBINDIR=
   INCLUDEDIR=
   LIBDIR=
   MANDIR=
   HOMEBREWDIR=
   
   WWWPREFIX="/var/www"
   HTDOCDIR=
   CGIBINDIR=
   
   BINM_APROPOS="apropos"
   BINM_MAKEWHATIS="makewhatis"
   BINM_MAN="man"
   BINM_SOELIM="soelim"
   BINM_WHATIS="whatis"
   MANM_MAN="man"
   MANM_MANCONF="man.conf"
   MANM_MDOC="mdoc"
   MANM_ROFF="roff"
   MANM_EQN="eqn"
   MANM_TBL="tbl"
   
   INSTALL="install"
   INSTALL_PROGRAM=
   INSTALL_LIB=
   INSTALL_MAN=
   INSTALL_DATA=
   
   # --- manual settings from configure.local -----------------------------
   
   if [ -r ./configure.local ]; then
           echo "configure.local: reading..." 1>&2
           echo "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
   fi
   echo 1>&3
   
   # --- tests for config.h  ----------------------------------------------
   
   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
   ismanual() {
           [ -z "${3}" ] && return 1
           echo "${1}: manual (HAVE_${2}=${3})" 1>&2
           echo "${1}: manual (HAVE_${2}=${3})" 1>&3
           echo 1>&3
           return 0
   }
   
   # 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
   singletest() {
           cat 1>&3 << __HEREDOC__
   ${1}${3}: testing...
   ${COMP} ${3} -o test-${1} test-${1}.c
   __HEREDOC__
   
           if ${COMP} ${3} -o "test-${1}" "test-${1}.c" 1>&3 2>&3; then
                   echo "${1}${3}: ${CC} succeeded" 1>&3
           else
                   echo "${1}${3}: ${CC} failed with $?" 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 1>&3
                   eval HAVE_${2}=1
                   rm "test-${1}"
                   return 0
           else
                   echo "${1}${3}: execution failed with $?" 1>&3
                   echo 1>&3
                   rm "test-${1}"
                   return 1
           fi
   }
   
   # 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
 runtest() {  runtest() {
         echo ${CC} ${CFLAGS} -o test-${1} test-${1}.c 1>&2          eval _manual=\${HAVE_${2}}
         ${CC} ${CFLAGS} -o "test-${1}" "test-${1}.c" 1>&2 || return 0          ismanual "${1}" "${2}" "${_manual}" && return 0
         "./test-${1}" && echo "#define HAVE_${2}" \          singletest "${1}" "${2}" "${3}" && return 0
                 || echo FAILURE: test-${1} returned $? 1>&2          echo "${1}${3}: no" 1>&2
         rm "test-${1}"          eval HAVE_${2}=0
           return 1
 }  }
   
 cat config.h.pre  # Select a UTF-8 locale.
   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
           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 1>&3
           return 0;
   }
   
   
   # --- library functions ---
   runtest dirent-namlen   DIRENT_NAMLEN   || true
   runtest be32toh         ENDIAN          || true
   runtest be32toh         SYS_ENDIAN      -DSYS_ENDIAN || true
   runtest EFTYPE          EFTYPE          || true
   runtest err             ERR             || true
   runtest getline         GETLINE         || true
   runtest getsubopt       GETSUBOPT       || true
   runtest isblank         ISBLANK         || true
   runtest mkdtemp         MKDTEMP         || true
   runtest ntohl           NTOHL           || true
   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 rewb-bsd        REWB_BSD        || true
   runtest rewb-sysv       REWB_SYSV       || true
   runtest strcasestr      STRCASESTR      || true
   runtest stringlist      STRINGLIST      || true
   runtest strlcat         STRLCAT         || true
   runtest strlcpy         STRLCPY         || true
   runtest strptime        STRPTIME        || true
   runtest strsep          STRSEP          || true
   runtest strtonum        STRTONUM        || true
   runtest vasprintf       VASPRINTF       || true
   
   if [ ${HAVE_ENDIAN} -eq 0 -a \
        ${HAVE_SYS_ENDIAN} -eq 0 -a \
        ${HAVE_NTOHL} -eq 0 ]; then
           echo "FATAL: no endian conversion functions found" 1>&2
           echo "FATAL: no endian conversion functions found" 1>&3
           exit 1
   fi
   
   if ismanual fts FTS ${HAVE_FTS}; then
           HAVE_FTS_COMPARE_CONST=0
   elif runtest fts FTS_COMPARE_CONST -DFTS_COMPARE_CONST; then
           HAVE_FTS=1
   else
           runtest fts FTS || true
   fi
   
   # --- wide character and locale support ---
   if get_locale; then
           runtest wchar WCHAR -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
   fi
   
   # --- nanosleep ---
   if [ -n "${LD_NANOSLEEP}" ]; then
           runtest nanosleep NANOSLEEP "${LD_NANOSLEEP}" || true
   elif singletest nanosleep NANOSLEEP; then
           :
   elif runtest nanosleep NANOSLEEP "-lrt"; then
           LD_NANOSLEEP="-lrt"
   fi
   if [ "${HAVE_NANOSLEEP}" -eq 0 ]; then
           echo "FATAL: nanosleep: no" 1>&2
           echo "FATAL: nanosleep: no" 1>&3
           exit 1
   fi
   
   # --- ohash ---
   if ismanual ohash OHASH "${HAVE_OHASH}"; then
           :
   elif [ -n "${LD_OHASH}" ]; then
           runtest ohash OHASH "${LD_OHASH}" || true
   elif singletest ohash OHASH; then
           :
   elif runtest ohash OHASH "-lutil"; then
           LD_OHASH="-lutil"
   fi
   if [ "${HAVE_OHASH}" -eq 0 ]; then
           LD_OHASH=
   fi
   
   # --- LDADD ---
   LDADD="${LDADD} ${LD_NANOSLEEP} ${LD_OHASH} -lz"
   echo "LDADD=\"${LDADD}\"" 1>&2
   echo "LDADD=\"${LDADD}\"" 1>&3
   echo 1>&3
   
   # --- write config.h ---
   
   exec > config.h
   
   cat << __HEREDOC__
   #ifdef __cplusplus
   #error "Do not use C++.  See the INSTALL file."
   #endif
   
   #if !defined(__GNUC__) || (__GNUC__ < 4)
   #define __attribute__(x)
   #endif
   
   #if defined(__linux__) || defined(__MINT__)
   #define _GNU_SOURCE     /* See test-*.c what needs this. */
   #endif
   
   __HEREDOC__
   
   [ ${HAVE_GETLINE} -eq 0 -o ${HAVE_REALLOCARRAY} -eq 0 -o \
     ${HAVE_STRLCAT} -eq 0 -o ${HAVE_STRLCPY} -eq 0 ] \
           && echo "#include <sys/types.h>"
   [ ${HAVE_VASPRINTF} -eq 0 ] && echo "#include <stdarg.h>"
   [ ${HAVE_GETLINE} -eq 0 ] && echo "#include <stdio.h>"
   
 echo  echo
 echo "#define VERSION \"${VERSION}\""  echo "#define MAN_CONF_FILE \"/etc/${MANM_MANCONF}\""
 runtest fgetln FGETLN  echo "#define MANPATH_DEFAULT \"${MANPATH_DEFAULT}\""
 runtest getsubopt GETSUBOPT  [ -n "${OSNAME}" ] && echo "#define OSNAME \"${OSNAME}\""
 runtest mmap MMAP  [ -n "${UTF8_LOCALE}" ] && echo "#define UTF8_LOCALE \"${UTF8_LOCALE}\""
 runtest ohash OHASH  [ -n "${HOMEBREWDIR}" ] && echo "#define HOMEBREWDIR \"${HOMEBREWDIR}\""
 runtest reallocarray REALLOCARRAY  [ ${HAVE_EFTYPE} -eq 0 ] && echo "#define EFTYPE EINVAL"
 runtest strcasestr STRCASESTR  [ ${HAVE_PATH_MAX} -eq 0 ] && echo "#define PATH_MAX 4096"
 runtest strlcat STRLCAT  if [ ${HAVE_ENDIAN} -eq 0 -a ${HAVE_SYS_ENDIAN} -eq 0 ]; then
 runtest strlcpy STRLCPY          echo "#define be32toh ntohl"
 runtest strnlen STRNLEN          echo "#define htobe32 htonl"
 runtest strptime STRPTIME  fi
 runtest strsep STRSEP  
 echo  cat << __HEREDOC__
 cat config.h.post  #define HAVE_DIRENT_NAMLEN ${HAVE_DIRENT_NAMLEN}
   #define HAVE_ENDIAN ${HAVE_ENDIAN}
   #define HAVE_ERR ${HAVE_ERR}
   #define HAVE_FTS ${HAVE_FTS}
   #define HAVE_FTS_COMPARE_CONST ${HAVE_FTS_COMPARE_CONST}
   #define HAVE_GETLINE ${HAVE_GETLINE}
   #define HAVE_GETSUBOPT ${HAVE_GETSUBOPT}
   #define HAVE_ISBLANK ${HAVE_ISBLANK}
   #define HAVE_MKDTEMP ${HAVE_MKDTEMP}
   #define HAVE_NTOHL ${HAVE_NTOHL}
   #define HAVE_PLEDGE ${HAVE_PLEDGE}
   #define HAVE_PROGNAME ${HAVE_PROGNAME}
   #define HAVE_REALLOCARRAY ${HAVE_REALLOCARRAY}
   #define HAVE_REWB_BSD ${HAVE_REWB_BSD}
   #define HAVE_REWB_SYSV ${HAVE_REWB_SYSV}
   #define HAVE_SANDBOX_INIT ${HAVE_SANDBOX_INIT}
   #define HAVE_STRCASESTR ${HAVE_STRCASESTR}
   #define HAVE_STRINGLIST ${HAVE_STRINGLIST}
   #define HAVE_STRLCAT ${HAVE_STRLCAT}
   #define HAVE_STRLCPY ${HAVE_STRLCPY}
   #define HAVE_STRPTIME ${HAVE_STRPTIME}
   #define HAVE_STRSEP ${HAVE_STRSEP}
   #define HAVE_STRTONUM ${HAVE_STRTONUM}
   #define HAVE_SYS_ENDIAN ${HAVE_SYS_ENDIAN}
   #define HAVE_VASPRINTF ${HAVE_VASPRINTF}
   #define HAVE_WCHAR ${HAVE_WCHAR}
   #define HAVE_OHASH ${HAVE_OHASH}
   
   #define BINM_APROPOS "${BINM_APROPOS}"
   #define BINM_MAKEWHATIS "${BINM_MAKEWHATIS}"
   #define BINM_MAN "${BINM_MAN}"
   #define BINM_SOELIM "${BINM_SOELIM}"
   #define BINM_WHATIS "${BINM_WHATIS}"
   
   __HEREDOC__
   
   if [ ${HAVE_ERR} -eq 0 ]; then
           echo "extern    void      err(int, const char *, ...);"
           echo "extern    void      errx(int, const char *, ...);"
           echo "extern    void      warn(const char *, ...);"
           echo "extern    void      warnx(const char *, ...);"
   fi
   
   [ ${HAVE_GETLINE} -eq 0 ] && \
           echo "extern    ssize_t   getline(char **, size_t *, FILE *);"
   
   [ ${HAVE_GETSUBOPT} -eq 0 ] && \
           echo "extern    int       getsubopt(char **, char * const *, char **);"
   
   [ ${HAVE_ISBLANK} -eq 0 ] && \
           echo "extern    int       isblank(int);"
   
   [ ${HAVE_MKDTEMP} -eq 0 ] && \
           echo "extern    char     *mkdtemp(char *);"
   
   if [ ${HAVE_PROGNAME} -eq 0 ]; then
           echo "extern    const char *getprogname(void);"
           echo "extern    void      setprogname(const char *);"
   fi
   
   [ ${HAVE_REALLOCARRAY} -eq 0 ] && \
           echo "extern    void     *reallocarray(void *, size_t, size_t);"
   
   [ ${HAVE_STRCASESTR} -eq 0 ] && \
           echo "extern    char     *strcasestr(const char *, const char *);"
   
   [ ${HAVE_STRLCAT} -eq 0 ] && \
           echo "extern    size_t    strlcat(char *, const char *, size_t);"
   
   [ ${HAVE_STRLCPY} -eq 0 ] && \
           echo "extern    size_t    strlcpy(char *, const char *, size_t);"
   
   [ ${HAVE_STRSEP} -eq 0 ] && \
           echo "extern    char     *strsep(char **, const char *);"
   
   [ ${HAVE_STRTONUM} -eq 0 ] && \
           echo "extern    long long strtonum(const char *, long long, long long, const char **);"
   
   [ ${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
   
   # --- tests for Makefile.local -----------------------------------------
   
   exec > Makefile.local
   
   [ -z "${BINDIR}"     ] && BINDIR="${PREFIX}/bin"
   [ -z "${SBINDIR}"    ] && SBINDIR="${PREFIX}/sbin"
   [ -z "${INCLUDEDIR}" ] && INCLUDEDIR="${PREFIX}/include/mandoc"
   [ -z "${LIBDIR}"     ] && LIBDIR="${PREFIX}/lib/mandoc"
   [ -z "${MANDIR}"     ] && MANDIR="${PREFIX}/man"
   
   [ -z "${HTDOCDIR}"   ] && HTDOCDIR="${WWWPREFIX}/htdocs"
   [ -z "${CGIBINDIR}"  ] && CGIBINDIR="${WWWPREFIX}/cgi-bin"
   
   [ -z "${INSTALL_PROGRAM}" ] && INSTALL_PROGRAM="${INSTALL} -m 0555"
   [ -z "${INSTALL_LIB}"     ] && INSTALL_LIB="${INSTALL} -m 0444"
   [ -z "${INSTALL_MAN}"     ] && INSTALL_MAN="${INSTALL} -m 0444"
   [ -z "${INSTALL_DATA}"    ] && INSTALL_DATA="${INSTALL} -m 0444"
   
   BUILD_TARGETS=
   [ ${BUILD_CGI} -gt 0 ] && BUILD_TARGETS="cgi-build"
   INSTALL_TARGETS=
   [ ${INSTALL_LIBMANDOC} -gt 0 ] && INSTALL_TARGETS="lib-install"
   [ ${BUILD_CGI} -gt 0 ] && INSTALL_TARGETS="${INSTALL_TARGETS} cgi-install"
   
   cat << __HEREDOC__
   BUILD_TARGETS   = ${BUILD_TARGETS}
   INSTALL_TARGETS = ${INSTALL_TARGETS}
   CC              = ${CC}
   CFLAGS          = ${CFLAGS}
   LDADD           = ${LDADD}
   LDFLAGS         = ${LDFLAGS}
   STATIC          = ${STATIC}
   PREFIX          = ${PREFIX}
   BINDIR          = ${BINDIR}
   SBINDIR         = ${SBINDIR}
   INCLUDEDIR      = ${INCLUDEDIR}
   LIBDIR          = ${LIBDIR}
   MANDIR          = ${MANDIR}
   WWWPREFIX       = ${WWWPREFIX}
   HTDOCDIR        = ${HTDOCDIR}
   CGIBINDIR       = ${CGIBINDIR}
   BINM_APROPOS    = ${BINM_APROPOS}
   BINM_MAKEWHATIS = ${BINM_MAKEWHATIS}
   BINM_MAN        = ${BINM_MAN}
   BINM_SOELIM     = ${BINM_SOELIM}
   BINM_WHATIS     = ${BINM_WHATIS}
   MANM_MAN        = ${MANM_MAN}
   MANM_MANCONF    = ${MANM_MANCONF}
   MANM_MDOC       = ${MANM_MDOC}
   MANM_ROFF       = ${MANM_ROFF}
   MANM_EQN        = ${MANM_EQN}
   MANM_TBL        = ${MANM_TBL}
   INSTALL         = ${INSTALL}
   INSTALL_PROGRAM = ${INSTALL_PROGRAM}
   INSTALL_LIB     = ${INSTALL_LIB}
   INSTALL_MAN     = ${INSTALL_MAN}
   INSTALL_DATA    = ${INSTALL_DATA}
   __HEREDOC__
   
   echo "Makefile.local: written" 1>&2
   echo "Makefile.local: written" 1>&3
   
 exit 0  exit 0

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.54

CVSweb