File Info

Rev. efeab20e689880041b1ce76d479bb22c776d3f74
Size 32,188 bytes
Time 2020-07-04 19:41:12
Author simphone
Log Message

simphone 0.8.1

Content

AC_PREREQ([2.59])
AC_COPYRIGHT([Copyright (c) 2020 The Creators of Simphone])
AC_INIT([simcore], [0.8.1])
AC_CONFIG_SRCDIR([simcore/simc.c])
AC_CONFIG_HEADERS([simcore/config.h])

## always load config.cache but save it ONLY if started with --config-cache
#old_cache_file=$cache_file
#cache_file=config.cache
#AC_CACHE_LOAD
#cache_file=$old_cache_file
## end of config.cache hack

config_cache=
if test "x$cache_file" = "xconfig.cache"; then
  config_cache=--config-cache
fi

# cross-compilation
ALLARGS=$*
XXFLAGS=
while test $# -gt 0; do
  arg=`echo $1 | cut -d = -f 1`
  case "$arg" in
    --host) XXFLAGS="$XXFLAGS $1";;
    --target) XXFLAGS="$XXFLAGS $1";;
    --build) XXFLAGS="$XXFLAGS $1";;
  esac
  shift
done

CFLAGS=
CPUFLAGS=
ARCHFLAGS="-ffunction-sections -fdata-sections"
AC_PROG_CXX([g++ eg++ c++])
AC_PROG_CC([gcc egcc cc])
AC_PROG_MAKE_SET

AC_CHECK_SIZEOF([void *])

AC_SUBST(LD)
AC_SUBST(LIBS)
AC_SUBST(LIBRARIES)
AC_SUBST(GUI)
AC_SUBST(NPTH)
AC_SUBST(EFENCE)
AC_SUBST(OPENSSL)
AC_SUBST(MAKEDEPEND)
AC_SUBST(CRYPTOPP)
AC_SUBST(CRYPTOPPCLEAN)
AC_SUBST(EXPAT)
AC_SUBST(CARES)
AC_SUBST(EXPATCLEAN)
AC_SUBST(CARESCLEAN)
AC_SUBST(SPEEX)
AC_SUBST(SPEEXCLEAN)
AC_SUBST(SPEEXDSP)
AC_SUBST(SPEEXDSPCLEAN)
AC_SUBST(PORTAUDIO)
AC_SUBST(PORTAUDIOCLEAN)
AC_SUBST(MINIUPNPC)
AC_SUBST(MINIUPNPCCLEAN)
AC_SUBST(CFLAGS)
AC_SUBST(CPPFLAGS)
AC_SUBST(CPUFLAGS)
AC_SUBST(ARCHFLAGS)
AC_SUBST(LDFLAGS)
AC_SUBST(DEFINES)
AC_SUBST(OBJECTS)
AC_SUBST(INCLUDES)

DEFINES=
OBJECTS=
INCLUDES=

AC_ARG_WITH([install-exec])
AC_ARG_WITH([qt], [AS_HELP_STRING([--with-qt], [use system-built Qt])])
AC_ARG_WITH([qt], [AS_HELP_STRING([--without-qt], [do not compile GUI])])
AC_ARG_WITH([ips], [AS_HELP_STRING([--without-ips], [do not include ip address database])])
AC_ARG_WITH([tray], [AS_HELP_STRING([--without-tray], [disable tray icon])])
AC_ARG_WITH([xss], [AS_HELP_STRING([--without-xss], [disable auto-away on unix])])
AC_ARG_WITH([xcb], [AS_HELP_STRING([--without-xcb], [disable global hotkeys on unix])])
AC_ARG_WITH([crash-handler], [AS_HELP_STRING([--without-crash-handler], [do not compile crash reporter])])
AC_ARG_WITH([backtrace], [AS_HELP_STRING([--without-backtrace], [no stack trace on crash])])
AC_ARG_WITH([threads], [AS_HELP_STRING([--without-threads], [build single-thread version])])
AC_ARG_WITH([pth], [AS_HELP_STRING([--without-pth], [do not use libpth even if available])])
AC_ARG_WITH([makedepend], [AS_HELP_STRING([--without-makedepend], [do not configure makedepend])])
AC_ARG_WITH([config-ssl], [AS_HELP_STRING([--without-config-ssl], [do not (re)configure openssl])])
AC_ARG_WITH([audio], [AS_HELP_STRING([--without-audio], [disable audio support])])
AC_ARG_WITH([udev], [AS_HELP_STRING([--without-udev], [disable linux audio PNP support])])
AC_ARG_WITH([alsa], [AS_HELP_STRING([--without-alsa], [do not use Advanced Linux Sound Architecture])])
AC_ARG_WITH([oss], [AS_HELP_STRING([--without-oss], [do not use the Open Sound System])])
AC_ARG_WITH([portaudio], [AS_HELP_STRING([--with-portaudio], [use system-built portaudio])])
AC_ARG_WITH([speex], [AS_HELP_STRING([--with-speex], [use system-built libspeex])])
AC_ARG_WITH([miniupnpc], [AS_HELP_STRING([--with-miniupnpc], [use system-built miniupnpc])])
AC_ARG_WITH([expat], [AS_HELP_STRING([--with-expat], [use system-built libexpat])])
AC_ARG_WITH([cares], [AS_HELP_STRING([--with-cares], [use system-built libcares])])
AC_ARG_WITH([debug], [AS_HELP_STRING([--with-debug], [enable debug information])])
AC_ARG_WITH([rlink], [AS_HELP_STRING([--with-rlink], [enable linker optimization script])])
AC_ARG_WITH([efence], [AS_HELP_STRING([--with-efence], [enable memory allocation checking])])
AC_ARG_WITH([bounds-check], [AS_HELP_STRING([--with-bounds-check], [check bounds. requires a special gcc version])])
AC_ARG_WITH([memory-check], [AS_HELP_STRING([--with-memory-check], [enable memory leak detection])])
AC_ARG_WITH([asm], [AS_HELP_STRING([--without-asm], [disable assembler code])])
AC_ARG_WITH([arch], [AS_HELP_STRING([--with-arch=-march=cpu], [compile for the specified processor model])])
AC_ARG_WITH([macosx-sdk], [AS_HELP_STRING([--with-macosx-sdk=x.y], [specify mac os SDK version number])])

UNAME=`uname`
npth_cflags=CFLAGS="-g -O2"
AS_IF([test "x$with_debug" != "xyes"], [CFLAGS="-g -O2"] [LDFLAGS="-g"], [CFLAGS="-g"] [LDFLAGS="-g"] [npth_cflags="CFLAGS=-g -DSIM_NONRECURSIVE"])
AS_IF([test "x$with_arch" != "x"], [ARCHFLAGS="$with_arch $ARCHFLAGS"])
AS_IF([test "x$with_bounds_check" = "xyes"], [CFLAGS="$CFLAGS -fbounds-checking -DSIM_BOUNDS_CHECK"] [LIBS="$LIBS -lboundscheck"])
AS_IF([test "x$with_memory_check" = "xyes"], [CFLAGS="$CFLAGS -DSIM_MEMORY_CHECK"])
AS_IF([test "x$with_tray" = "xno"], [CFLAGS="$CFLAGS -DSIM_NO_TRAY"])
CPUFLAGS=-DSIZEOF_VOID_P=$ac_cv_sizeof_void_p
CFLAGS="$CFLAGS $CPUFLAGS"

if test "x$with_config_ssl" != "xyes"; then
  AC_MSG_NOTICE([********** simcore/configure $ALLARGS])
  AC_C_BIGENDIAN([DEFINES=" -DARIA_BIG_ENDIAN"], [DEFINES=" -DARIA_LITTLE_ENDIAN"])

  AC_SUBST(HGBIN)
  AC_SUBST(HGREV)
  AC_SUBST(HGNODE)

  if test -d .hg; then
    AC_CHECK_PROG(HAVE_HG, hg, true, false)
  fi

  if test "x$HAVE_HG" != "xtrue"; then
    HGBIN=echo
    HGREV=0
    HGNODE=0
  else
    HGBIN="hg parent --template"
    HGREV="{rev}\n"
    HGNODE="{node}LL\n"
  fi

  OLDFLAGS=$LDFLAGS
  if test "x$UNAME" = "xOpenBSD"; then
    if test -x /usr/bin/ld.bfd; then
      LDFLAGS="-fuse-ld $LDFLAGS"
    fi
  fi
  LDFLAGS="-Wl,--build-id=none $LDFLAGS"
  unset ac_cv_lib_c_main
  with_build_id=no
  AC_CHECK_LIB([c], [main], [with_build_id=yes], [LDFLAGS=$OLDFLAGS])
  OLDCFLAGS=$CPPFLAGS
  OLDARCHFLAGS=$ARCHFLAGS
  ARCHFLAGS="$ARCHFLAGS -fno-omit-frame-pointer"
  CPPFLAGS="$CPPFLAGS $ARCHFLAGS"
  unset ac_cv_lib_c_main
  with_frame_pointer=no
  AC_CHECK_LIB([c], [main], [with_frame_pointer=yes], [ARCHFLAGS=$OLDARCHFLAGS])
  CPPFLAGS=$OLDCFLAGS
  npth_cflags="$npth_cflags $ARCHFLAGS"

  EXPAT=dht
  CARES=dht
  SPEEX=dht
  SPEEXDSP=dht
  PORTAUDIO=dht
  MINIUPNPC=dht
  LIBRARIES="../openssl/libssl.a ../openssl/libcrypto.a ../cryptopp/libcryptopp.a"

  if test "x$with_miniupnpc" = "x"; then
    MINIUPNPC=miniupnpc
    LIBRARIES="$LIBRARIES ../miniupnpc/libminiupnpc.a"
    INCLUDES="$INCLUDES -I.."
  fi

  if test "x$with_audio" != "xno"; then
    if test "x$with_speex" != "xyes"; then
      SPEEX=speex/libspeex
      SPEEXDSP=speexdsp/libspeexdsp
      LIBRARIES="$LIBRARIES ../speex/libspeex/.libs/libspeex.a ../speexdsp/libspeexdsp/.libs/libspeexdsp.a"
      INCLUDES="$INCLUDES -I../speex/include -I../speexdsp/include"
    fi
    if test "x$with_portaudio" != "xyes"; then
      PORTAUDIO=portaudio
      LIBRARIES="$LIBRARIES ../portaudio/lib/.libs/libportaudio.a"
      INCLUDES="$INCLUDES -I../portaudio/include"
    fi
  fi

  if test "x$with_expat" = "x"; then
    EXPAT=expat
    LIBRARIES="$LIBRARIES ../expat/.libs/libexpat.a"
    INCLUDES="$INCLUDES -I../expat/lib"
  fi

  if test "x$with_cares" = "x"; then
    CARES=cares
    LIBRARIES="$LIBRARIES ../cares/.libs/libcares.a"
    INCLUDES="$INCLUDES -I../cares"
  fi

  MAKEDEPEND=dht
  if test "x$with_config_ssl" != "xno"; then
    if test "x$with_makedepend" != "xno"; then
      MAKEDEPEND=build/makedepend
    fi
    CRYPTOPPCLEAN=cryptopp
    EXPATCLEAN=$EXPAT
    CARESCLEAN=$CARES
    SPEEXCLEAN=$SPEEX
    SPEEXDSPCLEAN=$SPEEXDSP
    PORTAUDIOCLEAN=$PORTAUDIO
    MINIUPNPCCLEAN=$MINIUPNPC
    OPENSSL=openssl
  else
    CRYPTOPPCLEAN=dht
    EXPATCLEAN=dht
    CARESCLEAN=dht
    SPEEXCLEAN=dht
    SPEEXDSPCLEAN=dht
    PORTAUDIOCLEAN=dht
    MINIUPNPCCLEAN=dht
    OPENSSL=dht
  fi

  AC_CHECK_LIB([ws2_32], [main], [windows=yes] [LIBS="$LIBS -lgdi32 -lws2_32 -lkernel32 -lole32 -loleaut32 -lshell32 -lshlwapi -liphlpapi -lwinmm"])
  AS_IF([test "x$windows" != "xyes"], [CFLAGS="$CFLAGS -Wextra -Wno-unused-parameter -Wno-deprecated-declarations -Wdeclaration-after-statement -Wshadow"])

  if test "x$UNAME" = "xDarwin"; then
    if test "x$with_macosx_sdk" = "xyes"; then
      with_macosx_sdk=
    fi
    if test "x$with_macosx_sdk" = "x"; then
      AC_CHECK_PROG(HAVE_XCRUN, xcrun, true, false)
      if test "x$HAVE_XCRUN" = "xtrue"; then
        with_macosx_sdk=`xcrun --show-sdk-version 2>/dev/null`
      fi
      if test "x$with_macosx_sdk" = "x"; then
        AC_CHECK_PROG(HAVE_XCODEBUILD, xcodebuild, true, false)
        if test "x$HAVE_XCODEBUILD" = "xtrue"; then
          with_macosx_sdk=`xcodebuild -showsdks 2>/dev/null | grep macosx | tail -1 | cut -f 3 | sed 's/-sdk macosx//'`
        fi
        if test "x$with_macosx_sdk" = "x"; then
          if test "x$with_qt" != "xno"; then
            AC_MSG_ERROR("cannot find xcode: please configure --with-macosx-sdk=major.minor")
          fi
          AC_MSG_WARN("cannot find xcode: please configure --with-macosx-sdk=major.minor")
        fi
      fi
    else
      if test "x$with_macosx_sdk" = "xno"; then
        with_macosx_sdk=
      fi
    fi
  fi

  CRYPTOPPFLAGS="-DNDEBUG -g2 -O2 $ARCHFLAGS"
  CRYPTOPP="cryptopp CXXFLAGS=\"$CRYPTOPPFLAGS\" static"
  if test "x$with_asm" = "x"; then
    with_asm=yes
    if test "x$UNAME" = "xDarwin"; then
      if test "x$with_macosx_sdk" != "x"; then
        MAJOR=`echo $with_macosx_sdk | cut -d . -f 1`
        MINOR=`echo $with_macosx_sdk | cut -d . -f 2`
        if test "$MAJOR" -lt 10; then
          with_asm=no
        fi
        if test "$MAJOR" -eq 10; then
          if test "$MINOR" -lt 9; then
            with_asm=no
          fi
        fi
      else
        with_asm=no
      fi
    fi
  fi
  if test "x$with_asm" = "xno"; then
    CRYPTOPP="cryptopp CXXFLAGS=\"$CRYPTOPPFLAGS -DCRYPTOPP_DISABLE_ASM\" static"
    CPPFLAGS="-DCRYPTOPP_DISABLE_ASM $CPPFLAGS"
  fi

  if test "x$windows" = "xyes"; then
    CPPFLAGS="-I/usr/local/include -I/usr/include $CPPFLAGS"
    LDFLAGS="-L/usr/local/lib -L/usr/lib $LDFLAGS"
  fi

  AS_IF([test "x$UNAME" = "xLinux"], [LDFLAGS="-Wl,--gc-sections $LDFLAGS"])
  AS_IF([test "x$UNAME" = "xFreeBSD"], [LDFLAGS="-Wl,--gc-sections $LDFLAGS"])
  AS_IF([test "x$UNAME" = "xDarwin"], [LDFLAGS="-dead_strip $LDFLAGS"])

  if test "x$windows" != "xyes"; then
    AC_CHECK_LIB([rt], [aio_cancel])
    AC_CHECK_LIB([pthread], [pthread_create])
    AC_SEARCH_LIBS([pthread], [pthread_getattr_np])
    AC_SEARCH_LIBS([pthread], [pthread_setschedprio])
    AC_CHECK_FUNCS(pthread_getattr_np pthread_setschedprio)
  else
    LDFLAGS+=" -static -static-libgcc -static-libstdc++"
  fi

  if test -z "$LD"; then
    LD=gcc
  fi

  if test "x$with_rlink" = "xyes"; then
    AC_CHECK_PROG(HAVE_PYTHON, python, true, false)
    if test "x$HAVE_PYTHON" != "xtrue"; then
      AC_MSG_ERROR("cannot find python: please install Python 2.4.3 or later or configure --without-rlink")
    fi
    MAJOR=`python --version 2>&1 | cut -d " " -f 2 | cut -d . -f 1`
    MINOR=`python --version 2>&1 | cut -d " " -f 2 | cut -d . -f 2`
    MICRO=`python --version 2>&1 | cut -d " " -f 2 | cut -d . -f 3`
    if test "$MAJOR" -lt 2; then
      AC_MSG_ERROR("Python$MAJOR not supported; please install Python 2.4.3 or configure --without-rlink")
    fi
    if test "$MAJOR" -eq 2; then
      if test "$MINOR" -lt 4; then
        AC_MSG_ERROR("Python $MAJOR.$MINOR not supported; please install Python 2.4.3 or configure --without-rlink")
      fi
      if test "$MINOR" -eq 4; then
        if test "$MICRO " -lt 3; then
          AC_MSG_ERROR("Python $MAJOR.$MINOR.$MICRO not supported; please install Python 2.4.3 or configure --without-rlink")
        fi
      fi
    fi
    LD="python ../build/rlink/rlink.py $LD"
  fi

  if test "x$with_threads" = "xno"; then
    if test "x$with_pth" = "xno"; then
      AC_DEFINE([HAVE_LIBPTH], [0])
    elif test "x$with_pth" = "xyes"; then
      AC_CHECK_HEADER([pth.h], [], [AC_MSG_ERROR("libpth: cannot find headers")])
      AC_CHECK_LIB([pth], [pth_nanosleep], [], [AC_MSG_ERROR("libpth: cannot find library; need libpth 2.0.x")])
    elif test "x$with_bounds_check" = "xyes"; then
      AC_DEFINE([HAVE_LIBPTH], [0])
    else
      AC_CHECK_HEADER([pth.h], [], [AC_DEFINE([HAVE_LIBPTH], [0])] [AC_MSG_WARN("libpth: cannot find headers")])
      AC_CHECK_LIB([pth], [pth_nanosleep], [], [AC_DEFINE([HAVE_LIBPTH], [0])] [AC_MSG_WARN("libpth: cannot find library; need libpth 2.0.x")])
    fi
  fi

  if test "x$with_miniupnpc" = "xyes"; then
    AC_CHECK_HEADER([miniupnpc/miniupnpc.h], [], [AC_MSG_ERROR("libminiupnpc: cannot find headers")])
    AC_CHECK_LIB([miniupnpc], [UPNP_GetListOfPortMappings], [], [AC_MSG_ERROR("libminiupnpc: cannot find library; need libminiupnpc 1.6 or later")])
  elif test "x$with_miniupnpc" = "x"; then
    AC_DEFINE([HAVE_LIBMINIUPNPC], 1)
  fi

  if test "x$with_expat" = "xyes"; then
    AC_CHECK_HEADER([expat.h], [], [AC_MSG_ERROR("libexpat: cannot find headers")])
    AC_CHECK_LIB([expat], [XML_StopParser], [], [AC_MSG_ERROR("libexpat: cannot find library; need libexpat 1.95.8 or later")])
  elif test "x$with_expat" = "x"; then
    AC_DEFINE([HAVE_LIBEXPAT], 1)
  fi

  if test "x$with_cares" = "xyes"; then
    AC_CHECK_HEADER([ares.h], [], [AC_MSG_ERROR("libcares: cannot find headers")])
    AC_CHECK_LIB([cares], [ares_library_init], [], [AC_MSG_ERROR("libcares: cannot find library; need version 1.7.0 or later")])
  elif test "x$with_cares" = "x"; then
    AC_DEFINE([HAVE_LIBCARES], 1)
  fi

  if test "x$with_audio" != "xno"; then
    if test "x$with_speex" = "xyes"; then
      AC_CHECK_HEADER([speex/speex_echo.h], [], [AC_MSG_ERROR("libspeex: cannot find headers; need version 1.2-rc1")])
      AC_CHECK_LIB([speexdsp], [speex_echo_state_init], [], [AC_MSG_ERROR("libspeex: cannot find library; need version 1.2-rc1")])
      AC_CHECK_HEADER([speex/speex.h], [], [AC_MSG_ERROR("libspeex: cannot find headers")])
      AC_CHECK_LIB([speex], [speex_encoder_init], [], [AC_MSG_ERROR("libspeex: cannot find library")])
    else
      AC_DEFINE([HAVE_LIBSPEEX], [1])
    fi
    if test "x$with_oss" != "xno"; then
      with_oss_h=no
      AC_CHECK_HEADERS([soundcard.h sys/soundcard.h linux/soundcard.h machine/soundcard.h], [with_oss_h=yes] [break])
      if test "x$with_oss_h" != "xyes"; then
        if test "x$with_oss" = "xyes"; then
          AC_MSG_ERROR("OSS: cannot find headers")
        fi
      fi
      with_oss=$with_oss_h
    fi
    if test "x$with_oss" = "xyes"; then
      AC_CHECK_LIB([ossaudio], [_oss_ioctl], [LIBS="$LIBS -lossaudio"] [with_liboss=yes], [with_liboss=no])
    fi
    if test "x$with_portaudio" = "xyes"; then
      AC_CHECK_HEADER([portaudio.h], [], [AC_MSG_ERROR("libportaudio: cannot find headers")])
      AC_CHECK_LIB([portaudio], [Pa_ReadStream], [], [AC_MSG_ERROR("libportaudio: cannot find library; need version V19")])
      AC_CHECK_LIB([portaudio], [PaAlsa_SetRetriesBusy], [AC_DEFINE([HAVE_ALSA], [1])] [LIBS="$LIBS -lasound"])
    else
      with_libalsa=$with_alsa
      if test "x$with_libalsa" = "x"; then
        with_libalsa=yes
        if test "x$UNAME" != "xLinux"; then
          if test "x$with_oss" = "xyes"; then
            with_libalsa=no
          fi
        fi
      fi
      if test "x$with_libalsa" = "xyes"; then
        AC_CHECK_LIB([asound], [snd_pcm_open], [AC_DEFINE([HAVE_ALSA], [1])] [LIBS="$LIBS -lasound"], [AC_DEFINE([HAVE_ALSA], [0])])
        if test "x$with_alsa" = "xyes"; then
          if test "x$ac_cv_lib_asound_snd_pcm_open" != "xyes"; then
            AC_MSG_ERROR("ALSA: cannot find library")
          fi
        fi
      fi
      with_alsa=$with_libalsa
    fi
  fi

  if test "x$windows" != "xyes"; then
    if test "x$with_audio" != "xno"; then
      if test "x$with_udev" != "xno"; then
        if test "x$with_udev" = "xyes"; then
          AC_CHECK_HEADER([libudev.h], [AC_DEFINE([HAVE_LIBUDEV_H], [1])], [AC_MSG_ERROR("libudev: cannot find headers")])
          AC_CHECK_LIB([udev], [udev_monitor_filter_add_match_subsystem_devtype], [], [AC_MSG_ERROR("libudev: cannot find library; need version 142 or later)])
        elif test "x$UNAME" = "xLinux"; then
          AC_CHECK_HEADER([libudev.h], [AC_DEFINE([HAVE_LIBUDEV_H], [1])], [AC_MSG_WARN("libudev: cannot find headers")])
          AC_CHECK_LIB([udev], [udev_monitor_filter_add_match_subsystem_devtype], [], [AC_MSG_WARN("libudev: cannot find library; need version 142 or later)])
        fi
      fi
    fi
  fi

  EFENCE=dht
  AS_IF([test "x$with_efence" = "xyes"],
        AS_IF([test "x$windows" = "xyes"], [AC_DEFINE([HAVE_LIBEFENCE], [1])] [EFENCE=efence] [LIBS="../efence/libefence.a $LIBS"],
              AC_CHECK_LIB([efence], [main], [], [AC_MSG_ERROR("cannot find libefence")])))

  with_npth=$with_threads
  AS_IF([test "x$ac_cv_header_pth_h" != "xyes"], [with_npth=yes], [])
  AS_IF([test "x$ac_cv_lib_pth_pth_nanosleep" != "xyes"], [with_npth=yes], [])

  AS_IF([test "x$windows" = "xyes"], [NPTHSRC=../npth/w32], [NPTHSRC=../npth/src])
  AS_IF([test "x$with_npth" != "xno"], [NPTH=npth] [OBJECTS="$OBJECTS spth.o $NPTHSRC/npth.o"] [INCLUDES="$INCLUDES -I$NPTHSRC"], [NPTH=dht])

  #AC_TYPE_UID_T
  #AC_TYPE_PID_T
  #AC_TYPE_SIZE_T

  AS_IF([test "x$with_bounds_check" != "xyes"], [AC_CHECK_HEADER([malloc_np.h], [AC_DEFINE([HAVE_MALLOC_NP_H], [1])])])
  AS_IF([test "x$with_bounds_check" != "xyes"], [AC_CHECK_FUNCS(malloc_usable_size)], [])
  AS_IF([test "x$with_memory_check" = "xyes"], [AC_CHECK_FUNCS(mtrace)], [])

  AC_CHECK_FUNCS(mlockall dladdr strerror_r flock)

  if test "x$windows" = "xyes"; then
    if test "x$with_crash_handler" != "xno"; then
      AC_DEFINE([HAVE_SYS_UCONTEXT_H], [0])
    fi
  elif test "x$with_crash_handler" = "xyes"; then
    if test "x$ac_cv_func_flock" != "xyes"; then
      AC_MSG_ERROR("flock: function not available; do not use --with-crash-handler")
    fi
    if test "x$UNAME" = "xOpenBSD"; then
      AC_DEFINE([HAVE_SYS_UCONTEXT_H], [0])
    else
      AC_CHECK_HEADERS([sys/ucontext.h], [], [AC_MSG_ERROR("crash handler not available")])
    fi
  elif test "x$with_crash_handler" != "xno"; then
    AC_CHECK_HEADERS([sys/ucontext.h], [], [AC_MSG_WARN("crash handler not available")])
    if test "x$UNAME" = "xOpenBSD"; then
      if test "x$ac_cv_header_sys_ucontext_h" != "xyes"; then
        AC_DEFINE([HAVE_SYS_UCONTEXT_H], [0])
      fi
    fi
  fi

  if test "x$UNAME" = "xOpenBSD"; then
    if test "x$with_backtrace" = "x"; then
      with_backtrace=no
    fi
  fi

  if test "x$with_backtrace" != "xno"; then
    AC_CHECK_FUNCS(backtrace)

    unset ac_cv_lib_execinfo_backtrace
    AC_CHECK_LIB([execinfo], [backtrace])
    if test "x$ac_cv_lib_execinfo_backtrace" != "xyes"; then
      OLDFLAGS=$LDFLAGS
      LDFLAGS="-L/usr/local/lib $LDFLAGS"
      unset ac_cv_lib_execinfo_backtrace
      AC_CHECK_LIB([execinfo], [backtrace])
      if test "x$ac_cv_lib_execinfo_backtrace" != "xyes"; then
        LDFLAGS=$OLDFLAGS
        if test "x$with_backtrace" = "xyes"; then
          AC_MSG_ERROR("cannot find backtrace")
        fi
      else
        CFLAGS="-I/usr/local/include $CFLAGS"
        AC_DEFINE([HAVE_BACKTRACE], [1])
      fi
    else
      AC_DEFINE([HAVE_BACKTRACE], [1])
    fi
  fi

  AC_MSG_CHECKING(for sysctl)
  AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
  #include <sys/types.h>
  #include <sys/sysctl.h>
  int main (int argc, char **argv) {
    static int name[3] = { CTL_KERN, KERN_PROC, KERN_PROC_ALL };
    size_t len = 0;
    sysctl (name, 3, 0, &len, 0, 0);
  }
  ]])], [AC_DEFINE([HAVE_SYSCTL], [1])] [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)])

  if test "x$UNAME" = "xDarwin"; then
    if test "x$with_audio" != "xno"; then
      LDFLAGS="-framework IOKit -framework CoreAudio -framework AudioToolBox -framework AudioUnit $LDFLAGS"
    fi
    if test "x$with_macosx_sdk" != "x"; then
      LDFLAGS="-framework Security -framework Carbon -mmacosx-version-min=$with_macosx_sdk $LDFLAGS"
    else
      LDFLAGS="-framework Security -framework Carbon $LDFLAGS"
    fi
  fi

  GUI=dht
  if test "x$with_qt" != "xno"; then
    OLDLIBS=$LIBS
    OLDFLAGS=$LDFLAGS
    OLDCFLAGS=$CPPFLAGS
    CPPFLAGS="-I/usr/X11R7/include -I/usr/X11R6/include -I/usr/pkg/include -I/usr/local/include $CPPFLAGS"
    LDFLAGS="-L/usr/X11R7/lib -L/usr/X11R6/lib -L/usr/pkg/lib -L/usr/local/lib $LDFLAGS"
    if test "x$with_xss" != "xno"; then
      if test "x$with_xss" = "xyes"; then
        AC_CHECK_HEADER([X11/extensions/scrnsaver.h], [], [AC_MSG_ERROR("libXss: cannot find X11/extensions/scrnsaver.h")])
        AC_CHECK_LIB([Xss], [XScreenSaverQueryInfo], [], [AC_MSG_ERROR("libXss: cannot find library")])
      else
        AC_CHECK_HEADER([X11/extensions/scrnsaver.h], [], [AC_MSG_WARN("libXss: cannot find X11/extensions/scrnsaver.h")])
        AC_CHECK_LIB([Xss], [XScreenSaverQueryInfo], [], [AC_MSG_WARN("libXss: cannot find library")])
      fi
    fi
    if test "x$with_xcb" != "xno"; then
      if test "x$with_xcb" = "xyes"; then
        AC_CHECK_HEADER([xcb/xcb_keysyms.h], [], [AC_MSG_ERROR("libxcb-keysyms: cannot find xcb/xcb_keysyms.h")])
        AC_CHECK_LIB([xcb-keysyms], [xcb_key_symbols_get_keycode], [], [AC_MSG_ERROR("libxcb-keysyms: cannot find library")])
      else
        AC_CHECK_HEADER([xcb/xcb_keysyms.h], [], [AC_MSG_WARN("libxcb-keysyms: cannot find xcb/xcb_keysyms.h")])
        AC_CHECK_LIB([xcb-keysyms], [xcb_key_symbols_get_keycode], [], [AC_MSG_WARN("libxcb-keysyms: cannot find library")])
      fi
    fi
    CPPFLAGS=$OLDCFLAGS
    LDFLAGS=$OLDFLAGS
    LIBS=$OLDLIBS

    if test "x$with_qt" = "xyes"; then
      AC_CHECK_PROG(HAVE_QMAKE, qmake, true, false)
      if test "x$HAVE_QMAKE" != "xtrue"; then
        AC_MSG_ERROR("cannot find qmake: please install Qt 5.3.2 or later or configure --without-qt")
      fi
      QMAKE=qmake
    else
      QMAKE=../qt/bin/qmake
      qt/bin/qmake --version >/dev/null 2>&1
      if test $? -ne 0; then
        AC_MSG_ERROR("cannot find qmake: please compile Qt or configure --with-qt or --without-qt")
      fi
    fi

    cd qsimphone
    MAJOR=`$QMAKE --version | grep Qt | cut -d " " -f 4 | cut -d . -f 1`
    MINOR=`$QMAKE --version | grep Qt | cut -d " " -f 4 | cut -d . -f 2`
    MICRO=`$QMAKE --version | grep Qt | cut -d " " -f 4 | cut -d . -f 3`
    if test "$MAJOR" -lt 5; then
       AC_MSG_ERROR("Qt$MAJOR not supported; please install Qt 5.3.2 or configure --without-qt")
    fi
    if test "$MAJOR" -eq 5; then
      if test "$MINOR" -lt 2; then
        AC_MSG_ERROR("Qt $MAJOR.$MINOR.$MICRO not supported; please install Qt 5.3.2 or configure --without-qt")
      fi
    fi
    SPEC=
    if test "x$windows" = "xyes"; then
      SPEC="-spec win32-g++"
    fi
    if test "x$UNAME" = "xFreeBSD"; then
      SPEC="-spec freebsd-g++"
    fi
    if test "x$UNAME" = "xDarwin"; then
      SPEC="-spec macx-g++"
      if test "x$with_macosx_sdk" != "x"; then
        SPEC="$SPEC MACOSXSDK=$with_macosx_sdk"
      fi
    fi

    if test "x$with_miniupnpc" = "xno"; then
      SPEC="$SPEC CONFIG+=nominiupnpc"
    elif test "x$with_miniupnpc" = "xyes"; then
      SPEC="$SPEC CONFIG+=nominiupnpc"
      SPEC="$SPEC SIMLIBS+=-lminiupnpc"
    fi
    if test "x$with_expat" = "xno"; then
      SPEC="$SPEC CONFIG+=noexpat"
    elif test "x$with_expat" = "xyes"; then
      SPEC="$SPEC CONFIG+=noexpat"
      SPEC="$SPEC SIMLIBS+=-lexpat"
    fi
    if test "x$with_cares" = "xno"; then
      SPEC="$SPEC CONFIG+=nocares"
    elif test "x$with_cares" = "xyes"; then
      SPEC="$SPEC CONFIG+=nocares"
      SPEC="$SPEC SIMLIBS+=-lcares"
    fi

    if test "x$with_audio" != "xno"; then
      if test "x$with_speex" = "xyes"; then
        SPEC="$SPEC CONFIG+=nospeex"
        SPEC="$SPEC SIMLIBS+=-lspeex"
        SPEC="$SPEC SIMLIBS+=-lspeexdsp"
      fi
      if test "x$with_portaudio" = "xyes"; then
        SPEC="$SPEC CONFIG+=noportaudio"
      else
        SPEC="$SPEC CONFIG+=portaudio"
        if test "x$ac_cv_lib_portaudio_PaAlsa_SetRetriesBusy" = "xyes"; then
          SPEC="$SPEC SIMLIBS+=-lasound"
        elif test "x$ac_cv_lib_asound_snd_pcm_open" = "xyes"; then
          SPEC="$SPEC SIMLIBS+=-lasound"
        fi
        if test "x$with_liboss" = "xyes"; then
          SPEC="$SPEC SIMLIBS+=-lossaudio"
        fi
      fi
      if test "x$ac_cv_lib_udev_udev_monitor_filter_add_match_subsystem_devtype" = "xyes"; then
        SPEC="$SPEC SIMLIBS+=-ludev"
      fi
    else
      SPEC="$SPEC CONFIG+=noaudio"
    fi

    if test "x$UNAME" != "xDarwin"; then
      if test "x$ac_cv_lib_Xss_XScreenSaverQueryInfo" = "xyes"; then
        if test "x$ac_cv_header_X11_extensions_scrnsaver_h" = "xyes"; then
          SPEC="$SPEC SIMLIBS+=-lXss"
          SPEC="$SPEC SIMLIBS+=-lX11"
          SPEC="$SPEC SIMDEFS+=-DHAVE_LIBXSS"
        fi
      fi

      if test "x$ac_cv_lib_xcb_keysyms_xcb_key_symbols_get_keycode" = "xyes"; then
        if test "x$ac_cv_header_xcb_xcb_keysyms_h" = "xyes"; then
          SPEC="$SPEC SIMLIBS+=-lxcb-keysyms"
          SPEC="$SPEC SIMLIBS+=-lxcb"
          SPEC="$SPEC SIMDEFS+=-DHAVE_LIBXCB"
        fi
      fi
    fi

    if test "x$UNAME" = "xNetBSD"; then
      if test "x$with_qt" != "xyes"; then
        SPEC="$SPEC SIMLIBS+=-lxcb-icccm"
      fi
    fi

    if test "x$with_ips" = "xno"; then
      SPEC="$SPEC CONFIG+=noips"
    fi
    if test "x$with_rlink" = "xyes"; then
      SPEC="$SPEC CONFIG+=rlink"
    fi
    if test "x$with_npth" = "xno"; then
      SPEC="$SPEC SIMLIBS+=-lpth"
    fi
    if test "x$with_efence" = "xyes"; then
      if test "x$windows" = "xyes"; then
        SPEC="$SPEC SIMLIBS+=../efence/libefence.a"
      else
        SPEC="$SPEC SIMLIBS+=-lefence"
      fi
    fi
    if test "x$with_bounds_check" = "xyes"; then
      SPEC="$SPEC SIMLIBS+=-lboundscheck"
    fi

    if test "x$windows" != "xyes"; then
      SPEC="$SPEC SIMLIBS+=-lpthread"
    fi
    if test "x$ac_cv_lib_rt_aio_cancel" = "xyes"; then
      SPEC="$SPEC SIMLIBS+=-lrt"
    fi

    if test "x$with_memory_check" = "xyes"; then
      SPEC="$SPEC SIMDEFS+=-DSIM_MEMORY_CHECK"
    fi
    if test "x$with_arch" != "x"; then
      SPEC="$SPEC SIMDEFS+=$with_arch"
    fi
    if test $ac_cv_sizeof_void_p = 8; then
      SPEC="$SPEC SIMDEFS+=-DSIZEOF_VOID_P=8"
    fi
    if test $ac_cv_sizeof_void_p = 4; then
      SPEC="$SPEC SIMDEFS+=-DSIZEOF_VOID_P=4"
    fi

    if test "x$with_frame_pointer" = "xyes"; then
      SPEC="$SPEC SIMCFLAGS+=-fno-omit-frame-pointer"
    fi
    SPEC="$SPEC SIMLFLAGS+=-g"
    if test "x$UNAME" != "xDarwin"; then
      SPEC="$SPEC SIMLFLAGS+=-Wl,--gc-sections"
    fi
    if test "x$with_build_id" = "xyes"; then
      SPEC="$SPEC SIMLFLAGS+=-Wl,--build-id=none"
    fi

    GUI=qsimphone
    if test "x$with_debug" = "xyes"; then
      SPEC="$SPEC CONFIG+=debug"
    fi
    AC_MSG_NOTICE([********** $QMAKE $SPEC qsimphone.pro])
    $QMAKE $SPEC qsimphone.pro
    if test $? -ne 0; then
      exit 1
    fi
    cd ..
  fi

  LIBS="-lstdc++ $LIBS"

  AC_CONFIG_FILES([Makefile])
  AC_CONFIG_FILES([dht/Makefile])
  AC_CONFIG_FILES([simcore/Makefile])
  AC_OUTPUT

  if test "x$with_expat" = "x"; then
    expat_cflags="CFLAGS=-g -O2 -Wall -Wmissing-prototypes -Wstrict-prototypes -fexceptions $ARCHFLAGS"
    AC_MSG_NOTICE([********** expat/configure --disable-shared --enable-static $config_cache $XXFLAGS "$expat_cflags"])
    cd expat
    if ! ./configure --disable-shared --enable-static $config_cache $XXFLAGS "$expat_cflags"; then
      exit 2
    fi
    cd ..
  fi

  if test "x$with_cares" = "x"; then
    cares_flags="--disable-shared --enable-static --without-random"
    cares_cflags="CFLAGS=-g0 -O2 -Wno-system-headers $ARCHFLAGS"
    AC_MSG_NOTICE([********** cares/configure $cares_flags $config_cache $XXFLAGS "$cares_cflags" "CPPFLAGS=$CPUFLAGS"])
    cd cares
    if ! ./configure $cares_flags $config_cache $XXFLAGS "$cares_cflags" "CPPFLAGS=$CPUFLAGS"; then
      exit 3
    fi
    cd ..
  fi

  if test "x$with_npth" != "xno"; then
    AC_MSG_NOTICE([********** npth/configure --disable-shared --disable-tests $config_cache $XXFLAGS "$npth_cflags"])
    cd npth
    if ! ./configure --disable-shared --disable-tests $config_cache $XXFLAGS "$npth_cflags"; then
      exit 4
    fi
    cd ..
    ssl_threads=threads
  else
    ssl_threads="no-threads no-locking"
  fi

  if test "x$with_audio" != "xno"; then
    if test "x$with_speex" != "xyes"; then
      if test $ac_cv_sizeof_void_p = 8; then
        SPEEXSSE=--enable-sse
      else
        SPEEXSSE=--disable-sse
      fi
      speex_flags="--disable-shared --enable-static"
      speex_cflags="CFLAGS=-g -O2 -DOS_SUPPORT_CUSTOM $CPUFLAGS $ARCHFLAGS"
      AC_MSG_NOTICE([********** speex/configure $speex_flags $SPEEXSSE --disable-vbr --disable-binaries $config_cache $XXFLAGS "$speex_cflags"])
      cd speex
      if ! ./configure $speex_flags $SPEEXSSE --disable-vbr --disable-binaries $config_cache $XXFLAGS "$speex_cflags"; then
        exit 5
      fi
      AC_MSG_NOTICE([********** speexdsp/configure $speex_flags $SPEEXSSE --disable-neon --disable-examples $config_cache $XXFLAGS "$speex_cflags"])
      cd ../speexdsp
      if ! ./configure $speex_flags $SPEEXSSE --disable-neon --disable-examples $config_cache $XXFLAGS "$speex_cflags"; then
        exit 6
      fi
      cd ..
    fi
    if test "x$with_portaudio" != "xyes"; then
      cd portaudio
      PA_ALSA=
      if test "x$with_alsa" = "xyes"; then
        PA_ALSA=--with-alsa
      elif test "x$with_alsa" = "xno"; then
        PA_ALSA=--without-alsa
      fi
      PA_OSS=
      if test "x$with_oss" = "xyes"; then
        PA_OSS=--with-oss
      elif test "x$with_oss" = "xno"; then
        PA_OSS=--without-oss
      fi
      pa_flags="--disable-shared --enable-static --without-jack --without-asihpi --with-winapi=wmme"
      AC_MSG_NOTICE([********** portaudio/configure $pa_flags $config_cache $XXFLAGS $PA_ALSA $PA_OSS "ARCHFLAGS=$ARCHFLAGS"])
      if ! ./configure $pa_flags $config_cache $XXFLAGS $PA_ALSA $PA_OSS "ARCHFLAGS=$ARCHFLAGS"; then
        exit 7
      fi
      cd ..
    fi
  fi
elif test "x$with_makedepend" = "x"; then
  with_makedepend=no
fi

if test "x$windows" = "xyes"; then
  ssl_threads="$ssl_threads no-sse2 no-posix-io"
fi
if test "x$with_debug" = "xyes"; then
  ssl_threads="$ssl_threads enable-ssl-trace"
else
  ssl_threads="$ssl_threads no-ssl-trace no-err"
fi

if test "x$with_config_ssl" != "xno"; then
  if test "x$with_makedepend" != "xno"; then
    cd build/makedepend
    if test $? -eq 0; then
      AC_MSG_NOTICE([********** build/makedepend/configure $config_cache X_CFLAGS=-D_X_NORETURN= X_LIBS=])
      if ! ./configure $config_cache X_CFLAGS=-D_X_NORETURN= X_LIBS=; then
        AC_MSG_WARN("could not configure makedepend")
      fi
      cd ../..
    fi
  fi

  cd openssl
  openssl="./config"
  if test "x$with_config_ssl" != "x"; then
    if test "x$with_config_ssl" != "xyes"; then
      openssl="./Configure $with_config_ssl"
    fi
  elif test "x$UNAME" = "xDarwin"; then
    if test $ac_cv_sizeof_void_p = 8; then
      openssl="./Configure darwin64-x86_64-cc"
    fi
  elif test "x$UNAME" = "xDragonFly"; then
    if test $ac_cv_sizeof_void_p = 8; then
      openssl="./Configure BSD-x86_64"
    fi
  fi
  AC_MSG_NOTICE([********** openssl/$openssl $CPUFLAGS $ssl_threads $ARCHFLAGS])
  export CC
  exec $openssl no-engine no-dh no-dsa no-weak-ssl-ciphers no-ssl2-method no-ssl2 no-ssl3-method no-ssl3 no-comp no-heartbeats no-dtls no-shared no-hw \
      no-dso no-npn no-psk no-srp no-jpake no-krb5 no-zlib no-zlib-dynamic no-idea no-bf no-buf-freelists no-camellia no-capieng                       \
      no-cast no-chain-verify no-des no-descbcm no-dgram no-dtls1 no-dynamic-engine no-gmp no-gost no-hw-4758-cca                                      \
      no-hw-aep no-hw-atalla no-hw-chil no-hw-cswift no-hw-ibmca no-hw-ncipher no-hw-nuron no-hw-padlock no-hw-sureware                                \
      no-hw-ubsec no-hw-zencod no-sock no-rdrand no-md2 no-md4 no-md5crypt-1 no-mdc2 no-nextprotoneg no-rc2 no-rc4 no-rc5 no-ripemd no-ripemd160       \
      no-rmd160 no-sctp no-seed no-sha0 no-speed no-srtp no-static-engine no-store no-unit-test no-whirlpool no-cms no-deprecated                      \
      no-ec2m no-ec-nistp-64-gcc-128 no-rfc3779 no-cmac no-libunbound no-multiblock -DSSL_FORBID_ENULL=1 -g $CPUFLAGS $ssl_threads $ARCHFLAGS
fi
Show on old repository browser