configure.ac 25.7 KB
Newer Older
1
dnl Ring - 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([Ring Daemon],[5.1.0],[ring@gnu.org],[ring])
6

Guillaume Roguez's avatar
Guillaume Roguez committed
7
AC_COPYRIGHT([[Copyright (c) Savoir-faire Linux 2004-2018]])
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
dnl Check for programs
AC_PROG_CC
AC_PROG_CXX
27
AC_PROG_OBJCXX
28 29 30 31
AC_PROG_CPP
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
Adrien Béraud's avatar
Adrien Béraud committed
32
AC_LANG(C++)
33

34 35 36 37
dnl
dnl  Check the operating system
dnl
HAVE_WIN64="0"
38
HAVE_IOS="0"
39 40 41 42 43 44 45 46 47 48
HAVE_OSX="0"

case "${host_os}" in
  "")
    SYS=unknown
    ;;
  linux*)
    SYS=linux
    # Necessary for linking .a to a .so
    LDFLAGS+=" -Wl,-Bsymbolic"
49 50
    # Needed for plugin system
    LDFLAGS+=" -ldl"
51 52 53
    ;;
  darwin*)
    SYS=darwin
Guillaume Roguez's avatar
Guillaume Roguez committed
54 55 56 57 58 59 60 61
    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"])
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
    ;;
  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.])
Edric Milaret's avatar
Edric Milaret committed
77

Edric Milaret's avatar
Edric Milaret committed
78
    AC_DEFINE([WIN32_LEAN_AND_MEAN],[1], [Define to limit the scope of <windows.h>.])
Edric Milaret's avatar
Edric Milaret committed
79

80
    CPPFLAGS+="-D_WIN32_WINNT=0x0601 -DWINVER=0x0601 -D__USE_MINGW_ANSI_STDIO=1"
81 82
    LDFLAGS+="-Wl,--nxcompat -Wl,--dynamicbase"
    LIBS+=" -lws2_32"
83 84 85 86
    ac_default_prefix="`pwd`/_win32"
    DESTDIR="`pwd`/_win32/"
    AC_SUBST(WINDOWS_ARCH)
    AC_SUBST(PROGRAMFILES)
Edric Milaret's avatar
Edric Milaret committed
87 88 89 90 91 92

    case "${host}" in
            amd64*|x86_64*)
                HAVE_WIN64="1"
            ;;
    esac
93 94 95 96 97 98 99 100 101 102
    ;;
  *)
    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")
Edric Milaret's avatar
Edric Milaret committed
103
AM_CONDITIONAL(HAVE_IOS,   test "${HAVE_IOS}" = "1")
104

105 106
dnl FIXME this should be deduced automatically
AC_DEFINE_UNQUOTED([HAVE_COREAUDIO],
107
                    `if test "${HAVE_OSX}" = "1" || test "${HAVE_IOS}" = "1"; then echo 1; else echo 0; fi`,
108 109
                    [Define if you have CoreAudio])

110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
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")

127 128 129 130 131 132 133
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])
134

Rafaël Carré's avatar
Rafaël Carré committed
135
dnl Define C++ as default language
136 137
LT_LANG(C++)

Luca Barbato's avatar
Luca Barbato committed
138 139
DOLT

140
lt_cv_deplibs_check_method=pass_all
yanmorin's avatar
 
yanmorin committed
141

Guillaume Roguez's avatar
Guillaume Roguez committed
142 143
dnl Check for C++14 support
AX_CXX_COMPILE_STDCXX(14,[ext],[mandatory])
144

Rafaël Carré's avatar
Rafaël Carré committed
145 146 147
dnl Check for header files
AC_FUNC_ALLOCA
AC_HEADER_STDC
148 149 150
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
151 152 153 154 155 156 157 158 159 160

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
161 162
AC_CHECK_TYPES([ptrdiff_t])

Tristan Matthews's avatar
Tristan Matthews committed
163
PKG_PROG_PKG_CONFIG()
yanmorin's avatar
 
yanmorin committed
164

165 166 167 168 169 170 171
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"
    ])
])

172 173 174 175 176 177 178 179 180 181 182
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])
183

184 185 186 187 188 189 190 191 192
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"], [
Tristan Matthews's avatar
Tristan Matthews committed
193
  CONTRIB_DIR="${srcdir}/contrib/${host}"
194 195
  AS_IF([test ! -d "${CONTRIB_DIR}"], [
    echo "${CONTRIB_DIR} not found" >&AS_MESSAGE_LOG_FD
Tristan Matthews's avatar
Tristan Matthews committed
196
    CONTRIB_DIR="${srcdir}/contrib/`$CC -dumpmachine`"
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225
    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"
226

Edric Milaret's avatar
Edric Milaret committed
227 228 229 230 231 232 233 234
  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"
235

236
  OBJCFLAGS="${OBJCFLAGS} -I${CONTRIB_DIR}/include"
Edric Milaret's avatar
Edric Milaret committed
237 238 239 240 241
  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
  ])
242
  export PKG_CONFIG_PATH="${CONTRIB_DIR}/lib/pkgconfig:${CONTRIB_DIR}/lib64/pkgconfig:$PKG_CONFIG_PATH"
aviau's avatar
aviau committed
243
  LDFLAGS="${LDFLAGS} -L${CONTRIB_DIR}/lib"
244 245 246 247

  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"
248 249 250 251
  ], [
      PKG_CHECK_MODULES([Jsoncpp], [jsoncpp >= 1.6.5])
      CPPFLAGS="${CPPFLAGS} ${Jsoncpp_CFLAGS}"
      LDFLAGS="${LDFLAGS} ${Jsoncpp_LIBS}"
252 253 254 255 256 257 258 259
  ])
], [
  AS_IF([test -n "${with_contrib}" && test "${with_contrib}" != "no"], [
    AC_MSG_ERROR([Third party libraries not found!])
  ])
])
AC_SUBST(CONTRIB_DIR)

260 261 262 263 264 265
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
])
266

aviau's avatar
aviau committed
267 268 269
dnl Check for zlib
PKG_CHECK_MODULES(ZLIB, zlib,, AC_MSG_ERROR([zlib not found]))

270 271 272
dnl Check for pjproject
PKG_CHECK_MODULES(PJPROJECT, libpjproject,, AC_MSG_ERROR([Missing pjproject files]))

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

276
if test "${HAVE_ANDROID}" = "1"; then
277 278 279 280 281 282 283 284 285 286 287 288 289 290 291
    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")

292
if test "${SYS}" = "linux"; then
Rafaël Carré's avatar
Rafaël Carré committed
293
dnl Check for alsa development package - name: libasound2-dev
294
ALSA_MIN_VERSION=1.0
295
AC_ARG_WITH([alsa],
Guillaume Roguez's avatar
Guillaume Roguez committed
296 297 298
    [AS_HELP_STRING([--without-alsa], [disable support for alsa])],
    [],
    [with_alsa=yes])
299
AS_IF([test "x$with_alsa" = "xyes"], [
300
       PKG_CHECK_MODULES(ALSA, alsa >= ${ALSA_MIN_VERSION},, AC_MSG_ERROR([Missing alsa development files]))
Guillaume Roguez's avatar
Guillaume Roguez committed
301
    ]);
302 303

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

307

308
if test "${SYS}" = "linux"; then
Rafaël Carré's avatar
Rafaël Carré committed
309
dnl Check for pulseaudio development package - name: libpulse-dev
310
LIBPULSE_MIN_VERSION=0.9.15
311
AC_ARG_WITH([pulse],
312
    [AS_HELP_STRING([--without-pulse], [disable support for pulseaudio])],
313 314 315
    [],
    [with_pulse=yes])

316
AS_IF([test "x$with_pulse" = "xyes"], [
317
       PKG_CHECK_MODULES(PULSEAUDIO, libpulse >= ${LIBPULSE_MIN_VERSION},, AC_MSG_ERROR([Missing pulseaudio development files]))
318
      ]);
319

320
AC_DEFINE_UNQUOTED([HAVE_PULSE], `if test "x$with_pulse" = "xyes"; then echo 1; else echo 0; fi`, [Define if you have pulseaudio])
321
fi
322
AM_CONDITIONAL(BUILD_PULSE, test "x$with_pulse" = "xyes")
323

324 325 326 327 328 329 330 331 332 333 334 335 336
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
337 338 339 340
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])
341
])
Edric Milaret's avatar
Edric Milaret committed
342 343 344
AS_IF([test "x$with_portaudio" = "xyes"],
      [PKG_CHECK_MODULES(PORTAUDIO, [portaudio-2.0],
        [AC_DEFINE([HAVE_PORTAUDIO], 1, [Define if you have portaudio])],
345
        [AC_MSG_ERROR([Missing libportaudio development files])])
Edric Milaret's avatar
Edric Milaret committed
346
      ])
347

Edric Milaret's avatar
Edric Milaret committed
348 349 350
AM_CONDITIONAL(BUILD_PORTAUDIO, test "x$with_portaudio" = "xyes")
AM_CONDITIONAL(HAVE_PORTAUDIO, test "x$with_portaudio" = "xyes")

351 352 353
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")

354 355
dnl Check for the samplerate development package - name: libsamplerate0-dev
LIBSAMPLERATE_MIN_VERSION=0.1.2
356
PKG_CHECK_MODULES(SAMPLERATE, samplerate >= ${LIBSAMPLERATE_MIN_VERSION},, AC_MSG_ERROR([Missing libsamplerate development files]))
357

358
dnl Check for the sndfile development package - name: libsndfile-dev
359
PKG_CHECK_MODULES(SNDFILE, sndfile,, AC_MSG_ERROR([Missing sndfile development files]))
360

361 362 363 364
dnl Coverage is default-disabled
AC_ARG_ENABLE([coverage], AS_HELP_STRING([--enable-coverage], [Enable coverage]))

AS_IF([test "x$enable_coverage" = "xyes"], [
365 366
        CXXFLAGS="${CXXFLAGS} --coverage"
        LDFLAGS="${LDFLAGS} --coverage"])
367

368 369 370 371 372 373 374 375
# 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]))
376

aviau's avatar
aviau committed
377 378
       AS_AC_EXPAND(LIBDIR, $libdir)
       AC_SUBST(LIBDIR)
379

380
       AC_CONFIG_FILES([bin/dbus/Makefile
Adrien Béraud's avatar
Adrien Béraud committed
381
                        bin/dbus/cx.ring.Ring.service])
382 383 384 385 386 387 388 389 390

       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])
       ]);
391
       AM_CONDITIONAL(RING_DBUS, true)],TESTS= $(check_PROGRAMS)
Adrien Béraud's avatar
Adrien Béraud committed
392
       AM_CONDITIONAL(RING_DBUS, false));
393

394 395 396 397 398
dnl Ring name service is default-enabled
AC_ARG_ENABLE([ringns], AS_HELP_STRING([--disable-ringns], [Enable Ring Name Service]))
AM_CONDITIONAL([RINGNS], test "x$enable_ringns" != "xno", [Define if you use the Ring 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 Ring Name Service])

Adrien Béraud's avatar
Adrien Béraud committed
399 400 401 402 403 404 405 406 407 408 409 410 411 412
dnl Ring nodejs module
AC_ARG_WITH([nodejs], AS_HELP_STRING([--with-nodejs], [Enable Ring NodeJS module]))
AM_CONDITIONAL([RING_NODEJS], test "x$enable_nodejs" != "xno", [Define if you use the Ring 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 Ring NodeJS module])
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)
);

Guillaume Roguez's avatar
Guillaume Roguez committed
413 414 415
# Rest C++ with restbed
AC_ARG_WITH([restcpp],
    AS_HELP_STRING([--with-restcpp], [enable rest support with C++]))
416 417 418 419
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"], [
  AC_DEFINE([RESTBED_OLD_API], [], [Defined if you use the old restbed API])
])
Guillaume Roguez's avatar
Guillaume Roguez committed
420

421 422 423 424 425 426 427 428 429 430 431
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"
  ])
  ], []
);
Guillaume Roguez's avatar
Guillaume Roguez committed
432

433
AS_IF([test "x$with_restcpp" = "xyes"], [
Guillaume Roguez's avatar
Guillaume Roguez committed
434 435 436
    AS_AC_EXPAND(SBINDIR, $sbindir)
    AC_SUBST(SBINDIR)
    AC_CONFIG_FILES([bin/restcpp/Makefile])
437 438 439 440
    AM_CONDITIONAL(RING_RESTCPP, true)
  ],
  AM_CONDITIONAL(RING_RESTCPP, false)
);
441

442
dnl Check for libav
Philippe Gorley's avatar
Philippe Gorley committed
443
PKG_CHECK_MODULES(LIBAVUTIL, libavutil >= 54.31.100,, AC_MSG_ERROR([Missing libavutil development files]))
444

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

Philippe Gorley's avatar
Philippe Gorley committed
448
PKG_CHECK_MODULES(LIBAVFORMAT, libavformat >= 56.40.101,, AC_MSG_ERROR([Missing libavformat development files]))
449

Philippe Gorley's avatar
Philippe Gorley committed
450
PKG_CHECK_MODULES(LIBAVDEVICE, libavdevice >= 56.4.100,, AC_MSG_ERROR([Missing libavdevice development files]))
451

452 453
PKG_CHECK_MODULES(LIBAVFILTER, libavfilter >= 5.40.101,, AC_MSG_ERROR([Missing libavfilter development files]))

Philippe Gorley's avatar
Philippe Gorley committed
454
PKG_CHECK_MODULES(LIBSWSCALE, libswscale >= 3.1.101,, AC_MSG_ERROR([Missing libswscale development files]))
455

Tristan Matthews's avatar
Tristan Matthews committed
456 457
dnl Video is default-enabled
AC_ARG_ENABLE([video], AS_HELP_STRING([--disable-video], [Disable video]))
458

Tristan Matthews's avatar
Tristan Matthews committed
459
AS_IF([test "x$enable_video" != "xno"],
460
      [
Adrien Béraud's avatar
Adrien Béraud committed
461 462
        AC_DEFINE(RING_VIDEO, [], [Video support enabled])
        AM_CONDITIONAL(RING_VIDEO, true)
Adrien Béraud's avatar
Adrien Béraud committed
463
        AS_IF([test "$SYS" = linux && test -z "${HAVE_ANDROID_FALSE}"],[
464 465 466
            PKG_CHECK_MODULES(UDEV, libudev,, AC_MSG_ERROR([Missing libudev development files]))
        ],[
        ])
467
    ],
468
    [
Adrien Béraud's avatar
Adrien Béraud committed
469
     AM_CONDITIONAL(RING_VIDEO, false)
470
     ]);
471

Philippe Gorley's avatar
Philippe Gorley committed
472
AC_ARG_ENABLE([accel], AS_HELP_STRING([--disable-accel], [Disable all hardware accelerations (enabled by default)]))
473
AS_IF([test "x$enable_video" != "xno" -a "x$enable_accel" != "xno"], [
Philippe Gorley's avatar
Philippe Gorley committed
474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493
  dnl if new hwaccel api is found, activate Ring's hardware accel
  dnl prefix needs to be different from the one above
  PKG_CHECK_MODULES(AVUTIL, libavutil >= 55.75.100, [
    ring_accel="yes"
    AC_DEFINE([RING_ACCEL], [1], [Hardware acceleration is enabled in Ring])
    AS_IF([test "${SYS}" = "linux" && test -z "${HAVE_ANDROID_FALSE}"], [
      dnl ffmpeg's vaapi and vdpau implementations depend on x11
      PKG_CHECK_MODULES([X11], [x11], [x11_available="yes"], [x11_available="no"])
      AS_IF([test "${x11_available}" = "yes"], [
        PKG_CHECK_MODULES([LIBVA], [libva], [
          PKG_CHECK_MODULES([LIBVA_DRM], [libva-drm], [
            AC_DEFINE([HAVE_VAAPI_ACCEL_DRM], [1], [Defined if vaapi via DRM is available])
          ], [])
          PKG_CHECK_MODULES([LIBVA_X11], [libva-x11], [
            AC_DEFINE([HAVE_VAAPI_ACCEL_X11], [1], [Defined if vaapi via X11 is available])
          ], [])
          AC_CHECK_HEADERS([libavcodec/vaapi.h], [
            ring_vaapi="yes"
            AC_DEFINE([RING_VAAPI], [1], [Defined if vaapi is available in Ring])
          ])
Philippe Gorley's avatar
Philippe Gorley committed
494
        ], [])
Philippe Gorley's avatar
Philippe Gorley committed
495 496 497 498 499
        PKG_CHECK_MODULES([VDPAU], [vdpau], [
          AC_CHECK_HEADERS([libavcodec/vdpau.h], [
            ring_vdpau="yes"
            AC_DEFINE([RING_VDPAU], [1], [Defined if vdpau is available in Ring])
          ])
Philippe Gorley's avatar
Philippe Gorley committed
500
        ], [])
Philippe Gorley's avatar
Philippe Gorley committed
501
      ])
502
    ])
Philippe Gorley's avatar
Philippe Gorley committed
503 504 505 506 507 508
    AS_IF([test "${SYS}" = "darwin"], [
      AC_CHECK_HEADER([VideoToolbox/VideoToolbox.h], [
        AC_CHECK_HEADER([libavcodec/videotoolbox.h], [
          ring_vt="yes"
          AC_DEFINE([RING_VIDEOTOOLBOX], [1], [Defined if videotoolbox is available in Ring])
        ])
Philippe Gorley's avatar
Philippe Gorley committed
509
      ])
510
    ])
Philippe Gorley's avatar
Philippe Gorley committed
511
  ],[AC_MSG_NOTICE([HWAccel API not found])])
512 513 514
])
AM_CONDITIONAL([RING_ACCEL], [test "x${ring_accel}" = "xyes"])
AM_CONDITIONAL([RING_VAAPI], [test "x${ring_vaapi}" = "xyes"])
515
AM_CONDITIONAL([RING_VDPAU], [test "x${ring_vdpau}" = "xyes"])
516
AM_CONDITIONAL([RING_VIDEOTOOLBOX], [test "x${ring_vt}" = "xyes"])
517 518 519

dnl check for GnuTLS
PKG_CHECK_MODULES([GNUTLS], [gnutls >= 3.4.14], [HAVE_GNUTLS=1], [HAVE_GNUTLS=0])
520 521 522

# PTHREAD
# required dependency(ies): libxpat
523
AX_PTHREAD
524

525

526 527
# SDES Key Exchange
# required dependency(ies): libpcre
528
AC_ARG_WITH([sdes],
529
    [AS_HELP_STRING([--without-sdes], [disable support for sdes key exchange])],
530 531
    [],
    [with_sdes=yes])
532
AS_IF([test "x$with_sdes" = "xyes"], [
533
      PKG_CHECK_MODULES(PCRE, [libpcre],,AC_MSG_ERROR([libpcre not found]))]);
534

535 536
AC_DEFINE_UNQUOTED([HAVE_SDES], `if test "x$with_sdes" = "xyes"; then echo 1; else echo 0; fi`, [Define if you have sdes support])
AM_CONDITIONAL(BUILD_SDES, test "x$with_sdes" = "xyes" )
Alexandre Savard's avatar
Alexandre Savard committed
537

538

539 540 541
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 ))
542

543

544
if test "${SYS}" != "mingw32"; then
545 546
# GSM CODEC
# required dependency(ies): libgsm
547 548
dnl check for libgsm1 (doesn't use pkg-config)
dnl Check for libgsm
549
AC_ARG_WITH([gsm], [AS_HELP_STRING([--without-gsm],
550
            [disable support for gsm codec])], [], [with_gsm=yes])
551 552 553

LIBGSM=
AS_IF([test "x$with_gsm" != xno],
554 555 556 557 558
        [AC_CHECK_HEADER([gsm/gsm.h], , AC_MSG_FAILURE([Unable to find the libgsm1 headers (you may need to install the dev package).  You may use --without-gsm to compile without gsm codec support.]))]
        [AC_CHECK_LIB([gsm], [gsm_decode], [], [
            AC_MSG_FAILURE([libgsm link test failed. You may use --without-gsm to compile without gsm codec support.])
        ])
    ])
559

560
AC_DEFINE_UNQUOTED([HAVE_GSM], `if test "x$with_gsm" = "xyes"; then echo 1; else echo 0; fi`, [Define if you have libgsm])
561
fi
562 563
AM_CONDITIONAL(BUILD_GSM, test "x$with_gsm" = "xyes" )

564

565 566
# SPEEX CODEC
# required dependency(ies): libspeex
567
dnl Check for libspeex
568
AC_ARG_WITH([speex],
569
        [AS_HELP_STRING([--without-speex], [disable support for speex codec])],
570 571
        [],
        [with_speex=yes])
572

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

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

578

579 580
# SPEEX DSP
# required dependency(ies): libspeexdsp
581
dnl check in case the libspeexdsp is not installed
582
AC_ARG_WITH([speexdsp],
583 584 585 586
    [AS_HELP_STRING([--without-speexdsp],
    [disable support for speexdp Noise Suppression and Automatic Gain Control])],
    [],
    [with_speexdsp=yes])
587

588
AS_IF([test "x$with_speexdsp" != xno], [PKG_CHECK_MODULES([SPEEXDSP], [speexdsp])])
589 590 591 592

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" )

593
dnl iLBC is enabled if it's installed
594
AC_ARG_WITH([libilbc],
595 596 597 598 599 600
  [AS_HELP_STRING([--with-libilbc],
    [support ilbc audio @<:@default=check@:>@])],
  [],
  [with_libilbc=check])
AS_CASE(["$with_libilbc"],
  [yes], [PKG_CHECK_MODULES([libilbc], [libilbc], [HAVE_LIBILBC=1])],
601
  [no], [HAVE_LIBILBC=0],
602
  [PKG_CHECK_MODULES([libilbc], [libilbc], [HAVE_LIBILBC=1], [HAVE_LIBILBC=0])])
603
AM_CONDITIONAL([BUILD_ILBC], [test "$HAVE_LIBILBC" -eq 1])
jpbl's avatar
jpbl committed
604

605
dnl opus is enabled if it's installed
606
AC_ARG_WITH([opus],
607 608 609
  [AS_HELP_STRING([--with-opus], [support opus audio @<:@default=check@:>@])], [], [with_opus=check])
AS_CASE(["$with_opus"],
  [yes], [PKG_CHECK_MODULES([opus], [opus], [HAVE_OPUS=1])],
610
  [no], [HAVE_OPUS=0],
611
  [PKG_CHECK_MODULES([opus], [opus], [HAVE_OPUS=1], [HAVE_OPUS=0])])
612
AM_CONDITIONAL([BUILD_OPUS], [test "$HAVE_OPUS" -eq 1])
jpbl's avatar
jpbl committed
613

614 615
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
616

617
PKG_CHECK_MODULES([SECP256K1], [libsecp256k1 >= 0.1],, AC_MSG_FAILURE([Missing secp256k1]))
Adrien Béraud's avatar
Adrien Béraud committed
618

619 620 621
dnl IPv6 mode is default-disabled
AC_ARG_ENABLE([ipv6], AS_HELP_STRING([--enable-ipv6], [Enable IPv6 support]))

Adrien Béraud's avatar
Adrien Béraud committed
622 623
AC_DEFINE_UNQUOTED([HAVE_IPV6], `if test "x$enable_ipv6" = "xyes"; then echo 1; else echo 0; fi`, [Define if you have IPv6])
AM_CONDITIONAL(BUILD_IPV6, test "x$enable_ipv6" = "xyes" )
624

Stepan Salenikovich's avatar
Stepan Salenikovich committed
625 626
# LIBUPNP
dnl check for libupnp
Stepan Salenikovich's avatar
Stepan Salenikovich committed
627 628 629
AC_ARG_WITH([upnp], [AS_HELP_STRING([--without-upnp],
            [disable support for upnp])], [], [with_upnp=yes])

Stepan Salenikovich's avatar
Stepan Salenikovich committed
630 631 632 633 634 635
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])])
      ])
636

Adrien Béraud's avatar
Adrien Béraud committed
637 638 639 640 641 642 643 644 645 646 647 648 649 650
# 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])

651
AC_DEFINE_UNQUOTED([HAVE_SHM], `if test -z "${HAVE_LINUX_TRUE}" && test -z "${HAVE_ANDROID_FALSE}" ; then echo 1; else echo 0; fi`,
Guillaume Roguez's avatar
Guillaume Roguez committed
652
    [Define if you have shared memory support])
653

654 655
# DOXYGEN
# required dependency(ies): doxygen
656 657 658
# check for doxygen, mostly stolen from http://log4cpp.sourceforge.net/
# ----------------------------------------------------------------------------
AC_DEFUN([BB_ENABLE_DOXYGEN],
Rafaël Carré's avatar
Rafaël Carré committed
659
    [
Rafaël Carré's avatar
Rafaël Carré committed
660
    AC_ARG_ENABLE(doxygen, [  --enable-doxygen        enable documentation generation with doxygen (disabled by default)])
Rafaël Carré's avatar
Rafaël Carré committed
661
    AC_ARG_ENABLE(dot, [  --enable-dot            use 'dot' to generate graphs in doxygen (auto)])
Rafaël Carré's avatar
Rafaël Carré committed
662
    if test "x$enable_doxygen" = xyes; then
Rafaël Carré's avatar
Rafaël Carré committed
663
        AC_PATH_PROG(DOXYGEN, doxygen, , $PATH)
Rafaël Carré's avatar
Rafaël Carré committed
664
        test x$DOXYGEN = x && AC_MSG_ERROR([could not find doxygen])
Rafaël Carré's avatar
Rafaël Carré committed
665
        AC_PATH_PROG(DOT, dot, , $PATH)
Rafaël Carré's avatar
Rafaël Carré committed
666
        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
667
    fi
668
    AM_CONDITIONAL(ENABLE_DOXYGEN, test "x$DOXYGEN" != "x")
Rafaël Carré's avatar
Rafaël Carré committed
669
])
670

671 672
# Actually perform the doxygen check
BB_ENABLE_DOXYGEN
673 674


675 676 677 678
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"],
679 680
      [CXXFLAGS="${CXXFLAGS} -g -fno-omit-frame-pointer -Wall -Wextra -Wnon-virtual-dtor -Wno-unknown-pragmas -Wformat=2 -O0"],
      [CXXFLAGS="${CXXFLAGS} -DNDEGUG=1"])
681 682 683

dnl What Makefiles to generate

Guillaume Roguez's avatar
Guillaume Roguez committed
684

685
#TODO: split this list across where the relevant check is performed
686
AC_CONFIG_FILES([Makefile \
687
                 bin/Makefile \
688 689 690
                 src/Makefile \
                 src/sip/Makefile \
                 src/im/Makefile \
691
                 src/ringdht/Makefile \
Adrien Béraud's avatar
Adrien Béraud committed
692 693
                 src/ringdht/eth/libdevcore/Makefile \
                 src/ringdht/eth/libdevcrypto/Makefile \
694 695 696 697 698 699 700
                 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
701
                 src/media/audio/portaudio/Makefile \
702
                 src/media/audio/sound/Makefile \
703
                 src/config/Makefile \
704
                 src/client/Makefile \
705
                 src/hooks/Makefile \
706 707
                 src/media/video/Makefile \
                 src/media/video/v4l2/Makefile \
708
                 src/media/video/androidvideo/Makefile \
709
                 src/media/video/osxvideo/Makefile \
710
                 src/media/video/iosvideo/Makefile \
Edric Milaret's avatar
Edric Milaret committed
711
                 src/media/video/winvideo/Makefile \
712
                 src/security/Makefile \
Stepan Salenikovich's avatar
Stepan Salenikovich committed
713
                 src/upnp/Makefile \
714
                 ringtones/Makefile \
Guillaume Roguez's avatar
Guillaume Roguez committed
715
                 test/Makefile\
716 717
                 test/sip/Makefile
                 test/turn/Makefile \
718 719
                 test/unitTest/Makefile \

720 721 722
                 man/Makefile \
                 doc/Makefile \
                 doc/doxygen/Makefile])
723

724
# Go!
Rafaël Carré's avatar
Rafaël Carré committed
725
AC_OUTPUT