configure.ac 22.5 KB
Newer Older
Philippe Gorley's avatar
Philippe Gorley committed
1
dnl Jami - configure.ac for automake 1.9 and autoconf 2.59
2

3
dnl Process this file with autoconf to produce a configure script.
4
AC_PREREQ([2.65])
5
AC_INIT([Jami Daemon],[7.8.0],[ring@gnu.org],[jami])
6

7
AC_COPYRIGHT([[Copyright (c) Savoir-faire Linux 2004-2019]])
8 9
AC_REVISION([$Revision$])

10
dnl Where to find configure files
Adrien Béraud's avatar
Adrien Béraud committed
11
AC_CONFIG_SRCDIR(src/ring_api.cpp)
12
AC_CONFIG_AUX_DIR([build-aux])
13 14 15 16
AC_CONFIG_MACRO_DIR([m4])
AC_CANONICAL_BUILD
AC_CANONICAL_HOST

17
AM_INIT_AUTOMAKE([-Wno-portability subdir-objects])
18
m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) # required by automake 1.12
19
AC_CONFIG_HEADERS([config.h])
20

21
# Silent build by default. Use make V=1 to increase verbosity
22
m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
23

24 25 26 27 28 29 30 31 32 33
dnl debug mode is default-disabled
AC_ARG_ENABLE([debug], AS_HELP_STRING([--enable-debug], [Build in debug mode, adds stricter warnings, disables optimization]))
AS_IF([test "x$enable_debug" = "xyes"], [
    CFLAGS="${CFLAGS} -g -fno-omit-frame-pointer -Wall -Wextra -Wnon-virtual-dtor -Wno-unknown-pragmas -Wformat=2 -O0"
    CXXFLAGS="${CXXFLAGS} -g -fno-omit-frame-pointer -Wall -Wextra -Wnon-virtual-dtor -Wno-unknown-pragmas -Wformat=2 -O0"
], [
    CFLAGS="${CFLAGS} -DNDEBUG=1 -O3"
    CXXFLAGS="${CXXFLAGS} -DNDEBUG=1 -O3"
])

34 35 36
dnl Check for programs
AC_PROG_CC
AC_PROG_CXX
37
AC_PROG_OBJCXX
38 39 40 41
AC_PROG_CPP
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
42
AC_LANG(C++)
43

44 45 46 47
dnl
dnl  Check the operating system
dnl
HAVE_WIN64="0"
48
HAVE_IOS="0"
49 50 51 52 53 54 55 56 57 58
HAVE_OSX="0"

case "${host_os}" in
  "")
    SYS=unknown
    ;;
  linux*)
    SYS=linux
    # Necessary for linking .a to a .so
    LDFLAGS+=" -Wl,-Bsymbolic"
59 60
    # Needed for plugin system
    LDFLAGS+=" -ldl"
61 62 63
    ;;
  darwin*)
    SYS=darwin
Guillaume Roguez's avatar
Guillaume Roguez committed
64 65 66 67 68 69 70 71
    AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
        [[#import <TargetConditionals.h>
          #if TARGET_OS_IPHONE == 0
          #error this is not an IPHONE
          #endif
        ]])],
        [HAVE_IOS="1"],
        [HAVE_OSX="1"])
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
    ;;
  mingw32*)
    SYS=mingw32
    AC_CHECK_TOOL(WINDRES, windres, :)
    AC_CHECK_TOOL(OBJCOPY, objcopy, :)
    AC_DEFINE([_UNICODE], [1], [Define to 1 for Unicode (Wide Chars) APIs.])
    AC_DEFINE([UNICODE], [1], [Define to 1 for Unicode (Wide Chars) APIs.])
    AC_DEFINE([_ISOC99_SOURCE], [1], [Extensions to ISO C89 from ISO C99.])
    AC_DEFINE([_ISOC11_SOURCE], [1], [Extensions to ISO C99 from ISO C11.])
    AC_DEFINE([_POSIX_SOURCE], [1], [IEEE Std 1003.1.])
    AC_DEFINE([_POSIX_C_SOURCE], [200809L], [IEEE Std 1003.1.])
    AC_DEFINE([_XOPEN_SOURCE], [700], [POSIX and XPG 7th edition])
    AC_DEFINE([_XOPEN_SOURCE_EXTENDED], [1], [XPG things and X/Open Unix extensions.])
    AC_DEFINE([_BSD_SOURCE], [1], [ISO C, POSIX, and 4.3BSD things.])
    AC_DEFINE([_SVID_SOURCE], [1], [ISO C, POSIX, and SVID things.])
87

88
    AC_DEFINE([WIN32_LEAN_AND_MEAN],[1], [Define to limit the scope of <windows.h>.])
89

90
    CPPFLAGS+="-D_WIN32_WINNT=0x0601 -DWINVER=0x0601 -D__USE_MINGW_ANSI_STDIO=1"
91 92
    LDFLAGS+="-Wl,--nxcompat -Wl,--dynamicbase"
    LIBS+=" -lws2_32"
93 94 95 96
    ac_default_prefix="`pwd`/_win32"
    DESTDIR="`pwd`/_win32/"
    AC_SUBST(WINDOWS_ARCH)
    AC_SUBST(PROGRAMFILES)
Edric Milaret's avatar
Edric Milaret committed
97 98 99 100 101 102

    case "${host}" in
            amd64*|x86_64*)
                HAVE_WIN64="1"
            ;;
    esac
103 104 105 106 107 108 109 110 111 112
    ;;
  *)
    SYS="${host_os}"
    ;;
esac
AM_CONDITIONAL(HAVE_DARWIN,  test "${SYS}" = "darwin")
AM_CONDITIONAL(HAVE_LINUX,   test "${SYS}" = "linux")
AM_CONDITIONAL(HAVE_WIN32,   test "${SYS}" = "mingw32")
AM_CONDITIONAL(HAVE_WIN64,   test "${HAVE_WIN64}" = "1")
AM_CONDITIONAL(HAVE_OSX,   test "${HAVE_OSX}" = "1")
113
AM_CONDITIONAL(HAVE_IOS,   test "${HAVE_IOS}" = "1")
114

115 116
dnl FIXME this should be deduced automatically
AC_DEFINE_UNQUOTED([HAVE_COREAUDIO],
117
                    `if test "${HAVE_OSX}" = "1" || test "${HAVE_IOS}" = "1"; then echo 1; else echo 0; fi`,
118 119
                    [Define if you have CoreAudio])

120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
dnl Android is linux, but a bit different
AS_IF([test "$SYS" = linux],[
    AC_MSG_CHECKING([for an Android system])
    AC_PREPROC_IFELSE([AC_LANG_PROGRAM(
        [[#ifndef __ANDROID__
         # error Not Android
         #endif
        ]],[[;]])
    ],[
      HAVE_ANDROID="1"
      AC_MSG_RESULT([yes])
    ],[
      AC_MSG_RESULT([no])
    ])
])
AM_CONDITIONAL(HAVE_ANDROID, test "${HAVE_ANDROID}" = "1")

137 138 139 140 141 142
AS_IF([test "$SYS" = linux && test "${HAVE_ANDROID}" != "1"],[
    CFLAGS="${CFLAGS} -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
    CXXFLAGS="${CXXFLAGS} -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
],[
])

143 144 145 146 147 148 149
dnl override platform specific check for dependent libraries
dnl otherwise libtool linking of shared libraries will
dnl fail on anything other than pass_all.
AC_CACHE_VAL(lt_cv_deplibs_check_method,
    [lt_cv_deplibs_check_method=pass_all])

LT_INIT([dlopen win32-dll shared disable-static])
150

Rafaël Carré's avatar
Rafaël Carré committed
151
dnl Define C++ as default language
152 153
LT_LANG(C++)

Luca Barbato's avatar
Luca Barbato committed
154 155
DOLT

156
lt_cv_deplibs_check_method=pass_all
157

Guillaume Roguez's avatar
Guillaume Roguez committed
158 159
dnl Check for C++14 support
AX_CXX_COMPILE_STDCXX(14,[ext],[mandatory])
160

Rafaël Carré's avatar
Rafaël Carré committed
161 162 163
dnl Check for header files
AC_FUNC_ALLOCA
AC_HEADER_STDC
164 165 166
AC_CHECK_HEADERS([arpa/inet.h fcntl.h libintl.h limits.h \
                  netdb.h netinet/in.h stdlib.h string.h \
                  sys/ioctl.h sys/socket.h sys/time.h unistd.h])
Rafaël Carré's avatar
Rafaël Carré committed
167 168 169 170 171 172 173 174 175 176

dnl Check for typedefs, structures, and compiler characteristics
AC_HEADER_STAT
AC_HEADER_STDBOOL
AC_C_CONST
AC_C_INLINE
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_HEADER_TIME
AC_C_VOLATILE
177 178
AC_CHECK_TYPES([ptrdiff_t])

179
PKG_PROG_PKG_CONFIG()
180

181 182 183 184 185 186 187
dnl On some OS we need static linking
AS_IF([test -n "${PKG_CONFIG}" ],[
    AS_IF([test "${SYS}" = "mingw32" -o "${SYS}" = "darwin"],[
        PKG_CONFIG="${PKG_CONFIG} --static"
    ])
])

188 189 190 191 192 193 194 195 196 197 198
dnl Check if we are using clang
AC_MSG_CHECKING([if compiling with clang])
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([], [[
#ifndef __clang__
       not clang
#endif
]])],
[CLANG=yes], [CLANG=no])

AC_MSG_RESULT([$CLANG])
199

200 201 202 203 204 205 206 207 208 209 210 211
dnl define DRING_BUILD because we are building libring, not using it
dnl if building shared library, define dring_EXPORTS
AC_MSG_CHECKING([if compiling shared library])
CPPFLAGS="${CPPFLAGS} -fvisibility=hidden -DDRING_BUILD "
AS_IF([test "x$enable_shared" == "xyes"], [
  RING_SHARED=yes
  CPPFLAGS="${CPPFLAGS} -Ddring_EXPORTS "
],[
  RING_SHARED=no
])
AC_MSG_RESULT([$RING_SHARED])

212 213 214 215 216 217 218 219 220
dnl
dnl  Check for the contrib directory
dnl
AC_ARG_WITH(contrib,
  [AS_HELP_STRING([--with-contrib[=DIR]],
    [search for 3rd party libraries in DIR/include and DIR/lib])
])
AC_MSG_CHECKING([for 3rd party libraries path])
AS_IF([test -z "${with_contrib}" || test "${with_contrib}" = "yes"], [
221
  CONTRIB_DIR="${srcdir}/contrib/${host}"
222 223
  AS_IF([test ! -d "${CONTRIB_DIR}"], [
    echo "${CONTRIB_DIR} not found" >&AS_MESSAGE_LOG_FD
224
    CONTRIB_DIR="${srcdir}/contrib/`$CC -dumpmachine`"
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253
    AS_IF([test ! -d "${CONTRIB_DIR}"], [
      echo "${CONTRIB_DIR} not found" >&AS_MESSAGE_LOG_FD
      CONTRIB_DIR=""
      AC_MSG_RESULT([not found])
    ])
  ])
], [
  AS_IF([test "${with_contrib}" != "no"], [
    CONTRIB_DIR="${with_contrib}"
  ], [
    CONTRIB_DIR=""
    AC_MSG_RESULT([disabled])
  ])
])

AS_IF([test -n "${CONTRIB_DIR}"], [
  AS_IF([test -d "${CONTRIB_DIR}/lib"],[
    CONTRIB_DIR=`cd "${CONTRIB_DIR}" && pwd`
  ], [
    echo "${CONTRIB_DIR}/lib not found" >&AS_MESSAGE_LOG_FD
    CONTRIB_DIR=""
    AC_MSG_RESULT([not usable])
  ])
])

AS_IF([test -n "${CONTRIB_DIR}"], [
  AC_MSG_RESULT([${CONTRIB_DIR}])
  export PATH=${CONTRIB_DIR}/bin:$PATH
  CPPFLAGS="${CPPFLAGS} -I${CONTRIB_DIR}/include"
254

Edric Milaret's avatar
Edric Milaret committed
255 256 257 258 259 260 261 262
  CFLAGS="${CFLAGS} -DPJ_AUTOCONF=1 "
  CXXFLAGS="${CXXFLAGS} -DPJ_AUTOCONF=1 "
  AS_IF([test "${HAVE_WIN64}" = "1"],[
      CFLAGS+=" -DPJ_WIN64=1"
      CXXFLAGS+=" -DPJ_WIN64=1"
  ])
  CFLAGS+=" -I${CONTRIB_DIR}/include"
  CXXFLAGS+=" -I${CONTRIB_DIR}/include"
263

264
  OBJCFLAGS="${OBJCFLAGS} -I${CONTRIB_DIR}/include"
Edric Milaret's avatar
Edric Milaret committed
265 266 267 268 269
  AS_IF([test "${SYS}" = "mingw32"],[
        PKG_CONFIG_PATH_CUSTOM="${CONTRIB_DIR}/lib/pkgconfig:${CONTRIB_DIR}/lib64/pkgconfig"
        AC_SUBST(PKG_CONFIG_PATH_CUSTOM)
        export PKG_CONFIG_PATH_CUSTOM
  ])
270
  export PKG_CONFIG_PATH="${CONTRIB_DIR}/lib/pkgconfig:${CONTRIB_DIR}/lib64/pkgconfig:$PKG_CONFIG_PATH"
aviau's avatar
aviau committed
271
  LDFLAGS="${LDFLAGS} -L${CONTRIB_DIR}/lib"
272 273 274 275

  AS_IF([test "${SYS}" = "darwin"], [
    export LD_LIBRARY_PATH="${CONTRIB_DIR}/lib:$LD_LIBRARY_PATH"
    export DYLD_LIBRARY_PATH="${CONTRIB_DIR}/lib:$DYLD_LIBRARY_PATH"
276 277 278 279
  ], [
      PKG_CHECK_MODULES([Jsoncpp], [jsoncpp >= 1.6.5])
      CPPFLAGS="${CPPFLAGS} ${Jsoncpp_CFLAGS}"
      LDFLAGS="${LDFLAGS} ${Jsoncpp_LIBS}"
280 281 282 283 284 285 286 287
  ])
], [
  AS_IF([test -n "${with_contrib}" && test "${with_contrib}" != "no"], [
    AC_MSG_ERROR([Third party libraries not found!])
  ])
])
AC_SUBST(CONTRIB_DIR)

288 289 290 291 292 293
dnl Add extras/tools to the PATH
TOOLS_DIR="${srcdir}/extras/tools/build/bin"
AS_IF([test -d "${TOOLS_DIR}"], [
  TOOLS_DIR=`cd "${TOOLS_DIR}" && pwd`
  export PATH="${TOOLS_DIR}":$PATH
])
294

aviau's avatar
aviau committed
295 296 297
dnl Check for zlib
PKG_CHECK_MODULES(ZLIB, zlib,, AC_MSG_ERROR([zlib not found]))

298 299 300
dnl Check for pjproject
PKG_CHECK_MODULES(PJPROJECT, libpjproject,, AC_MSG_ERROR([Missing pjproject files]))

301
PKG_CHECK_MODULES([YAMLCPP], [yaml-cpp >= 0.5.1],, AC_MSG_ERROR([yaml-cpp not found]))
Alexandre Lision's avatar
Alexandre Lision committed
302
PKG_CHECK_MODULES([JSONCPP], [jsoncpp >= 1.6.5],, AC_MSG_ERROR([jsoncpp not found]))
303

304
if test "${HAVE_ANDROID}" = "1"; then
305 306 307 308 309 310 311 312 313 314 315 316 317 318 319
    dnl Check for OpenSL
    AC_ARG_WITH([opensl],
                AS_HELP_STRING([--without-opensl],
                               [Ignore presence of opensl and disable it]))

    AS_IF([test "x$with_opensl" != "xno"],
          [AC_CHECK_HEADER(["SLES/OpenSLES.h"],
                           [have_opensl=yes], [have_opensl=no])],
          [have_opensl=no])
    AC_DEFINE_UNQUOTED([HAVE_OPENSL],
                       `if test "x$have_opensl" = "xyes"; then echo 1; else echo 0; fi`,
                       [Define if you have OpenSL])
fi
AM_CONDITIONAL([BUILD_OPENSL], test "x$have_opensl" = "xyes")

320
if test "${SYS}" = "linux"; then
Rafaël Carré's avatar
Rafaël Carré committed
321
dnl Check for alsa development package - name: libasound2-dev
322
ALSA_MIN_VERSION=1.0
323
AC_ARG_WITH([alsa],
324 325 326
    [AS_HELP_STRING([--without-alsa], [disable support for alsa])],
    [],
    [with_alsa=yes])
327
AS_IF([test "x$with_alsa" = "xyes"], [
328
       PKG_CHECK_MODULES(ALSA, alsa >= ${ALSA_MIN_VERSION},, AC_MSG_ERROR([Missing alsa development files]))
329
    ]);
330 331

AC_DEFINE_UNQUOTED([HAVE_ALSA], `if test "x$with_alsa" = "xyes"; then echo 1; else echo 0; fi`, [Define if you have alsa])
332
fi
333 334
AM_CONDITIONAL(BUILD_ALSA, test "x$with_alsa" = "xyes")

335

336
if test "${SYS}" = "linux"; then
Rafaël Carré's avatar
Rafaël Carré committed
337
dnl Check for pulseaudio development package - name: libpulse-dev
338
LIBPULSE_MIN_VERSION=0.9.15
339
AC_ARG_WITH([pulse],
340
    [AS_HELP_STRING([--without-pulse], [disable support for pulseaudio])],
341 342 343
    [],
    [with_pulse=yes])

344
AS_IF([test "x$with_pulse" = "xyes"], [
345
       PKG_CHECK_MODULES(PULSEAUDIO, libpulse >= ${LIBPULSE_MIN_VERSION},, AC_MSG_ERROR([Missing pulseaudio development files]))
346
      ]);
347

348
AC_DEFINE_UNQUOTED([HAVE_PULSE], `if test "x$with_pulse" = "xyes"; then echo 1; else echo 0; fi`, [Define if you have pulseaudio])
349
fi
350
AM_CONDITIONAL(BUILD_PULSE, test "x$with_pulse" = "xyes")
351

352 353 354 355 356 357 358 359 360 361 362 363 364
AC_ARG_WITH([jack],
    AS_HELP_STRING([--without-jack], [Ignore presence of jack and disable it]))

AS_IF([test "x$with_jack" != "xno"],
      [PKG_CHECK_MODULES(JACK, jack, [have_jack=yes], [have_jack=no])],
      [have_jack=no])

AS_IF([test "x$have_jack" = "xyes"],,
      [AS_IF([test "x$with_jack" = "xyes"],
             [AC_MSG_ERROR([jack requested but not found])
      ])
])

Edric Milaret's avatar
Edric Milaret committed
365 366 367 368
dnl check for libportaudio
AS_IF([test "${SYS}" = "mingw32"],[
AC_ARG_WITH([portaudio], [AS_HELP_STRING([--without-portaudio],
            [disable support for portaudio])], [], [with_portaudio=yes])
369
])
Edric Milaret's avatar
Edric Milaret committed
370 371 372
AS_IF([test "x$with_portaudio" = "xyes"],
      [PKG_CHECK_MODULES(PORTAUDIO, [portaudio-2.0],
        [AC_DEFINE([HAVE_PORTAUDIO], 1, [Define if you have portaudio])],
373
        [AC_MSG_ERROR([Missing libportaudio development files])])
Edric Milaret's avatar
Edric Milaret committed
374
      ])
375

Edric Milaret's avatar
Edric Milaret committed
376 377 378
AM_CONDITIONAL(BUILD_PORTAUDIO, test "x$with_portaudio" = "xyes")
AM_CONDITIONAL(HAVE_PORTAUDIO, test "x$with_portaudio" = "xyes")

379 380 381
AC_DEFINE_UNQUOTED([HAVE_JACK], `if test "x$have_jack" = "xyes"; then echo 1; else echo 0; fi`, [Define if you have jack])
AM_CONDITIONAL(BUILD_JACK, test "x$have_jack" = "xyes")

382 383 384 385
dnl Coverage is default-disabled
AC_ARG_ENABLE([coverage], AS_HELP_STRING([--enable-coverage], [Enable coverage]))

AS_IF([test "x$enable_coverage" = "xyes"], [
386 387
        CXXFLAGS="${CXXFLAGS} --coverage"
        LDFLAGS="${LDFLAGS} --coverage"])
388

389 390 391 392 393 394 395 396
# DBUSCPP
dnl Check for dbuscpp, the C++ bindings for D-Bus
AC_ARG_WITH([dbus],
    [AS_HELP_STRING([--without-dbus], [disable support for dbus])],
    [],
    [with_dbus=yes])
AS_IF([test "x$with_dbus" = "xyes"], [
       PKG_CHECK_MODULES(DBUSCPP, dbus-c++-1,, AC_MSG_WARN([Missing dbus development files]))
397

398 399
       AS_AC_EXPAND(LIBDIR, $libdir)
       AC_SUBST(LIBDIR)
400

401
       AC_CONFIG_FILES([bin/dbus/Makefile
Adrien Béraud's avatar
Adrien Béraud committed
402
                        bin/dbus/cx.ring.Ring.service])
403 404 405 406 407 408 409 410 411

       AC_CHECK_PROG(HAVE_DBUSXML2CPP, dbusxx-xml2cpp, true, false)
       if test "x$HAVE_DBUSXML2CPP" = "xfalse"; then
           AC_MSG_ERROR([dbusxx-xml2cpp not found])
       fi

       AS_IF([test "x$CLANG" = "xyes"], [
             AC_MSG_ERROR([dbus does not compile when clang is used, rerun with --without-dbus])
       ]);
412
       AM_CONDITIONAL(RING_DBUS, true)],TESTS= $(check_PROGRAMS)
Adrien Béraud's avatar
Adrien Béraud committed
413
       AM_CONDITIONAL(RING_DBUS, false));
414

Philippe Gorley's avatar
Philippe Gorley committed
415 416 417 418
dnl name service is default-enabled
AC_ARG_ENABLE([ringns], AS_HELP_STRING([--disable-ringns], [Enable Name Service]))
AM_CONDITIONAL([RINGNS], test "x$enable_ringns" != "xno", [Define if you use the Name Service])
AC_DEFINE_UNQUOTED([HAVE_RINGNS], `if test "x$enable_ringns" != "xno"; then echo 1; else echo 0; fi`, [Define if you use the Name Service])
419

Philippe Gorley's avatar
Philippe Gorley committed
420 421 422 423
dnl nodejs module
AC_ARG_WITH([nodejs], AS_HELP_STRING([--with-nodejs], [Enable NodeJS module]))
AM_CONDITIONAL([RING_NODEJS], test "x$enable_nodejs" != "xno", [Define if you use the NodeJS module])
AC_DEFINE_UNQUOTED([HAVE_NODEJS], `if test "x$enable_ringns" != "xno"; then echo 1; else echo 0; fi`, [Define if you use the NodeJS module])
424 425 426 427 428 429 430 431 432 433
AS_IF([test "x$with_nodejs" = "xyes"], [
    AC_PATH_PROG(SWIG, swig, "")
    AS_AC_EXPAND(SBINDIR, $sbindir)
    AC_SUBST(SBINDIR)
    AC_CONFIG_FILES([bin/nodejs/Makefile])
    AM_CONDITIONAL(RING_NODEJS, true)
  ],
  AM_CONDITIONAL(RING_NODEJS, false)
);

434 435 436
# Rest C++ with restbed
AC_ARG_WITH([restcpp],
    AS_HELP_STRING([--with-restcpp], [enable rest support with C++]))
437 438
AC_ARG_ENABLE([restbed_old_api], AS_HELP_STRING([--enable-restbed-old-api], [Use the old restbed API]))
AS_IF([test "x$enable_restbed_old_api" = "xyes"], [
439
  AC_DEFINE([RESTBED_OLD_API], [1], [Defined if you use the old restbed API])
440
])
441

442 443 444 445 446 447 448 449 450 451 452
AS_IF([test "x$enable_ringns" != "xno" || test "x$with_restcpp" = "xyes"], [
  AC_CHECK_LIB(restbed, exit,, AC_MSG_ERROR([Missing restbed files]))
  PKG_CHECK_MODULES(LIBCRYPTO, libcrypto,, AC_MSG_ERROR([Missing libcrypto development files]))
  PKG_CHECK_MODULES(LIBSSL, libssl,, AC_MSG_ERROR([Missing libssl development files]))

  LIBS="${LIBS} -lssl -lcrypto"
  AS_IF([test "${HAVE_WIN32}" = "1"],[
      LIBS="${LIBS} -lssleay32 -leay32"
  ])
  ], []
);
453

454
AS_IF([test "x$with_restcpp" = "xyes"], [
455 456 457
    AS_AC_EXPAND(SBINDIR, $sbindir)
    AC_SUBST(SBINDIR)
    AC_CONFIG_FILES([bin/restcpp/Makefile])
458 459 460 461
    AM_CONDITIONAL(RING_RESTCPP, true)
  ],
  AM_CONDITIONAL(RING_RESTCPP, false)
);
462

463
dnl Check for libav
464
PKG_CHECK_MODULES(LIBAVUTIL, libavutil >= 54.31.100,, AC_MSG_ERROR([Missing libavutil development files]))
465

466
PKG_CHECK_MODULES(LIBAVCODEC, libavcodec >= 56.60.100,, AC_MSG_ERROR([Missing libavcodec development files]))
Philippe Gorley's avatar
Philippe Gorley committed
467
LIBAVCODEC_CFLAGS="${LIBAVCODEC_CFLAGS} -D__STDC_CONSTANT_MACROS"
468

469
PKG_CHECK_MODULES(LIBAVFORMAT, libavformat >= 56.40.101,, AC_MSG_ERROR([Missing libavformat development files]))
470

471
PKG_CHECK_MODULES(LIBAVDEVICE, libavdevice >= 56.4.100,, AC_MSG_ERROR([Missing libavdevice development files]))
472

473 474
PKG_CHECK_MODULES(LIBAVFILTER, libavfilter >= 5.40.101,, AC_MSG_ERROR([Missing libavfilter development files]))

475
PKG_CHECK_MODULES(LIBSWSCALE, libswscale >= 3.1.101,, AC_MSG_ERROR([Missing libswscale development files]))
476

477 478
PKG_CHECK_MODULES(LIBSWRESAMPLE, libswresample >= 1.2.101,, AC_MSG_ERROR([Missing libswresample development files]))

479 480
dnl Video is default-enabled
AC_ARG_ENABLE([video], AS_HELP_STRING([--disable-video], [Disable video]))
481

482
AS_IF([test "x$enable_video" != "xno"],
483
      [
Adrien Béraud's avatar
Adrien Béraud committed
484 485
        AC_DEFINE(ENABLE_VIDEO, [], [Video support enabled])
        AM_CONDITIONAL(ENABLE_VIDEO, true)
486
        AS_IF([test "$SYS" = linux && test -z "${HAVE_ANDROID_FALSE}"],[
487 488 489
            PKG_CHECK_MODULES(UDEV, libudev,, AC_MSG_ERROR([Missing libudev development files]))
        ],[
        ])
490
    ],
491
    [
Adrien Béraud's avatar
Adrien Béraud committed
492
     AM_CONDITIONAL(ENABLE_VIDEO, false)
493
     ]);
494

495
AC_ARG_ENABLE([accel], AS_HELP_STRING([--disable-accel], [Disable all hardware accelerations (enabled by default)]))
496
AS_IF([test "x$enable_video" != "xno" -a "x$enable_accel" != "xno"], [
Philippe Gorley's avatar
Philippe Gorley committed
497
  dnl if new hwaccel api is found, activate hardware accel
498 499 500
  dnl prefix needs to be different from the one above
  PKG_CHECK_MODULES(AVUTIL, libavutil >= 55.75.100, [
    ring_accel="yes"
Philippe Gorley's avatar
Philippe Gorley committed
501
    AC_DEFINE([RING_ACCEL], [1], [Hardware acceleration is enabled])
502 503 504 505
    AS_IF([test "${SYS}" = "darwin"], [
      AC_CHECK_HEADER([VideoToolbox/VideoToolbox.h], [
        AC_CHECK_HEADER([libavcodec/videotoolbox.h], [
          ring_vt="yes"
Adrien Béraud's avatar
Adrien Béraud committed
506
          AC_DEFINE([ENABLE_VIDEOTOOLBOX], [1], [Defined if videotoolbox is available])
507
        ])
508
      ])
509
    ])
Adrien Béraud's avatar
Adrien Béraud committed
510
  ],[])
511 512 513 514
])
AM_CONDITIONAL([RING_ACCEL], [test "x${ring_accel}" = "xyes"])

dnl check for GnuTLS
515
PKG_CHECK_MODULES([GNUTLS], [gnutls >= 3.6.7], [HAVE_GNUTLS=1], [HAVE_GNUTLS=0])
516 517 518

# PTHREAD
# required dependency(ies): libxpat
519
AX_PTHREAD
520

521 522 523
dnl Check for libcppunit-dev
CPPUNIT_MIN_VERSION=1.12
PKG_CHECK_MODULES(CPPUNIT, cppunit >= ${CPPUNIT_MIN_VERSION}, AM_CONDITIONAL(BUILD_TEST, test 1 = 1 ), AM_CONDITIONAL(BUILD_TEST, test 0 = 1 ))
524

525

526 527
# SPEEX CODEC
# required dependency(ies): libspeex
528
dnl Check for libspeex
529
AC_ARG_WITH([speex],
530
        [AS_HELP_STRING([--without-speex], [disable support for speex codec])],
531 532
        [],
        [with_speex=yes])
533

534
AS_IF([test "x$with_speex" != xno], [PKG_CHECK_MODULES([SPEEX], [speex])])
535

Rafaël Carré's avatar
Rafaël Carré committed
536
AC_DEFINE_UNQUOTED([HAVE_SPEEX], `if test "x$with_speex" = "xyes"; then echo 1; else echo 0; fi`, [Define if you have libspeex])
537
AM_CONDITIONAL(BUILD_SPEEX, test "x$with_speex" = "xyes" )
538

539

540 541
# SPEEX DSP
# required dependency(ies): libspeexdsp
542
dnl check in case the libspeexdsp is not installed
543
AC_ARG_WITH([speexdsp],
544 545 546 547
    [AS_HELP_STRING([--without-speexdsp],
    [disable support for speexdp Noise Suppression and Automatic Gain Control])],
    [],
    [with_speexdsp=yes])
548

549
AS_IF([test "x$with_speexdsp" != xno], [PKG_CHECK_MODULES([SPEEXDSP], [speexdsp])])
550 551 552
AC_DEFINE_UNQUOTED([HAVE_SPEEXDSP], `if test "x$with_speexdsp" = "xyes"; then echo 1; else echo 0; fi`, [Define if you have libspeexdsp])
AM_CONDITIONAL(BUILD_SPEEXDSP, test "x$with_speexdsp" = "xyes" )

553 554
dnl check for openDHT
PKG_CHECK_MODULES([OPENDHT], [opendht >= 0.6.1],, AC_MSG_WARN([Missing OpenDHT]))
Adrien Béraud's avatar
Adrien Béraud committed
555

556
PKG_CHECK_MODULES([SECP256K1], [libsecp256k1 >= 0.1],, AC_MSG_FAILURE([Missing secp256k1]))
557

558 559
# LIBUPNP
dnl check for libupnp
560 561 562
AC_ARG_WITH([upnp], [AS_HELP_STRING([--without-upnp],
            [disable support for upnp])], [], [with_upnp=yes])

563 564 565 566 567 568
AS_IF([test "x$with_upnp" = "xyes"],
      [PKG_CHECK_MODULES(LIBUPNP, [libupnp],
        [AC_DEFINE([HAVE_LIBUPNP], 1, [Define if you have libupnp])],
        [AC_MSG_WARN([Missing libupnp development files])
         AC_DEFINE([HAVE_LIBUPNP], 0, [Define if you have libupnp])])
      ])
569
AM_CONDITIONAL([BUILD_PUPNP], test "x$with_upnp" = "xyes")
570

571 572 573 574 575 576 577 578 579 580 581 582 583
# LIBNATPMP
dnl check for libnatpmp
AC_ARG_WITH([natpmp], [AS_HELP_STRING([--without-natpmp],
            [disable support for NAT-PMP])], [], [with_natpmp=yes])

AS_IF([test "x$with_natpmp" != xno],
        [AC_CHECK_HEADER([natpmp.h],
            AC_CHECK_LIB([natpmp], [initnatpmp], [], [with_natpmp=no]),
            [AC_MSG_WARN([Unable to find the libnatpmp headers (you may need to install the dev package). You may use --without-natpmp to compile without NAT-PMP support.]);
             with_natpmp=no])
        ],[])

AC_DEFINE_UNQUOTED([HAVE_LIBNATPMP], `if test "x$with_natpmp" != xno; then echo 1; else echo 0; fi`, [Define if you have libnatpmp])
584
AM_CONDITIONAL([BUILD_NATPMP], test "x$with_natpmp" = "xyes")
585

586
AC_DEFINE_UNQUOTED([HAVE_SHM], `if test -z "${HAVE_LINUX_TRUE}" && test -z "${HAVE_ANDROID_FALSE}" ; then echo 1; else echo 0; fi`,
587
    [Define if you have shared memory support])
588

589 590
# DOXYGEN
# required dependency(ies): doxygen
591 592 593
# check for doxygen, mostly stolen from http://log4cpp.sourceforge.net/
# ----------------------------------------------------------------------------
AC_DEFUN([BB_ENABLE_DOXYGEN],
Rafaël Carré's avatar
Rafaël Carré committed
594
    [
595
    AC_ARG_ENABLE(doxygen, [  --enable-doxygen        enable documentation generation with doxygen (disabled by default)])
Rafaël Carré's avatar
Rafaël Carré committed
596
    AC_ARG_ENABLE(dot, [  --enable-dot            use 'dot' to generate graphs in doxygen (auto)])
597
    if test "x$enable_doxygen" = xyes; then
Rafaël Carré's avatar
Rafaël Carré committed
598
        AC_PATH_PROG(DOXYGEN, doxygen, , $PATH)
599
        test x$DOXYGEN = x && AC_MSG_ERROR([could not find doxygen])
Rafaël Carré's avatar
Rafaël Carré committed
600
        AC_PATH_PROG(DOT, dot, , $PATH)
601
        test x$DOT = x -a "x$enable_dot" = xyes && AC_MSG_ERROR([could not find dot])
Rafaël Carré's avatar
Rafaël Carré committed
602
    fi
603
    AM_CONDITIONAL(ENABLE_DOXYGEN, test "x$DOXYGEN" != "x")
Rafaël Carré's avatar
Rafaël Carré committed
604
])
605

606 607
# Actually perform the doxygen check
BB_ENABLE_DOXYGEN
608

609
AC_CONFIG_FILES([Makefile \
610
                 bin/Makefile \
611 612 613
                 src/Makefile \
                 src/sip/Makefile \
                 src/im/Makefile \
614 615 616
                 src/jamidht/Makefile \
                 src/jamidht/eth/libdevcore/Makefile \
                 src/jamidht/eth/libdevcrypto/Makefile \
617 618 619 620 621 622 623
                 src/media/Makefile \
                 src/media/audio/Makefile \
                 src/media/audio/pulseaudio/Makefile \
                 src/media/audio/alsa/Makefile \
                 src/media/audio/opensl/Makefile \
                 src/media/audio/jack/Makefile \
                 src/media/audio/coreaudio/Makefile \
Edric Milaret's avatar
Edric Milaret committed
624
                 src/media/audio/portaudio/Makefile \
625
                 src/media/audio/sound/Makefile \
626
                 src/config/Makefile \
627
                 src/client/Makefile \
628
                 src/hooks/Makefile \
629 630
                 src/media/video/Makefile \
                 src/media/video/v4l2/Makefile \
631
                 src/media/video/androidvideo/Makefile \
632
                 src/media/video/osxvideo/Makefile \
633
                 src/media/video/iosvideo/Makefile \
Edric Milaret's avatar
Edric Milaret committed
634
                 src/media/video/winvideo/Makefile \
635
                 src/security/Makefile \
636
                 src/upnp/Makefile \
637 638 639
                 src/upnp/protocol/Makefile \
                 src/upnp/protocol/natpmp/Makefile \
                 src/upnp/protocol/pupnp/Makefile \
640
                 ringtones/Makefile \
Guillaume Roguez's avatar
Guillaume Roguez committed
641
                 test/Makefile\
642 643
                 test/sip/Makefile
                 test/turn/Makefile \
644 645
                 test/unitTest/Makefile \

646 647 648
                 man/Makefile \
                 doc/Makefile \
                 doc/doxygen/Makefile])
649

650
# Go!
Rafaël Carré's avatar
Rafaël Carré committed
651
AC_OUTPUT