Add support for ICE/STUN/TURN in res_rtp_asterisk and chan_sip.
[asterisk/asterisk.git] / res / pjproject / aconfigure.ac
1 AC_INIT(pjproject,2.x)
2
3 host_orig="$host"
4
5 AC_CANONICAL_BUILD
6 AC_CANONICAL_HOST
7 AC_CANONICAL_TARGET
8 AC_CONFIG_HEADER([pjlib/include/pj/compat/os_auto.h
9                   pjlib/include/pj/compat/m_auto.h
10                   pjmedia/include/pjmedia/config_auto.h
11                   pjmedia/include/pjmedia-codec/config_auto.h
12                   pjsip/include/pjsip/sip_autoconf.h
13                  ])
14 AC_CONFIG_FILES([build.mak 
15                  build/os-auto.mak 
16                  build/cc-auto.mak
17                  pjlib/build/os-auto.mak 
18                  pjlib-util/build/os-auto.mak 
19                  pjmedia/build/os-auto.mak
20                  pjsip/build/os-auto.mak
21                  third_party/build/os-auto.mak
22                  third_party/build/portaudio/os-auto.mak 
23                  ])
24
25
26 dnl
27 dnl Setup default CFLAGS
28 dnl
29 if test "$CFLAGS" = ""; then
30   CFLAGS="-O2"
31 else
32   CFLAGS="$CFLAGS"
33 fi
34
35 CXXFLAGS="$CFLAGS $CXXFLAGS"
36
37 dnl #
38 dnl # Configure tools
39 dnl #
40 AC_PROG_CC
41 AC_PROG_CXX
42 AC_LANG_C
43
44 dnl #
45 dnl # Setup CROSS_COMPILE variable
46 dnl #
47 if test -z "$CROSS_COMPILE"; then 
48     CROSS_COMPILE=`echo ${CC} | sed 's/gcc//'`
49 fi
50
51 if test "$AR" = ""; then AR="${CROSS_COMPILE}ar rv"; fi
52 AC_SUBST(AR)
53 if test "$LD" = ""; then LD="$CC"; fi
54 AC_SUBST(LD)
55 if test "$LDOUT" = ""; then LDOUT="-o "; fi
56 AC_SUBST(LDOUT)
57 if test "$RANLIB" = ""; then RANLIB="${CROSS_COMPILE}ranlib"; fi
58 AC_SUBST(RANLIB)
59 if test "$OBJEXT" = ""; then OBJEXT='o'; fi
60 AC_SUBST(OBJEXT)
61 if test "$LIBEXT" = ""; then LIBEXT='a'; fi
62 AC_SUBST(LIBEXT)
63 if test "$LIBEXT2" = ""; then LIBEXT2=""; fi
64 AC_SUBST(LIBEXT2)
65 if test "$CC_OUT" = ""; then CC_OUT="-o "; fi
66 AC_SUBST(CC_OUT)
67 if test "$CC_INC" = ""; then CC_INC="-I"; fi
68 AC_SUBST(CC_INC)
69 if test "$CC_DEF" = ""; then CC_DEF="-D"; fi
70 AC_SUBST(CC_DEF)
71 if test "$CC_OPTIMIZE" = ""; then CC_OPTIMIZE="-O2"; fi
72 AC_SUBST(CC_OPTIMIZE)
73 if test "$CC_CFLAGS" = ""; then CC_CFLAGS="-Wall"; fi
74 AC_SUBST(CC_CFLAGS)
75
76
77
78 AC_SUBST(ac_pjdir)
79 AC_SUBST(ac_build_mak_vars)
80
81 case $host in 
82     *mingw* | *cygw* | *win32* | *w32* )
83         if pwd -W 2&> /dev/null; then
84            ac_pjdir=`pwd -W`
85         else
86            # We're probably cross-compiling mingw on Linux
87            ac_pjdir=`pwd`
88         fi
89         ;;
90     *)
91         ac_pjdir=`pwd`
92         ;;
93 esac
94
95 AC_SUBST(ac_shlib_suffix)
96 case $target in
97     *mingw* | *cygw* | *win32* | *w32* )
98         ac_shlib_suffix=dll
99         ;;
100     *darwin*)
101         ac_shlib_suffix=dylib
102         ;;
103     *)
104         ac_shlib_suffix=so
105         ;;
106 esac
107
108 AC_CHECK_LIB(pthread,pthread_create)
109 AC_CHECK_LIB(wsock32,puts)
110 AC_CHECK_LIB(ws2_32,puts)
111 AC_CHECK_LIB(ole32,puts)
112 AC_CHECK_LIB(winmm,puts)
113 AC_CHECK_LIB(socket,puts)
114 AC_CHECK_LIB(rt,puts)
115 AC_CHECK_LIB(nsl,puts)
116 AC_CHECK_LIB(uuid,uuid_generate)
117 AC_CHECK_LIB(uuid,uuid_generate,[ac_has_uuid_lib=1])
118
119 AC_MSG_RESULT([Setting PJ_M_NAME to $target_cpu])
120 AC_DEFINE_UNQUOTED(PJ_M_NAME,["$target_cpu"])
121
122 dnl
123 dnl Memory alignment detection
124 dnl
125 AC_MSG_CHECKING([memory alignment])
126 case $target in
127     sparc64-* | ia64-* | x86_64-* )
128         AC_DEFINE(PJ_POOL_ALIGNMENT, 8)
129         AC_MSG_RESULT([8 bytes])
130         ;;
131     * )
132         AC_DEFINE(PJ_POOL_ALIGNMENT, 4)
133         AC_MSG_RESULT([4 bytes (default)])
134         ;;
135 esac
136
137
138 dnl
139 dnl Endianness detection
140 dnl
141 AC_C_BIGENDIAN
142
143 if test "x$ac_cv_c_bigendian" = "xyes"; then
144   CFLAGS="$CFLAGS -DPJ_IS_BIG_ENDIAN=1 -DPJ_IS_LITTLE_ENDIAN=0"
145 else
146   CFLAGS="$CFLAGS -DPJ_IS_BIG_ENDIAN=0 -DPJ_IS_LITTLE_ENDIAN=1"
147 fi
148
149 dnl
150 dnl Legacy macros
151 dnl
152 case $target in
153     *mingw* | *cygw* | *win32* | *w32* )
154         AC_DEFINE(PJ_WIN32,1)
155         AC_DEFINE(PJ_WIN32_WINNT,0x0400)
156         AC_DEFINE(WIN32_LEAN_AND_MEAN)
157         ;;
158     *darwin*)
159         AC_DEFINE(PJ_DARWINOS,1)
160         ;;
161     *linux*)
162         AC_DEFINE(PJ_LINUX,1)
163         ;;
164     *rtems*)
165         AC_DEFINE(PJ_RTEMS,1)
166         ;;
167     *sunos* | *solaris* )
168         AC_DEFINE(PJ_SUNOS,1)
169         ;;
170     *)
171         ;;
172 esac
173
174
175
176
177 dnl # --disable-floating-point option
178 AC_ARG_ENABLE(floating-point,
179               AC_HELP_STRING([--disable-floating-point],
180                              [Disable floating point where possible]),
181               [if test "$enable_floating_point" = "no"; then
182                 AC_DEFINE(PJ_HAS_FLOATING_POINT,0)
183                 AC_MSG_RESULT([Checking if floating point is disabled... yes])
184                fi],
185               [
186                 AC_DEFINE(PJ_HAS_FLOATING_POINT,1)
187                 AC_MSG_RESULT([Checking if floating point is disabled... no]) 
188                 AC_CHECK_LIB(m,fmod)
189               ])
190
191
192 AC_CHECK_HEADER(arpa/inet.h,[AC_DEFINE(PJ_HAS_ARPA_INET_H,1)])
193 AC_CHECK_HEADER(assert.h,[AC_DEFINE(PJ_HAS_ASSERT_H,1)])
194 AC_CHECK_HEADER(ctype.h,[AC_DEFINE(PJ_HAS_CTYPE_H,1)])
195
196 case $target in
197     *mingw* | *cygw* | *win32* | *w32* )
198         AC_DEFINE(PJ_HAS_ERRNO_H,0)
199         ;;
200     *)
201         AC_CHECK_HEADER(errno.h,[AC_DEFINE(PJ_HAS_ERRNO_H,1)])
202         ;;
203 esac
204
205 AC_CHECK_HEADER(fcntl.h,[AC_DEFINE(PJ_HAS_FCNTL_H,1)])
206 AC_CHECK_HEADER(linux/socket.h,[AC_DEFINE(PJ_HAS_LINUX_SOCKET_H,1)])
207 AC_CHECK_HEADER(limits.h,[AC_DEFINE(PJ_HAS_LIMITS_H,1)])
208 AC_CHECK_HEADER(malloc.h,[AC_DEFINE(PJ_HAS_MALLOC_H,1)])
209 AC_CHECK_HEADER(netdb.h,[AC_DEFINE(PJ_HAS_NETDB_H,1)])
210 AC_CHECK_HEADER(netinet/in_systm.h,[AC_DEFINE(PJ_HAS_NETINET_IN_SYSTM_H,1)])
211 AC_CHECK_HEADER(netinet/in.h,[AC_DEFINE(PJ_HAS_NETINET_IN_H,1)])
212 AC_CHECK_HEADER(netinet/ip.h,[AC_DEFINE(PJ_HAS_NETINET_IP_H,1)],[],
213                  [#if PJ_HAS_SYS_TYPES_H
214                   #     include <sys/types.h>
215                   #endif
216                   #if PJ_HAS_NETINET_IN_SYSTM_H
217                   #     include <netinet/in_systm.h>
218                   #endif
219                   #if PJ_HAS_NETINET_IN_H
220                   #     include <netinet/in.h>
221                   #endif
222                  ])
223 AC_CHECK_HEADER(netinet/tcp.h,[AC_DEFINE(PJ_HAS_NETINET_TCP_H,1)])
224 AC_CHECK_HEADER(ifaddrs.h,
225                 [AC_CHECK_FUNC(getifaddrs,[AC_DEFINE(PJ_HAS_IFADDRS_H,1)])])
226 AC_CHECK_HEADER(semaphore.h,[AC_DEFINE(PJ_HAS_SEMAPHORE_H,1)])
227 AC_CHECK_HEADER(setjmp.h,[AC_DEFINE(PJ_HAS_SETJMP_H,1)])
228 AC_CHECK_HEADER(stdarg.h,[AC_DEFINE(PJ_HAS_STDARG_H,1)])
229 AC_CHECK_HEADER(stddef.h,[AC_DEFINE(PJ_HAS_STDDEF_H,1)])
230 AC_CHECK_HEADER(stdio.h,[AC_DEFINE(PJ_HAS_STDIO_H,1)])
231 AC_CHECK_HEADER(stdint.h,[AC_DEFINE(PJ_HAS_STDINT_H,1)])
232 AC_CHECK_HEADER(stdlib.h,[AC_DEFINE(PJ_HAS_STDLIB_H,1)])
233 AC_CHECK_HEADER(string.h,[AC_DEFINE(PJ_HAS_STRING_H,1)])
234 AC_CHECK_HEADER(sys/ioctl.h,[AC_DEFINE(PJ_HAS_SYS_IOCTL_H,1)])
235 AC_CHECK_HEADER(sys/select.h,[AC_DEFINE(PJ_HAS_SYS_SELECT_H,1)])
236 AC_CHECK_HEADER(sys/socket.h,[AC_DEFINE(PJ_HAS_SYS_SOCKET_H,1)])
237 AC_CHECK_HEADER(sys/time.h,[AC_DEFINE(PJ_HAS_SYS_TIME_H,1)])
238 AC_CHECK_HEADER(sys/timeb.h,[AC_DEFINE(PJ_HAS_SYS_TIMEB_H,1)])
239 AC_CHECK_HEADER(sys/types.h,[AC_DEFINE(PJ_HAS_SYS_TYPES_H,1)])
240 AC_CHECK_HEADER(sys/filio.h,[AC_DEFINE(PJ_HAS_SYS_FILIO_H,1)])
241 AC_CHECK_HEADER(sys/sockio.h,[AC_DEFINE(PJ_HAS_SYS_SOCKIO_H,1)])
242 AC_CHECK_HEADER(sys/utsname.h,[AC_DEFINE(PJ_HAS_SYS_UTSNAME_H,1)])
243 AC_CHECK_HEADER(time.h,[AC_DEFINE(PJ_HAS_TIME_H,1)])
244 AC_CHECK_HEADER(unistd.h,[AC_DEFINE(PJ_HAS_UNISTD_H,1)])
245 AC_CHECK_HEADER(winsock.h,[AC_DEFINE(PJ_HAS_WINSOCK_H,1)])
246 AC_CHECK_HEADER(winsock2.h,[AC_DEFINE(PJ_HAS_WINSOCK2_H,1)])
247 AC_CHECK_HEADER(mswsock.h,[AC_DEFINE(PJ_HAS_MSWSOCK_H,1)],[],
248                  [#if PJ_HAS_WINSOCK2_H
249                   #     include <winsock2.h>
250                   #elif PJ_HAS_WINSOCK_H
251                   #     include <winsock.h>
252                   #endif
253                  ])
254 AC_CHECK_HEADER(ws2tcpip.h,[AC_DEFINE(PJ_HAS_WS2TCPIP_H,1)])
255 AC_CHECK_HEADER(uuid/uuid.h,[ac_has_uuid_h=1])
256 AC_CHECK_HEADER(net/if.h,[AC_DEFINE(PJ_HAS_NET_IF_H,1)],[],
257                  [#if PJ_HAS_SYS_TYPES_H
258                   #     include <sys/types.h>
259                   #endif
260                   #if PJ_HAS_SYS_SOCKET_H
261
262                   #     include <sys/socket.h>
263                   #endif
264                  ])
265 AC_MSG_RESULT([Setting PJ_OS_NAME to $target])
266 AC_DEFINE_UNQUOTED(PJ_OS_NAME,["$target"])
267
268 AC_MSG_RESULT([Setting PJ_HAS_ERRNO_VAR to 1])
269 AC_DEFINE(PJ_HAS_ERRNO_VAR,1)
270
271 AC_MSG_RESULT([Setting PJ_HAS_HIGH_RES_TIMER to 1])
272 AC_DEFINE(PJ_HAS_HIGH_RES_TIMER,1)
273
274 AC_MSG_RESULT([Setting PJ_HAS_MALLOC to 1])
275 AC_DEFINE(PJ_HAS_MALLOC,1)
276
277 AC_MSG_RESULT([Setting PJ_NATIVE_STRING_IS_UNICODE to 0])
278 AC_DEFINE(PJ_NATIVE_STRING_IS_UNICODE,0)
279
280 AC_MSG_RESULT([Setting PJ_ATOMIC_VALUE_TYPE to long])
281 AC_DEFINE(PJ_ATOMIC_VALUE_TYPE,long)
282
283 dnl # Determine if inet_aton() is available
284 AC_MSG_CHECKING([if inet_aton() is available])
285 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
286                                      #include <sys/socket.h>
287                                      #include <arpa/inet.h>]],
288                                   [inet_aton(0, 0);])],
289                   [AC_DEFINE(PJ_SOCK_HAS_INET_ATON,1)
290                    AC_MSG_RESULT(yes)],
291                   [AC_MSG_RESULT(no)])
292
293 dnl # Determine if inet_pton() is available
294 AC_MSG_CHECKING([if inet_pton() is available])
295 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
296                                      #include <sys/socket.h>
297                                      #include <arpa/inet.h>]],
298                                   [inet_pton(0, 0, 0);])],
299                   [AC_DEFINE(PJ_SOCK_HAS_INET_PTON,1)
300                    AC_MSG_RESULT(yes)],
301                   [AC_MSG_RESULT(no)])
302
303 dnl # Determine if inet_ntop() is available
304 AC_MSG_CHECKING([if inet_ntop() is available])
305 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
306                                      #include <sys/socket.h>
307                                      #include <arpa/inet.h>]],
308                                   [inet_ntop(0, 0, 0, 0);])],
309                   [AC_DEFINE(PJ_SOCK_HAS_INET_NTOP,1)
310                    AC_MSG_RESULT(yes)],
311                   [AC_MSG_RESULT(no)])
312
313 dnl # Determine if getaddrinfo() is available
314 AC_MSG_CHECKING([if getaddrinfo() is available])
315 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
316                                      #include <sys/socket.h>
317                                      #include <netdb.h>]],
318                                   [getaddrinfo(0, 0, 0, 0);])],
319                   [AC_DEFINE(PJ_SOCK_HAS_GETADDRINFO,1)
320                    AC_MSG_RESULT(yes)],
321                   [AC_MSG_RESULT(no)])
322
323 dnl # Determine if sockaddr_in has sin_len member
324 AC_MSG_CHECKING([if sockaddr_in has sin_len member])
325 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
326                                      #include <sys/socket.h>
327                                      #include <netinet/in.h>
328                                      #include <arpa/inet.h>]],
329                                   [struct sockaddr_in a; a.sin_len=0;])],
330                   [AC_DEFINE(PJ_SOCKADDR_HAS_LEN,1)
331                    AC_MSG_RESULT(yes)],
332                   AC_MSG_RESULT(no))
333
334 dnl # Determine if socklen_t is available
335 AC_MSG_CHECKING([if socklen_t is available])
336 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
337                                      #include <sys/socket.h>]],
338                                    [socklen_t xxx = 0;])],
339                   [AC_DEFINE(PJ_HAS_SOCKLEN_T,1)
340                    AC_MSG_RESULT(yes)],
341                   AC_MSG_RESULT(no))
342
343 dnl # Determine if SO_ERROR is available
344 AC_MSG_CHECKING([if SO_ERROR is available])
345 case $target in
346     *mingw* | *cygw* | *win32* | *w32* )
347         AC_DEFINE(PJ_HAS_SO_ERROR,1)
348         AC_MSG_RESULT(yes)
349         ;;
350     *)
351         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
352                                              #include <sys/socket.h>
353                                              #include <netinet/in.h>
354                                              #include <arpa/inet.h>]],
355                                           [int i=SO_ERROR;])],
356                           [AC_DEFINE(PJ_HAS_SO_ERROR,1)
357                            AC_MSG_RESULT(yes)],
358                           AC_MSG_RESULT(no))
359         ;;
360 esac
361
362
363 dnl # Determine if RW-mutex is available
364 AC_MSG_CHECKING([if pthread_rwlock_t is available])
365 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>],
366                                    [pthread_rwlock_t *x;])],
367                   [AC_DEFINE(PJ_EMULATE_RWMUTEX,0)
368                    ac_rwmutex="yes"
369                    AC_MSG_RESULT(yes)],
370                   [AC_DEFINE(PJ_EMULATE_RWMUTEX,1)
371                    ac_rwmutex="no"
372                    AC_MSG_RESULT(no)])
373
374 dnl # If rwmutex is not detected, check again but this time
375 dnl # with _POSIX_READER_WRITER_LOCKS defined (newlib needs this)
376 if test "$ac_rwmutex" = "no"; then
377     AC_MSG_CHECKING([if pthread_rwlock_t is available with _POSIX_READER_WRITER_LOCKS])
378     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#define _POSIX_READER_WRITER_LOCKS
379                                          #include <pthread.h>]],
380                                        [pthread_rwlock_t *x;])],
381                       [AC_DEFINE(PJ_EMULATE_RWMUTEX,0)
382                        CFLAGS="$CFLAGS -D_POSIX_THREADS -D_POSIX_READER_WRITER_LOCKS"
383                        AC_MSG_RESULT(yes)],
384                       [AC_DEFINE(PJ_EMULATE_RWMUTEX,1)
385                        AC_MSG_RESULT(no)])
386 fi
387
388 dnl # Do we have pthread_mutexattr_settype()?
389 AC_MSG_CHECKING([if pthread_mutexattr_settype() is available])
390 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>],
391                                    [pthread_mutexattr_settype(0,PTHREAD_MUTEX_FAST_NP);])],
392                   [AC_DEFINE(PJ_HAS_PTHREAD_MUTEXATTR_SETTYPE,1)
393                    AC_MSG_RESULT(yes)],
394                   [AC_MSG_RESULT(no)])
395
396 dnl # Does pthread_mutexattr_t has "recursive" member?
397 AC_MSG_CHECKING([if pthread_mutexattr_t has recursive member])
398 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>],
399                                    [[pthread_mutexattr_t attr;
400                                      attr.recursive=1;]])],
401                   [AC_DEFINE(PJ_PTHREAD_MUTEXATTR_T_HAS_RECURSIVE,1)
402                    AC_MSG_RESULT(yes)],
403                   [AC_MSG_RESULT(no)])
404
405 dnl ######################
406 dnl # ioqueue selection
407 dnl # 
408 AC_SUBST(ac_os_objs)
409 AC_MSG_CHECKING([ioqueue backend])
410 AC_ARG_ENABLE(epoll,
411               AC_HELP_STRING([--enable-epoll],
412                              [Use /dev/epoll ioqueue on Linux (experimental)]),
413               [
414                 ac_os_objs=ioqueue_epoll.o
415                 AC_MSG_RESULT([/dev/epoll])
416               ],
417               [
418                 ac_os_objs=ioqueue_select.o
419                 AC_MSG_RESULT([select()]) 
420               ])
421
422
423 dnl ######################
424 dnl # OS specific files
425 dnl #
426 case $target in
427   *mingw* | *cygw* | *win32* | *w32* )
428         ac_os_objs="$ac_os_objs file_access_win32.o file_io_win32.o os_core_win32.o os_error_win32.o os_time_win32.o os_timestamp_win32.o guid_win32.o"
429         ;;
430   *)
431         ac_os_objs="$ac_os_objs file_access_unistd.o file_io_ansi.o os_core_unix.o os_error_unix.o os_time_unix.o os_timestamp_posix.o"
432         case $target in
433           arm-apple-darwin*)
434                 ac_os_objs="$ac_os_objs os_info_iphone.o"
435                 ;;
436         esac
437         # UUID
438         if test "$ac_has_uuid_lib" = "1" -a "$ac_has_uuid_h" = "1"; then
439                 ac_os_objs="$ac_os_objs guid_uuid.o"
440         else
441                 ac_os_objs="$ac_os_objs guid_simple.o"
442         fi
443         ;;
444 esac
445
446 case $target in
447   *darwin*)
448         ac_os_objs="$ac_os_objs os_core_darwin.o"
449         ;;
450 esac
451
452 dnl ##########################################
453 dnl #
454 dnl # PJMEDIA
455 dnl #
456
457 dnl # Use external Speex installation
458 AC_SUBST(ac_external_speex,0)
459 AC_ARG_WITH(external-speex,
460     AC_HELP_STRING([--with-external-speex],
461                    [Use external Speex development files, not the one in "third_party" directory. When this option is set, make sure that Speex is accessible to use (hint: use CFLAGS and LDFLAGS env var to set the include/lib paths)]),
462     [
463         if test "x$with_external_speex" != "xno"; then
464                 # Test Speex installation
465                 AC_MSG_CHECKING([if external Speex devkit is installed])
466                 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <speex/speex.h>
467                                                      #include <speex/speex_echo.h>
468                                                      ]],
469                                                   [speex_echo_state_init(0, 0); speex_encoder_init(0); ])],
470                                   [AC_MSG_RESULT(yes!!)
471                                    AC_DEFINE(PJMEDIA_EXTERNAL_SPEEX_CODEC, 1)
472                                    ac_external_speex="1"
473                                    ],
474                                   [AC_MSG_ERROR([Unable to use external Speex library. If Speex development files are not available in the default locations, use CFLAGS and LDFLAGS env var to set the include/lib paths])])
475         fi
476     ]
477     )
478
479 dnl # Use external GSM codec library installation
480 AC_SUBST(ac_external_gsm,0)
481 AC_ARG_WITH(external-gsm,
482     AC_HELP_STRING([--with-external-gsm],
483                    [Use external GSM codec library, not the one in "third_party" directory. When this option is set, make sure that the GSM include/lib files are accessible to use (hint: use CFLAGS and LDFLAGS env var to set the include/lib paths)]),
484     [
485         if test "x$with_external_gsm" != "xno"; then
486                 # Test GSM library installation
487                 AC_MSG_CHECKING([if external GSM devkit is installed as gsm/gsm.h])
488                 AC_COMPILE_IFELSE(
489                     [AC_LANG_PROGRAM([[#include <gsm/gsm.h> ]], [gsm_create(); ]) ],
490                     [AC_MSG_RESULT(yes!!)
491                      AC_DEFINE(PJMEDIA_EXTERNAL_GSM_CODEC, 1)
492                      AC_DEFINE(PJMEDIA_EXTERNAL_GSM_GSM_H, 1)
493                      ac_external_gsm="1"
494                     ],
495                     [
496                      AC_MSG_RESULT(no)
497                      AC_MSG_CHECKING([if external GSM devkit is installed as gsm.h])
498                      AC_COMPILE_IFELSE(
499                         [AC_LANG_PROGRAM([[#include <gsm.h> ]], [gsm_create(); ]) ],
500                         [AC_MSG_RESULT(yes!!)
501                          AC_DEFINE(PJMEDIA_EXTERNAL_GSM_CODEC, 1)
502                          AC_DEFINE(PJMEDIA_EXTERNAL_GSM_H, 1)
503                          ac_external_gsm="1"
504                         ],
505                         [AC_MSG_ERROR([Unable to use external GSM library. If GSM development files are not available in the default locations, use CFLAGS and LDFLAGS env var to set the include/lib paths])
506                         ]
507                      )
508                     ]
509                 )
510         fi
511     ]
512     )
513
514
515
516 dnl # Sound device backend selection
517 AC_SUBST(ac_pjmedia_snd)
518 AC_ARG_ENABLE(sound,
519               AC_HELP_STRING([--disable-sound],
520                              [Exclude sound (i.e. use null sound)]),
521               [if test "$enable_sound" = "no"; then
522                 [ac_pjmedia_snd=null]
523                 AC_MSG_RESULT([Checking if sound is disabled... yes])
524                fi]
525               )
526
527 dnl # Use external PortAudio installation
528 AC_SUBST(ac_external_pa,0)
529 AC_ARG_WITH(external-pa,
530     AC_HELP_STRING([--with-external-pa],
531                    [Use external PortAudio development files, not the one in "third_party" directory. When this option is set, make sure that PortAudio is accessible to use (hint: use CFLAGS and LDFLAGS env var to set the include/lib paths)]),
532     [
533         if test "x$with_external_pa" != "xno"; then
534                 # Test PortAudio installation
535                 AC_MSG_CHECKING([if external PortAudio devkit is installed])
536                 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <portaudio.h>
537                                                      ]],
538                                                   [Pa_Initialize();])],
539                                   [AC_MSG_RESULT(yes!!)
540                                    ac_external_pa="1"
541                                    ],
542                                   [AC_MSG_ERROR([Unable to use PortAudio. If PortAudio development files are not available in the default locations, use CFLAGS and LDFLAGS env var to set the include/lib paths])])
543         fi
544     ]
545     )
546
547 AC_SUBST(ac_pa_cflags)
548 AC_CHECK_HEADER(sys/soundcard.h,
549                 [ac_pa_cflags="$ac_pa_cflags -DHAVE_SYS_SOUNDCARD_H"])
550 AC_CHECK_HEADER(linux/soundcard.h,
551                 [ac_pa_cflags="$ac_pa_cflags -DHAVE_LINUX_SOUNDCARD_H"])
552 AC_CHECK_HEADER(machine/soundcard.h,
553                 [ac_pa_cflags="$ac_pa_cflags -DHAVE_MACHINE_SOUNDCARD_H"])
554
555 if test "x$ac_cv_c_bigendian" = "xyes"; then
556   ac_pa_cflags="$ac_pa_cflags -DPA_BIG_ENDIAN"
557 else
558   ac_pa_cflags="$ac_pa_cflags -DPA_LITTLE_ENDIAN"
559 fi
560
561 if test "$enable_sound" = "no"; then
562   true;
563 else
564  case $target in
565   arm-apple-darwin*)
566         LIBS="$LIBS -framework CoreAudio -framework CoreFoundation -framework AudioToolbox -framework CFNetwork -framework UIKit"
567         AC_MSG_RESULT([Checking sound device backend... AudioUnit])
568         ;;
569   *darwin*)
570         LIBS="$LIBS -framework CoreAudio -framework CoreServices -framework AudioUnit -framework AudioToolbox"
571         if test "`uname -r`" = "6.8"; then
572                 #ac_pa_cflags="$ac_pa_cflags -DPA_OLD_CORE_AUDIO -DMOSX_USE_NON_ATOMIC_FLAG_BITS"
573                 #AC_MSG_RESULT([Setting additional PortAudio CFLAGS.. -DPA_OLD_CORE_AUDIO -DMOSX_USE_NON_ATOMIC_FLAG_BITS])
574                 ac_pjmedia_snd=pa_old_darwinos
575                 AC_MSG_RESULT([Checking sound device backend... old coreaudio])
576         else
577                 ac_pjmedia_snd=pa_darwinos
578                 AC_MSG_RESULT([Checking sound device backend... coreaudio])
579         fi
580         ;;
581   *cygwin* | *mingw*)
582         ac_pjmedia_snd=pa_win32
583         AC_MSG_RESULT([Checking sound device backend... win32 sound])
584         ;;
585   *rtems*)
586         ac_pjmedia_snd=null
587         AC_MSG_RESULT([Checking sound device backend... null sound])
588         ;;
589   *)
590         dnl # Check if ALSA is available
591         ac_pjmedia_snd=pa_unix
592         AC_CHECK_HEADER(alsa/version.h,
593                         [AC_SUBST(ac_pa_use_alsa,1)
594                          LIBS="$LIBS -lasound"
595                         ],
596                         [AC_SUBST(ac_pa_use_alsa,0)])
597         AC_MSG_RESULT([Checking sound device backend... unix])
598
599         dnl # Check if OSS is disabled
600         AC_SUBST(ac_pa_use_oss,1)
601         AC_ARG_ENABLE(oss,
602                       AC_HELP_STRING([--disable-oss],
603                                      [Disable OSS audio (default: not disabled)]),
604                       [
605                         if test "$enable_oss" = "no"; then
606                          [ac_pa_use_oss=0]
607                          AC_MSG_RESULT([Checking if OSS audio is disabled... yes])
608                         fi
609                       ])
610         ;;
611  esac
612 fi
613
614 AC_SUBST(ac_pjmedia_video)
615
616 dnl # --disable-video option
617 AC_ARG_ENABLE(video,
618               AC_HELP_STRING([--disable-video],
619                              [Disable video feature]),
620               [if test "$enable_video" = "no"; then
621                 #AC_DEFINE(PJMEDIA_HAS_VIDEO,0)
622                 AC_MSG_RESULT([Video is disabled]) 
623                 enable_sdl="no"
624                 enable_ffmpeg="no"
625                 enable_v4l2="no"
626                fi],
627               [])
628
629 case $target in
630  arm-apple-darwin*)
631         LIBS="$LIBS -framework UIKit"
632         ;;
633  *darwin*)
634         LIBS="$LIBS -framework Foundation -framework AppKit"
635         ;;
636 esac
637
638 if test "$enable_video" = "no"; then
639   true;
640 else
641  case $target in
642   arm-apple-darwin*)
643         ac_pjmedia_video=iphone_os
644         AC_SUBST(ac_pjmedia_video_has_ios)
645         AC_SUBST(ac_ios_cflags)
646         SAVED_LIBS="$LIBS"
647         LIBS="-framework AVFoundation -framework CoreGraphics -framework QuartzCore -framework CoreVideo -framework CoreMedia"
648         AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [])],[ac_pjmedia_video_has_ios=yes],[ac_pjmedia_video_has_ios=no])
649         LIBS="$SAVED_LIBS"
650         if test "$ac_pjmedia_video_has_ios" = "yes"; then
651           ac_ios_cflags="-DPJMEDIA_VIDEO_DEV_HAS_IOS=1"
652           LIBS="$LIBS -framework AVFoundation -framework CoreGraphics -framework QuartzCore -framework CoreVideo -framework CoreMedia"
653           AC_MSG_RESULT([Checking if AVFoundation framework is available... yes])
654         else
655           AC_MSG_RESULT([Checking if AVFoundation framework is available... no])
656         fi
657         ;;
658   *darwin*)
659         ac_pjmedia_video=mac_os
660         AC_SUBST(ac_pjmedia_video_has_qt)
661         AC_SUBST(ac_qt_cflags)
662         SAVED_LIBS="$LIBS"
663         LIBS="-framework QTKit"
664         AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [])],[ac_pjmedia_video_has_qt=yes],[ac_pjmedia_video_has_qt=no])
665         LIBS="$SAVED_LIBS"
666         if test "$ac_pjmedia_video_has_qt" = "yes"; then
667           ac_qt_cflags="-DPJMEDIA_VIDEO_DEV_HAS_QT=1"
668           LIBS="$LIBS -framework QTKit -framework QuartzCore -framework OpenGL"
669           AC_MSG_RESULT([Checking if QTKit framework is available... yes])
670         else
671           AC_MSG_RESULT([Checking if QTKit framework is available... no])
672         fi
673         ;;
674  esac
675 fi
676
677 AC_ARG_ENABLE(ext_sound,
678               AC_HELP_STRING([--enable-ext-sound],
679                              [PJMEDIA will not provide any sound device backend]),
680               [if test "$enable_ext_sound" = "yes"; then
681                 [ac_pjmedia_snd=external]
682                 AC_MSG_RESULT([Checking if external sound is set... yes])
683                fi]
684               )
685
686 dnl # Include resampling small filter
687 AC_SUBST(ac_no_small_filter)
688 AC_ARG_ENABLE(small-filter,
689               AC_HELP_STRING([--disable-small-filter],
690                              [Exclude small filter in resampling]),
691               [if test "$enable_small_filter" = "no"; then
692                 [ac_no_small_filter='-DPJMEDIA_HAS_SMALL_FILTER=0']
693                 AC_MSG_RESULT([Checking if small filter is disabled... yes])
694                fi],
695               AC_MSG_RESULT([Checking if small filter is disabled... no]))
696
697 dnl # Include resampling large filter
698 AC_SUBST(ac_no_large_filter)
699 AC_ARG_ENABLE(large-filter,
700               AC_HELP_STRING([--disable-large-filter],
701                              [Exclude large filter in resampling]),
702               [if test "$enable_large_filter" = "no"; then
703                 [ac_no_large_filter='-DPJMEDIA_HAS_LARGE_FILTER=0']
704                 AC_MSG_RESULT([Checking if large filter is disabled... yes])
705                fi],
706               AC_MSG_RESULT([Checking if large filter is disabled... no]))
707
708 dnl # Include Speex AEC
709 AC_SUBST(ac_no_speex_aec)
710 AC_ARG_ENABLE(speex-aec,
711               AC_HELP_STRING([--disable-speex-aec],
712                              [Exclude Speex Acoustic Echo Canceller/AEC]),
713               [if test "$enable_speex_aec" = "no"; then
714                 [ac_no_speex_aec='-DPJMEDIA_HAS_SPEEX_AEC=0']
715                 AC_MSG_RESULT([Checking if Speex AEC is disabled...yes])
716                fi],
717               AC_MSG_RESULT([Checking if Speex AEC is disabled...no]))
718
719 dnl # Include G711 codec
720 AC_SUBST(ac_no_g711_codec)
721 AC_ARG_ENABLE(g711-codec,
722               AC_HELP_STRING([--disable-g711-codec],
723                              [Exclude G.711 codecs from the build]),
724               [if test "$enable_g711_codec" = "no"; then
725                 [ac_no_g711_codec=1]
726                 AC_DEFINE(PJMEDIA_HAS_G711_CODEC,0)
727                 AC_MSG_RESULT([Checking if G.711 codec is disabled...yes])
728                fi],
729               AC_MSG_RESULT([Checking if G.711 codec is disabled...no]))
730
731
732 dnl # Include L16 codec
733 AC_SUBST(ac_no_l16_codec)
734 AC_ARG_ENABLE(l16-codec,
735               AC_HELP_STRING([--disable-l16-codec],
736                              [Exclude Linear/L16 codec family from the build]),
737               [if test "$enable_l16_codec" = "no"; then
738                 [ac_no_l16_codec=1]
739                 AC_DEFINE(PJMEDIA_HAS_L16_CODEC,0)
740                 AC_MSG_RESULT([Checking if L16 codecs are disabled...yes])
741                fi],
742               AC_MSG_RESULT([Checking if L16 codec is disabled...no]))
743
744
745 dnl # Include GSM codec
746 AC_SUBST(ac_no_gsm_codec)
747 AC_ARG_ENABLE(gsm-codec,
748               AC_HELP_STRING([--disable-gsm-codec],
749                              [Exclude GSM codec in the build]),
750               [if test "$enable_gsm_codec" = "no"; then
751                 [ac_no_gsm_codec=1]
752                 AC_DEFINE(PJMEDIA_HAS_GSM_CODEC,0)
753                 AC_MSG_RESULT([Checking if GSM codec is disabled...yes])
754                fi],
755               AC_MSG_RESULT([Checking if GSM codec is disabled...no]))
756
757 dnl # Include G.722 codec
758 AC_SUBST(ac_no_g722_codec)
759 AC_ARG_ENABLE(g722-codec,
760               AC_HELP_STRING([--disable-g722-codec],
761                              [Exclude G.722 codec in the build]),
762               [if test "$enable_g722_codec" = "no"; then
763                 [ac_no_g722_codec=1]
764                 AC_DEFINE(PJMEDIA_HAS_G722_CODEC,0)
765                 AC_MSG_RESULT([Checking if G.722 codec is disabled...yes])
766                fi],
767               AC_MSG_RESULT([Checking if G.722 codec is disabled...no]))
768
769 dnl # Include G722.1 codec
770 AC_SUBST(ac_no_g7221_codec)
771 AC_ARG_ENABLE(g7221-codec,
772               AC_HELP_STRING([--disable-g7221-codec],
773                              [Exclude G.7221 codec in the build]),
774               [if test "$enable_g7221_codec" = "no"; then
775                 [ac_no_g7221_codec=1]
776                 AC_DEFINE(PJMEDIA_HAS_G7221_CODEC,0)
777                 AC_MSG_RESULT([Checking if G.722.1 codec is disabled...yes])
778                fi],
779               AC_MSG_RESULT([Checking if G.722.1 codec is disabled...no]))
780
781 dnl # Include Speex codec
782 AC_SUBST(ac_no_speex_codec)
783 AC_ARG_ENABLE(speex-codec,
784               AC_HELP_STRING([--disable-speex-codec],
785                              [Exclude Speex codecs in the build]),
786               [if test "$enable_speex_codec" = "no"; then
787                 [ac_no_speex_codec=1]
788                 AC_DEFINE(PJMEDIA_HAS_SPEEX_CODEC,0)
789                 AC_MSG_RESULT([Checking if Speex codec is disabled...yes])
790                fi],
791               AC_MSG_RESULT([Checking if Speex codec is disabled...no]))
792
793 dnl # Include iLBC codec
794 AC_SUBST(ac_no_ilbc_codec)
795 AC_ARG_ENABLE(ilbc-codec,
796               AC_HELP_STRING([--disable-ilbc-codec],
797                              [Exclude iLBC codec in the build]),
798               [if test "$enable_ilbc_codec" = "no"; then
799                 [ac_no_ilbc_codec=1]
800                 AC_DEFINE(PJMEDIA_HAS_ILBC_CODEC,0)
801                 AC_MSG_RESULT([Checking if iLBC codec is disabled...yes])
802                fi],
803               AC_MSG_RESULT([Checking if iLBC codec is disabled...no]))
804
805 dnl # Include libsamplerate
806 AC_ARG_ENABLE(libsamplerate,
807               AC_HELP_STRING([--enable-libsamplerate],
808                              [Link with libsamplerate when available. Note that PJMEDIA_RESAMPLE_IMP must also be configured]),
809               [ AC_CHECK_LIB(samplerate,src_new) ],
810               AC_MSG_RESULT([Skipping libsamplerate detection])
811              )
812
813 dnl # Include libsamplerate
814 AC_SUBST(ac_resample_dll)
815 AC_ARG_ENABLE(resample_dll,
816               AC_HELP_STRING([--enable-resample-dll],
817                              [Build libresample as shared library]),
818               [if test "$enable_resample_dll" = "yes"; then
819                 [ac_resample_dll=1]
820                 AC_MSG_RESULT([Building libresample as shared library... yes])
821                fi],
822               AC_MSG_RESULT([Building libresample as shared library... no])
823               )
824
825 dnl # SDL alt prefix
826 AC_ARG_WITH(sdl,
827     AC_HELP_STRING([--with-sdl=DIR],
828                    [Specify alternate libSDL prefix]),
829     [],
830     [with_sdl=no]
831     )
832
833 dnl # SDL
834 AC_ARG_ENABLE(sdl,
835               AC_HELP_STRING([--disable-sdl],
836                              [Disable SDL (default: not disabled)]),
837               [
838                 if test "$enable_sdl" = "no"; then
839                   AC_MSG_RESULT([Checking if SDL is disabled... yes])
840                 fi
841               ],
842               [
843                   SDL_CONFIG="sdl-config"
844                   if test "x$with_sdl" != "xno" -a "x$with_sdl" != "x"; then
845                         SDL_CONFIG=$with_sdl/bin/sdl-config
846                         AC_MSG_RESULT([Using SDL prefix... $with_sdl])
847                   fi
848               
849                   AC_MSG_CHECKING([SDL availability..])
850                   if (sh -c "$SDL_CONFIG --version" | grep 1.3) then
851                           AC_SUBST(ac_sdl_cflags)
852                           AC_SUBST(ac_sdl_ldflags)
853                           ac_sdl_cflags=`$SDL_CONFIG --cflags`
854                           ac_sdl_cflags="-DPJMEDIA_VIDEO_DEV_HAS_SDL=1 $ac_sdl_cflags"
855                           ac_sdl_ldflags=`$SDL_CONFIG --libs`
856                           LIBS="$LIBS $ac_sdl_ldflags"
857                    else
858                         AC_MSG_RESULT([Unsupported SDL version])
859                    fi
860               ])
861
862
863 dnl # FFMPEG stuffs
864 AC_ARG_ENABLE(ffmpeg,
865               AC_HELP_STRING([--disable-ffmpeg],
866                              [Disable ffmpeg (default: not disabled)]),
867               [
868                 AC_SUBST(ac_has_ffmpeg,0)
869                 if test "$enable_ffmpeg" = "no"; then
870                         AC_MSG_RESULT([Checking if ffmpeg is disabled... yes])
871                 fi
872               ],
873               [
874                 AC_SUBST(ac_ffmpeg_cflags)
875                 AC_SUBST(ac_ffmpeg_ldflags)
876
877                 FFMPEG_PREFIX=""
878                 AC_SUBST(SAVED_PKG_CONFIG_PATH)
879                 SAVED_PKG_CONFIG_PATH=$PKG_CONFIG_PATH
880                 if test "x$with_ffmpeg" != "xno" -a "x$with_ffmpeg" != "x"; then
881                         FFMPEG_PREFIX=$with_ffmpeg
882                         AC_MSG_RESULT([Using ffmpeg prefix... $FFMPEG_PREFIX])
883                         export PKG_CONFIG_PATH=$FFMPEG_PREFIX/lib/pkgconfig
884                 fi
885
886                 AC_CHECK_PROGS(PKG_CONFIG,pkg-config "python pkgconfig.py",none)
887
888                 if test "$PKG_CONFIG" != "none"; then
889                         AC_MSG_CHECKING([ffmpeg packages])
890                         av_pkg=""
891                         if $PKG_CONFIG --exists libdevice; then
892                                 ac_ffmpeg_cflags="$ac_ffmpeg_cflags -DPJMEDIA_HAS_LIBAVDEVICE=1"
893                                 av_pkg="$av_pkg libdevice"
894                         fi
895                         if $PKG_CONFIG --exists libavformat; then
896                                 ac_ffmpeg_cflags="$ac_ffmpeg_cflags -DPJMEDIA_HAS_LIBAVFORMAT=1"
897                                 av_pkg="$av_pkg libavformat"
898                         fi
899                         if $PKG_CONFIG --exists libavcodec; then
900                                 ac_ffmpeg_cflags="$ac_ffmpeg_cflags -DPJMEDIA_HAS_LIBAVCODEC=1"
901                                 av_pkg="$av_pkg libavcodec"
902                         fi
903                         if $PKG_CONFIG --exists libswscale; then
904                                 ac_ffmpeg_cflags="$ac_ffmpeg_cflags -DPJMEDIA_HAS_LIBSWSCALE=1"
905                                 av_pkg="$av_pkg libswscale"
906                         fi
907                         if $PKG_CONFIG --exists libavutil; then
908                                 ac_ffmpeg_cflags="$ac_ffmpeg_cflags -DPJMEDIA_HAS_LIBAVUTIL=1"
909                                 av_pkg="$av_pkg libavutil"
910                         fi
911                         if $PKG_CONFIG --exists libavcore; then
912                                 ac_ffmpeg_cflags="$ac_ffmpeg_cflags -DPJMEDIA_HAS_LIBAVCORE=1"
913                                 av_pkg="$av_pkg libavcore"
914                         fi
915                         
916                         if test "x$av_pkg" == "x"; then
917                            AC_MSG_RESULT([none detected (check the prefix)! **])
918                         else
919                            AC_MSG_RESULT([$av_pkg])
920                         fi
921                         
922                         ac_ffmpeg_cflags="$ac_ffmpeg_cflags `$PKG_CONFIG --cflags $av_pkg`"
923                         ac_ffmpeg_ldflags="$ac_ffmpeg_ldflags `$PKG_CONFIG --libs $av_pkg`"
924
925                 else
926                         dnl #
927                         dnl # Use hardcoded values to configure ffmpeg
928                         dnl #
929                         
930                         AC_MSG_RESULT([*** Warning: neither pkg-config nor python is available, ffmpeg dependency cannot be calculated. If ffmpeg libraries are not detected, you need to specify the correct CFLAGS and LDFLAGS settings for ffmpeg prior to invoking configure ***])
931                         
932                         LIBS="-L$FFMPEG_PREFIX/lib $LIBS"
933                         LDFLAGS="-L$FFMPEG_PREFIX/lib $LDFLAGS"
934                         CFLAGS="-I$FFMPEG_PREFIX/include $CFLAGS"
935                         
936                         AC_CHECK_LIB(avdevice,
937                                      avdevice_version,
938                                      [ac_ffmpeg_cflags="$ac_ffmpeg_cflags -DPJMEDIA_HAS_LIBAVDEVICE=1"
939                                       ac_ffmpeg_ldflags="$ac_ffmpeg_ldflags -lavdevice"
940                                      ]
941                                      )
942                         AC_CHECK_LIB(avutil,
943                                      av_malloc,
944                                      [ac_ffmpeg_cflags="$ac_ffmpeg_cflags -DPJMEDIA_HAS_LIBAVUTIL=1"
945                                       ac_ffmpeg_ldflags="$ac_ffmpeg_ldflags -lavutil"
946                                      ]
947                                      )
948                         AC_CHECK_LIB(avcodec,
949                                      avcodec_init,
950                                      [ac_ffmpeg_cflags="$ac_ffmpeg_cflags -DPJMEDIA_HAS_LIBAVCODEC=1"
951                                       ac_ffmpeg_ldflags="$ac_ffmpeg_ldflags -lavcodec"
952                                      ],
953                                      [],
954                                      [-lavutil]
955                                      )
956                         AC_CHECK_LIB(avformat,
957                                      av_register_all,
958                                      [ac_ffmpeg_cflags="$ac_ffmpeg_cflags -DPJMEDIA_HAS_LIBAVFORMAT=1"
959                                       ac_ffmpeg_ldflags="$ac_ffmpeg_ldflags -lavformat"
960                                      ],
961                                      [],
962                                      [-lavcodec -lavutil]
963                                      )
964                         AC_CHECK_LIB(swscale,
965                                      sws_scale,
966                                      [ac_ffmpeg_cflags="$ac_ffmpeg_cflags -DPJMEDIA_HAS_LIBSWSCALE=1"
967                                       ac_ffmpeg_ldflags="$ac_ffmpeg_ldflags -lswscale"
968                                      ],
969                                      [],
970                                      [-lavutil]
971                                      )
972                         AC_CHECK_LIB(avcore,
973                                      avcore_version,
974                                      [ac_ffmpeg_cflags="$ac_ffmpeg_cflags -DPJMEDIA_HAS_LIBAVCORE=1"
975                                       ac_ffmpeg_ldflags="$ac_ffmpeg_ldflags -lavcore"
976                                      ]
977                                      )
978                         
979                 fi
980                 
981                 LIBS="$LIBS $ac_ffmpeg_ldflags"
982                 export PKG_CONFIG_PATH=$SAVED_PKG_CONFIG_PATH
983               ]
984               )
985
986 AC_ARG_WITH(ffmpeg,
987     AC_HELP_STRING([--with-ffmpeg=DIR],
988                    [Specify alternate FFMPEG prefix]),
989     [],
990     [with_ffmpeg=no]
991     )
992
993
994 dnl # Video for Linux 2
995 AC_ARG_ENABLE(v4l2,
996               AC_HELP_STRING([--disable-v4l2],
997                              [Disable Video4Linux2 (default: not disabled)]),
998               [
999                 if test "$enable_v4l2" = "no"; then
1000                   AC_MSG_RESULT([Checking if V4L2 is disabled... yes])
1001                 fi
1002               ],
1003               [
1004                 AC_SUBST(ac_v4l2_cflags)
1005                 AC_SUBST(ac_v4l2_ldflags)
1006                 AC_CHECK_LIB(v4l2,
1007                              v4l2_open,
1008                              [ac_v4l2_cflags="-DPJMEDIA_VIDEO_DEV_HAS_V4L2=1"
1009                               ac_v4l2_ldflags="-lv4l2"
1010                               LIBS="$LIBS -lv4l2"
1011                              ]
1012                              )
1013               ])
1014
1015 dnl ########################################################
1016 dnl # Intel IPP support
1017 dnl #
1018 AC_ARG_ENABLE(ipp,
1019     AC_HELP_STRING([--enable-ipp],
1020                    [Enable Intel IPP support. Specify the Intel IPP package and samples location using IPPROOT and IPPSAMPLES env var or with --with-ipp and --with-ipp-samples options]),
1021     [],
1022     [enable_ipp=no]
1023     )
1024
1025 AC_ARG_WITH(ipp,
1026     AC_HELP_STRING([--with-ipp=DIR],
1027                    [Specify the Intel IPP location]),
1028     [],
1029     [with_ipp=no]
1030     )
1031
1032 AC_ARG_WITH(ipp-samples,
1033     AC_HELP_STRING([--with-ipp-samples=DIR],
1034                    [Specify the Intel IPP samples location]),
1035     [],
1036     [with_ipp_samples=no]
1037     )
1038
1039 AC_ARG_WITH(ipp-arch,
1040     AC_HELP_STRING([--with-ipp-arch=ARCH],
1041                    [Specify the Intel IPP ARCH suffix, e.g. "64" or "em64t. Default is blank for IA32"]),
1042     [],
1043     [with_ipp_arch=no]
1044     )
1045
1046 if test "x$enable_ipp" != "xno"; then
1047     dnl # 
1048     dnl # Verifying Intel IPP path
1049     dnl #
1050     AC_MSG_CHECKING([Intel IPP location])
1051
1052     if test "x$with_ipp" != "xno" -a "x$with_ipp" != "x"; then
1053         AC_MSG_RESULT([$with_ipp])
1054         IPPROOT=$with_ipp
1055     elif test "x$IPPROOT" = "x"; then
1056         if test -d /opt/intel/ipp; then
1057             IPPROOT=`ls -d /opt/intel/ipp/*/* | head -1`
1058             AC_MSG_RESULT([autodetected in $IPPROOT])
1059         fi
1060     else
1061         AC_MSG_RESULT([$IPPROOT])
1062     fi
1063
1064     if test "x$with_ipp_arch" != "xno"; then
1065         IPP_SUFFIX=$with_ipp_arch
1066         AC_MSG_RESULT([IPP arch suffix is set to $IPP_SUFFIX])
1067     else
1068         IPP_SUFFIX=""
1069         AC_MSG_RESULT([IPP arch suffix is set to empty])
1070     fi
1071
1072     if test x$IPPROOT = x; then
1073         AC_MSG_ERROR([the location is neither specified nor can be guessed. Please specify with IPPROOT env var or with --with-ipp option])
1074     elif test ! -d $IPPROOT; then
1075         AC_MSG_ERROR([not found])
1076     elif test ! -d $IPPROOT/include; then
1077         AC_MSG_ERROR([directory doesn't seem to be valid])
1078     else
1079         # IPP directory looks okay.
1080         # Remove trailing backslash
1081         IPPROOT=`echo $IPPROOT | sed 's/\/$//'`
1082
1083         SAVED_CFLAGS="$CFLAGS"
1084         SAVED_LDFLAGS="$LDFLAGS"
1085         SAVED_LIBS="$LIBS"
1086
1087         IPP_CFLAGS="-I$IPPROOT/include"
1088         IPP_LIBS="-lippsc${IPP_SUFFIX} -lipps${IPP_SUFFIX} -lippcore${IPP_SUFFIX}"
1089
1090 #
1091         # Some differences between Mac OS X and Linux
1092         case $target in 
1093             *darwin* )
1094                 IPP_LDFLAGS="-L$IPPROOT/Libraries -L$IPPROOT/lib"
1095                 ;;
1096             *)
1097                 # Find out where the libraries live.
1098                 IPP7_ARCH=""
1099                 if test -d $IPPROOT/lib/intel64; then
1100                    IPP7_ARCH="intel64"
1101                 elif test -d $IPPROOT/lib/ia32; then
1102                    IPP7_ARCH="ia32"
1103                 elif test -d $IPPROOT/lib/mic; then
1104                    IPP7_ARCH="mic"
1105                 fi
1106
1107                 if test -z "$IPP7_ARCH"; then
1108                    # IPP6 (and possibly below)
1109                    IPP_LDFLAGS="-L$IPPROOT/sharedlib"
1110                    IPP_LIBS="$IPP_LIBS  -lippsr${IPP_SUFFIX} -lguide"
1111                 else
1112                    # IPP7
1113                    if ! test -d $IPPROOT/../compiler; then
1114                         AC_MSG_ERROR([Cannot find $IPPROOT/../compiler directory. Please set IPPROOT variable correctly])
1115                    fi
1116                    IPP_CFLAGS="$IPP_CFLAGS"
1117                    IPP_LDFLAGS="-L$IPPROOT/lib/intel64 -L$IPPROOT/../compiler/lib/$IPP7_ARCH"
1118                    IPP_LIBS="$IPP_LIBS -liomp5"
1119                 fi
1120                 ;;
1121         esac
1122
1123         #IPP_LDFLAGS="-L$IPPROOT/sharedlib"
1124         #Static:
1125         #IPP_LIBS="-lippscmerged -lippsrmerged -lippsmerged -lippcore"
1126
1127         CFLAGS="$CFLAGS $IPP_CFLAGS"
1128         LDFLAGS="$LDFLAGS $IPP_LDFLAGS"
1129         LIBS="$IPP_LIBS $LIBS"
1130
1131
1132         AC_MSG_CHECKING([Intel IPP usability])
1133         AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <ippcore.h>
1134                                            ]],
1135                                            [ippStaticInit();])],
1136                   [AC_MSG_RESULT(ok)],
1137                   [AC_MSG_FAILURE([Error: unable to recognize your IPP installation. Make sure the paths and ARCH suffix are set correctly, run with --help for more info])])
1138
1139         CFLAGS="$SAVED_CFLAGS"
1140         LDFLAGS="$SAVED_LDFLAGS"
1141         LIBS="$SAVED_LIBS"
1142     fi
1143
1144     dnl # 
1145     dnl # Verifying Intel IPP samples path
1146     dnl #
1147     AC_MSG_CHECKING([Intel IPP samples location])
1148
1149     if test "x$with_ipp_samples" != "xno" -a "x$with_ipp_samples" != "x"; then
1150         AC_MSG_RESULT([$with_ipp_samples])
1151         IPPSAMPLES=$with_ipp_samples
1152     elif test "x$IPPSAMPLES" = "x"; then
1153         if test -d /opt/intel/ipp-samples; then
1154             IPPSAMPLES=/opt/intel/ipp-samples
1155             AC_MSG_RESULT([autodetected in $IPPSAMPLES])
1156         fi
1157     else
1158         AC_MSG_RESULT([$IPPSAMPLES])
1159     fi
1160
1161     if test x$IPPSAMPLES = x; then
1162         AC_MSG_ERROR([the location is neither specified nor can be guessed. Please specify with IPPSAMPLES env var or with --with-ipp-samples option])
1163     elif test ! -d $IPPSAMPLES; then
1164         AC_MSG_ERROR([not found])
1165     elif test ! -d $IPPSAMPLES/speech-codecs; then
1166         AC_MSG_ERROR([directory doesn't seem to be valid])
1167     else
1168         # Remove trailing backslash
1169         IPPSAMPLES=`echo $IPPSAMPLES | sed 's/\/$//'`
1170         
1171         # Guess the libusc.a/libspeech.a build location
1172         AC_MSG_CHECKING([Intel IPP USC build location])
1173         if test -d $IPPSAMPLES/speech-codecs/bin; then
1174             IPPVER=5 
1175             IPPSAMP_DIR=`ls -d $IPPSAMPLES/speech-codecs/bin/*gcc*/lib | head -1`
1176         elif test -d $IPPSAMPLES/speech-codecs/_bin; then
1177             IPPVER=6
1178             if test -d $IPPSAMPLES/speech-codecs/_bin/*gcc*; then
1179                 # gcc compiler
1180                 IPPSAMP_DIR=`ls -d $IPPSAMPLES/speech-codecs/_bin/*gcc*/lib | head -1`
1181             elif test -d $IPPSAMPLES/speech-codecs/_bin/*icc*; then
1182                 # icc compiler
1183                 IPPSAMP_DIR=`ls -d $IPPSAMPLES/speech-codecs/_bin/*icc*/lib | head -1`
1184             else
1185                 AC_MSG_FAILURE([Unable to find to find built binaries under $IPPSAMPLES/speech-codecs/{bin,_bin}. Have you built the IPP samples?])
1186             fi
1187         else
1188             AC_MSG_FAILURE([unable to find $IPPSAMPLES/speech-codecs/bin/*gcc*/lib or $IPPSAMPLES/speech-codecs/_bin/*gcc*/lib directory. Have you built the samples?])
1189         fi
1190
1191         # Test the directory
1192         if test ! -d $IPPSAMP_DIR; then
1193             AC_MSG_FAILURE([There's something wrong with this script, directory $IPPSAMP_DIR does not exist])
1194             exit 1;
1195         fi
1196
1197         if test "x$IPPVER" = "x5"; then
1198             IPPSAMP_LIBS="libusc.a"
1199             IPPSAMP_LDLIBS="-lusc"
1200         elif test "x$IPPVER" = "x6"; then
1201             IPPSAMP_LIBS="libspeech.a"
1202             IPPSAMP_LDLIBS="-lspeech"
1203         else
1204             AC_MSG_FAILURE([bug in this script: unsupported IPP version])
1205         fi
1206
1207         if test ! -f $IPPSAMP_DIR/$IPPSAMP_LIBS; then
1208             AC_MSG_FAILURE([$IPPSAMP_LIBS doesn't exist in $IPPSAMP_DIR])
1209         fi
1210
1211         AC_MSG_RESULT([$IPPSAMP_DIR])
1212
1213         SAVED_CFLAGS="$CFLAGS"
1214         SAVED_LDFLAGS="$LDFLAGS"
1215         SAVED_LIBS="$LIBS"
1216
1217         IPPSAMP_INC="-I$IPPSAMPLES/speech-codecs/core/usc/include"
1218         CFLAGS="$CFLAGS $IPPSAMP_INC"
1219         LDFLAGS="$LDFLAGS -L$IPPSAMP_DIR"
1220         LIBS="$IPPSAMP_LDLIBS $LIBS"
1221
1222         AC_MSG_CHECKING([Intel IPP USC usability])
1223         AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <usc.h>
1224                                            ]],
1225                                            [extern USC_Fxns USC_G729AFP_Fxns;])],
1226                   [AC_MSG_RESULT(ok)],
1227                   [AC_MSG_FAILURE(failed)])
1228
1229         CFLAGS="$SAVED_CFLAGS"
1230         LDFLAGS="$IPP_LDFLAGS $SAVED_LDFLAGS"
1231         LIBS="$IPP_LIBS $SAVED_LIBS"
1232
1233         IPP_CFLAGS="$IPP_CFLAGS $IPPSAMP_INC"
1234         IPP_LDFLAGS="$IPP_LDFLAGS -L$IPPSAMP_DIR"
1235         IPP_LIBS="$IPPSAMP_LDLIBS $IPP_LIBS"
1236     fi
1237
1238     CFLAGS="$CFLAGS $IPP_CFLAGS"
1239     LDFLAGS="$LDFLAGS $IPP_LDFLAGS"
1240     LIBS="$LIBS $IPP_LIBS"
1241
1242     ac_build_mak_vars="$ac_build_mak_vars\n\
1243 export IPP_CFLAGS=$IPP_CFLAGS\n\
1244 export IPP_LDFLAGS=$IPP_LDFLAGS\n\
1245 export IPP_LIBS=$IPP_LIBS"
1246 else
1247     AC_MSG_RESULT([Skipping Intel IPP settings (not wanted)])
1248 fi
1249
1250
1251 dnl ##########################################
1252 dnl #
1253 dnl # PJSIP CONFIG
1254 dnl #
1255
1256 dnl # Include SSL support
1257 AC_SUBST(ac_no_ssl)
1258 AC_ARG_ENABLE(ssl,
1259               AC_HELP_STRING([--disable-ssl],
1260                              [Exclude SSL support the build (default: autodetect)])
1261               ,
1262               [
1263                 if test "$enable_ssl" = "no"; then
1264                  [ac_no_ssl=1]
1265                  AC_MSG_RESULT([Checking if SSL support is disabled... yes])
1266                 fi
1267               ],
1268               [
1269                 AC_MSG_RESULT([checking for OpenSSL installations..])
1270                 AC_SUBST(openssl_h_present)
1271                 AC_SUBST(libssl_present)
1272                 AC_SUBST(libcrypto_present)
1273                 AC_CHECK_HEADER(openssl/ssl.h,[openssl_h_present=1])
1274                 AC_CHECK_LIB(crypto,ERR_load_BIO_strings,[libcrypto_present=1 && LIBS="$LIBS -lcrypto"])
1275                 AC_CHECK_LIB(ssl,SSL_library_init,[libssl_present=1 && LIBS="$LIBS -lssl"])
1276                 if test "x$openssl_h_present" = "x1" -a "x$libssl_present" = "x1" -a "x$libcrypto_present" = "x1"; then
1277                         AC_MSG_RESULT([OpenSSL library found, SSL support enabled])
1278                         # PJSIP_HAS_TLS_TRANSPORT setting follows PJ_HAS_SSL_SOCK
1279                         #AC_DEFINE(PJSIP_HAS_TLS_TRANSPORT, 1)
1280                         AC_DEFINE(PJ_HAS_SSL_SOCK, 1)
1281                 else
1282                         AC_MSG_RESULT([** OpenSSL libraries not found, disabling SSL support **])
1283                 fi
1284               ])
1285
1286 dnl # Include opencore-amrnb support
1287 AC_SUBST(ac_no_opencore_amrnb)
1288 AC_ARG_ENABLE(opencore_amrnb,
1289               AC_HELP_STRING([--disable-opencore-amrnb],
1290                              [Exclude OpenCORE AMR-NB support from the build (default: autodetect)])
1291               ,
1292               [
1293                 if test "$enable_opencore_amrnb" = "no"; then
1294                  [ac_no_opencore_amrnb=1]
1295                  AC_DEFINE(PJMEDIA_HAS_OPENCORE_AMRNB_CODEC,0)
1296                  AC_MSG_RESULT([Checking if OpenCORE AMR-NB support is disabled... yes])
1297                 fi
1298               ],
1299               [
1300                 AC_MSG_RESULT([checking for OpenCORE AMR-NB installations..])
1301                 AC_SUBST(opencore_amrnb_h_present)
1302                 AC_SUBST(opencore_amrnb_present)
1303                 AC_CHECK_HEADER(opencore-amrnb/interf_enc.h,[opencore_amrnb_h_present=1])
1304                 AC_CHECK_LIB(opencore-amrnb,Encoder_Interface_init,[opencore_amrnb_present=1 && LIBS="$LIBS -lopencore-amrnb"])
1305                 if test "x$opencore_amrnb_h_present" = "x1" -a "x$opencore_amrnb_present" = "x1"; then
1306                         AC_MSG_RESULT([OpenCORE AMR-NB library found, AMR-NB support enabled])
1307                         AC_DEFINE(PJMEDIA_HAS_OPENCORE_AMRNB_CODEC,1)
1308                 else
1309                         [ac_no_opencore_amrnb=1]
1310                         AC_DEFINE(PJMEDIA_HAS_OPENCORE_AMRNB_CODEC,0)
1311                 fi
1312               ])
1313
1314 dnl ##########################################
1315 dnl #
1316 dnl # MANUAL CONFIG
1317 dnl #
1318
1319
1320 dnl # Determine if select() requires nfds to be filled up with
1321 dnl # correct value (max_fd+1). If zero, nfds will be filled up with
1322 dnl # PJ_FD_SETSIZE
1323 AC_MSG_CHECKING([if select() needs correct nfds])
1324 case $target in
1325   *rtems*) AC_DEFINE(PJ_SELECT_NEEDS_NFDS,1)
1326            AC_MSG_RESULT(yes)
1327         ;;
1328   *) AC_DEFINE(PJ_SELECT_NEEDS_NFDS,0)
1329      AC_MSG_RESULT([no (default)])
1330      AC_MSG_RESULT([** Decided that select() doesn't need correct nfds (please check)])
1331         ;;
1332 esac
1333
1334 dnl # Determine if pj_thread_create() should enforce thread stack size when
1335 dnl # creating thread. Default is zero, to allow OS to allocate appropriate
1336 dnl # thread's stack size.
1337 AC_MSG_CHECKING([if pj_thread_create() should enforce stack size])
1338 case $target in
1339   *rtems*) AC_DEFINE(PJ_THREAD_SET_STACK_SIZE,1)
1340            AC_MSG_RESULT(yes)
1341         ;;
1342   *) AC_DEFINE(PJ_THREAD_SET_STACK_SIZE,0)
1343      AC_MSG_RESULT([no (default)])
1344         ;;
1345 esac
1346
1347 dnl # Determine if pj_thread_create() should allocate thread's stack from
1348 dnl # the pool. Default is zero, to let OS allocate thread's stack.
1349 AC_MSG_CHECKING([if pj_thread_create() should allocate stack])
1350 case $target in
1351   *rtems*) AC_DEFINE(PJ_THREAD_ALLOCATE_STACK,1)
1352            AC_MSG_RESULT(yes)
1353         ;;
1354   *) AC_DEFINE(PJ_THREAD_ALLOCATE_STACK,0)
1355      AC_MSG_RESULT([no (default)])
1356         ;;
1357 esac
1358
1359 dnl # This value specifies the value set in errno by the OS when a non-blocking
1360 dnl # socket recv() can not return immediate data.
1361 case $target in
1362   *mingw* | *cygw* | *win32* | *w32* )
1363         AC_DEFINE(PJ_BLOCKING_ERROR_VAL,WSAEWOULDBLOCK)
1364         ;;
1365   *) AC_DEFINE(PJ_BLOCKING_ERROR_VAL,EAGAIN)
1366      AC_MSG_RESULT([** Setting non-blocking recv() retval to EAGAIN (please check)])
1367         ;;
1368 esac
1369
1370 dnl # This value specifies the value set in errno by the OS when a non-blocking
1371 dnl # socket connect() can not get connected immediately.
1372 case $target in
1373   *mingw* | *cygw* | *win32* | *w32* )
1374         AC_DEFINE(PJ_BLOCKING_CONNECT_ERROR_VAL,WSAEWOULDBLOCK)
1375         ;;
1376   *) AC_DEFINE(PJ_BLOCKING_CONNECT_ERROR_VAL,EINPROGRESS)
1377      AC_MSG_RESULT([** Setting non-blocking connect() retval to EINPROGRESS (please check)])
1378         ;;
1379 esac
1380
1381
1382 AC_SUBST(target)
1383 AC_SUBST(ac_cross_compile)
1384 if test "$build" = "$host"; then
1385     ac_cross_compile=
1386 else
1387     ac_cross_compile=${host_orig}-
1388 fi
1389 AC_SUBST(ac_linux_poll,select)
1390 AC_SUBST(ac_host,unix)
1391 AC_SUBST(ac_main_obj)
1392 case $target in
1393   *rtems*)
1394         ac_main_obj=main_rtems.o
1395         ;;
1396   *)
1397         ac_main_obj=main.o
1398         ;;
1399 esac
1400 AC_SUBST(CC)
1401
1402 ac_build_mak_vars=`echo $ac_build_mak_vars | sed 's/\\\\n/\n/g'`
1403 AC_OUTPUT()
1404
1405
1406 AC_MSG_RESULT([
1407
1408 Configurations for current target have been written to 'build.mak', and 'os-auto.mak' in various build directories, and pjlib/include/pj/compat/os_auto.h.
1409
1410 Further customizations can be put in:
1411   - 'user.mak'
1412   - 'pjlib/include/pj/config_site.h'
1413
1414 The next step now is to run 'make dep' and 'make'.
1415 ])
1416