Added PWLIB_CONFIGURE_OPTIONS environment variable for Win32 builds so
[opal/cbnco.git] / configure.ac
blobc2a73b25a2cc9ce0346e98e2242f77f0d08a6bc2
1 AC_INIT(include/opal/manager.h)
3 AC_PROG_CC
4 AC_PROG_CXX
6 dnl this must be updated for every minor revision, and for
7 dnl builds when and as necessary
8 REQUIRED_PWLIB_MAJOR=1
9 REQUIRED_PWLIB_MINOR=11
10 REQUIRED_PWLIB_BUILD=0
12 dnl ########################################################################
13 dnl set the OPAL directory to the current directory
15 OPALDIR=`pwd`
16 AC_SUBST(OPALDIR)
18 dnl ########################################################################
19 dnl set the PREFIX accordingly
20 if test "x$prefix" = "xNONE"; then
21    INSTALLPREFIX="/usr/local"
22 else
23    INSTALLPREFIX="${prefix}"
26 AC_SUBST(INSTALLPREFIX)
28 dnl ########################################################################
29 dnl set LIBDIR accordingly
30 LIBDIR="${libdir}"
32 AC_SUBST(LIBDIR)
34 dnl ########################################################################
35 dnl extract the OPAL version
37 dnl MSWIN_DISPLAY version,Version
38 dnl MSWIN_VERSION version,OPAL_MAJOR=MAJOR_VERSION
39 dnl MSWIN_VERSION version,OPAL_MINOR=MINOR_VERSION
40 dnl MSWIN_VERSION version,OPAL_BUILD=BUILD_NUMBER
41 dnl MSWIN_VERSION version,OPAL_VERSION=VERSION
43 MAJOR_VERSION=`cat ${OPALDIR}/version.h | grep MAJOR_VERSION | cut -f3 -d' '`
44 MINOR_VERSION=`cat ${OPALDIR}/version.h | grep MINOR_VERSION | cut -f3 -d' '`
45 BUILD_NUMBER=`cat ${OPALDIR}/version.h | grep BUILD_NUMBER | cut -f3 -d' '`
46 OPAL_VERSION="${MAJOR_VERSION}.${MINOR_VERSION}.${BUILD_NUMBER}"
47 AC_DEFINE_UNQUOTED(OPAL_MAJOR,   ${MAJOR_VERSION})
48 AC_DEFINE_UNQUOTED(OPAL_MINOR,   ${MINOR_VERSION})
49 AC_DEFINE_UNQUOTED(OPAL_BUILD,   ${BUILD_NUMBER})
50 AC_DEFINE_UNQUOTED(OPAL_VERSION, "$OPAL_VERSION")
53 dnl ########################################################################
54 dnl look for ptlib, use a preference order of explicit PWLIBDIR, directory
55 dnl at same level, home directory, /usr/local or /usr.
57 if test "${PWLIBDIR:-unset}" != "unset" ; then
58   AC_CHECK_FILE(${PWLIBDIR}/version.h, HAS_PTLIB=1)
60 if test "${HAS_PTLIB:-unset}" = "unset" ; then
61   AC_CHECK_FILE(${OPALDIR}/../pwlib/version.h, HAS_PTLIB=1)
62   if test "${HAS_PTLIB:-unset}" != "unset" ; then
63     PWLIBDIR="${OPALDIR}/../pwlib"
64   else
65     AC_CHECK_FILE(${HOME}/pwlib/include/ptlib.h, HAS_PTLIB=1)
66     if test "${HAS_PTLIB:-unset}" != "unset" ; then
67       PWLIBDIR="${HOME}/pwlib"
68     else
69       AC_CHECK_FILE(/usr/local/include/ptlib.h, HAS_PTLIB=1)
70       if test "${HAS_PTLIB:-unset}" != "unset" ; then
71         AC_PATH_PROG(PTLIB_CONFIG, ptlib-config, , /usr/local/bin)
72       else
73         AC_CHECK_FILE(/usr/include/ptlib.h, HAS_PTLIB=1)
74         if test "${HAS_PTLIB:-unset}" != "unset" ; then
75           AC_PATH_PROG(PTLIB_CONFIG, ptlib-config, , /usr/share/pwlib/make/)
76         fi
77       fi
78     fi
79   fi
82 if test "${HAS_PTLIB:-unset}" = "unset" ; then
83   echo "Cannot find pwlib - please install or set PWLIBDIR and try again"
84   exit
87 if test "${PWLIBDIR:-unset}" = "unset" ; then
88   if test "${PTLIB_CONFIG:-unset}" = "unset" ; then
89     echo "Cannot find ptlib-config - please install and try again"
90     exit
91   fi
92   PWLIBDIR=`$PTLIB_CONFIG --prefix`
95 if test "x$PWLIBDIR" = "x/usr" -o "x$PWLIBDIR" = "x/usr/"; then
96   PWLIBDIR="/usr/share/pwlib/"
98 if test "x$PWLIBDIR" = "x/usr/local" -o "x$PWLIBDIR" = "x/usr/"; then
99   PWLIBDIR="/usr/local/share/pwlib/"
101 AC_SUBST(PWLIBDIR)
103 echo "PWLib prefix set to.... $PWLIBDIR"
105 if test "${PWLIBDIR:-unset}" = "unset" ; then
106   PWVERSION=`$PTLIB_CONFIG --version`
107   PW_MAJOR_VERSION=`echo $PW_VERSION | cut -d'.' -f1`
108   PW_MINOR_VERSION=`echo $PW_VERSION | cut -d'.' -f2`
109   PW_BUILD_NUMBER=`echo $PW_VERSION | cut -d'.' -f3`
110   
111 else
112   PW_MAJOR_VERSION=`cat ${PWLIBDIR}/version.h | grep MAJOR_VERSION | cut -f3 -d' '`
113   PW_MINOR_VERSION=`cat ${PWLIBDIR}/version.h | grep MINOR_VERSION | cut -f3 -d' '`
114   PW_BUILD_NUMBER=`cat ${PWLIBDIR}/version.h | grep BUILD_NUMBER | cut -f3 -d' '`
115   PWVERSION="${PW_MAJOR_VERSION}.${PW_MINOR_VERSION}.${PW_BUILD_NUMBER}"
118 AC_ARG_ENABLE(versioncheck,
119                 [  --disable-versioncheck    disable PWLib version check],
120                 PWLIB_VERSION_CHECK=$enableval)
122 AC_MSG_CHECKING(Checking PWLib version ${PWVERSION})
123 if test "${PWLIB_VERSION_CHECK}x" = "nox" ; then
124   AC_MSG_RESULT(check disabled)
125 else
126   if test $PW_MAJOR_VERSION -lt $REQUIRED_PWLIB_MAJOR ; then
127     AC_MSG_RESULT(Major version less than required $REQUIRED_PWLIB_MAJOR)
128     exit 1
129   fi
130   if test $PW_MINOR_VERSION -lt $REQUIRED_PWLIB_MINOR ; then
131     AC_MSG_RESULT(Minor version less than required $REQUIRED_PWLIB_MINOR)
132     exit 1
133   fi
134   if test $PW_BUILD_NUMBER -lt $REQUIRED_PWLIB_BUILD ; then
135     AC_MSG_RESULT(Build version less than required $REQUIRED_PWLIB_BUILD)
136     exit 1
137   fi
138   AC_MSG_RESULT(ok)
141 AC_SUBST(PWLIBDIR)
143 dnl ########################################################################
144 dnl get the gcc version
146 if test x$GXX = xyes ; then
147   USE_GCC=yes
148   gcc_version=`$CXX -dumpversion`
149   AC_MSG_NOTICE(gcc version is $gcc_version);
150   GXX_MAJOR=`echo $gcc_version | sed 's/\..*$//'`
151   GXX_MINOR=[`echo $gcc_version | sed -e 's/[0-9][0-9]*\.//' -e 's/\..*$//'`]
152   GXX_PATCH=[`echo $gcc_version | sed -e 's/[0-9][0-9]*\.[0-9][0-9]*\.//' -e 's/\..*$//'`]
154   dnl cannot compile for less than gcc 3
155   AC_MSG_CHECKING(checking if gcc version is valid)
156   if test ${GXX_MAJOR} -lt 3 ; then
157     AC_MSG_RESULT(no)
158     AC_MSG_ERROR([OPAL requires gcc version 3 or later])
159   else
160     AC_MSG_RESULT(yes)
161   fi
165 dnl ########################################################################
166 dnl Look for system libspeex
167 localspeex="xxx"
168 AC_ARG_ENABLE(localspeex,
169        [  --enable-localspeex     use local version of Speex library rather than system version],
170        localspeex=$enableval)
172 AC_CHECK_SIZEOF(short)
173 AC_CHECK_SIZEOF(int)
174 AC_CHECK_SIZEOF(long)
175 AC_CHECK_SIZEOF(long long)
177 case 2 in
178         $ac_cv_sizeof_short) SIZE16="short";;
179         $ac_cv_sizeof_int) SIZE16="int";;
180 esac
182 case 4 in
183         $ac_cv_sizeof_int) SIZE32="int";;
184         $ac_cv_sizeof_long) SIZE32="long";;
185         $ac_cv_sizeof_short) SIZE32="short";;
186 esac
188 AC_SUBST(SIZE16)
189 AC_SUBST(SIZE32)
191 OPAL_HAVE_SPEEX_H=
192 OPAL_HAVE_SPEEX_SPEEX_H=
193 AC_CHECK_HEADERS("speex.h", OPAL_HAVE_SPEEX_H=1)
194 if test "${OPAL_HAVE_SPEEX_H}x" != "x" ; then
195   AC_DEFINE(OPAL_HAVE_SPEEX_H)
196 else
197   AC_CHECK_HEADERS("speex/speex.h", OPAL_HAVE_SPEEX_SPEEX_H=1)
198   if test "${OPAL_HAVE_SPEEX_SPEEX_H}x" != "x" ; then
199     AC_DEFINE(OPAL_HAVE_SPEEX_SPEEX_H)
200   fi
203 if test "${localspeex}" = "yes" ; then
204   AC_MSG_NOTICE(Forcing use of OPAL Speex sources)
205 elif test "${localspeex}" = "no" ; then
206   AC_MSG_NOTICE(Forcing use of system Speex library)
207   AC_DEFINE(OPAL_SYSTEM_SPEEX, 1)
208   AC_SUBST(OPAL_SYSTEM_SPEEX, 1)
209 else
210   AC_CHECK_LIB(speex, speex_encoder_destroy, SPEEX=1)
211   if test "${SPEEX}x" != "x" ; then
212     AC_CHECK_LIB(speex, speex_encode_int, SPEEX=1, unset SPEEX)
213   fi
214   if test "x$SPEEX" = "x" -o \( "${OPAL_HAVE_SPEEX_H}x" = "x" -a "${OPAL_HAVE_SPEEX_SPEEX_H}x" = "x" \); then
215     AC_MSG_NOTICE(Forcing use of OPAL Speex library)
216   else
217     AC_MSG_CHECKING(system Speex version)
218     if test "${OPAL_HAVE_SPEEX_H}x" != "x" ; then
219       echo "#include <speex.h>" > t.c 
220       echo "#include <speex_header.h>" >> t.c
221     else
222       echo "#include <speex/speex.h>" > t.c 
223       echo "#include <speex/speex_header.h>" >> t.c
224     fi
225     cat >> t.c <<C_FILE
226     #include <stdio.h>
227     int main(int argc,char *argv[])
228     {
229       SpeexHeader header;
230       speex_init_header(&header, 1, 1, &speex_nb_mode);
231       printf("%s\n", header.speex_version);
232     }
233 C_FILE
234     cc -o t t.c -lspeex > /dev/null 2>&1
235     if test \! -x t ; then
236       AC_MSG_RESULT(cannot determine - using OPAL version)
237     else
238       SYSVER=`./t`
239       AC_MSG_RESULT($SYSVER)
240       AC_MSG_CHECKING(library Speex version)
241       LIBVER=`grep "#define SPEEX_VERSION" ./src/codec/speex/libspeex/misc.h | sed -e 's/^.*[Ss][Pp][Ee][Ee][Xx]\-//' -e 's/\"//' -e 's/\/.*//'`
242       AC_MSG_RESULT($LIBVER)
243       AC_MSG_CHECKING(Speex versions)
244       cat > t.pl <<P_FILE
245       [
246       \$sysver = @ARGV[0];
247       \$libver = @ARGV[1];
248       @lib = split /\./, \$libver;
249       while (@lib < 3) {
250         @lib[0+@lib] = "0";
251       }
252       @sys = split /\./, \$sysver;
253       while (@sys < 3) {
254         @sys[0+@sys] = "0";
255       }
256       \$i = 0;
257       while (\$i < 3) {
258         if (@sys[\$i] < @lib[\$i]) {
259           print "0";
260           die;
261         }
262         \$i++;
263       }
264       print "1";
265       ]
266 P_FILE
267       SPEEX=`perl t.pl $SYSVER $LIBVER`
268       rm t.pl
269       if test "x$SPEEX" = "x0" ; then
270         AC_MSG_RESULT(OPAL version is more recent)
271       else
272         AC_MSG_RESULT(system version is more recent)
273         AC_DEFINE(OPAL_SYSTEM_SPEEX, 1)
274         AC_SUBST(OPAL_SYSTEM_SPEEX, 1)
275         AC_MSG_CHECKING(Speex noise type)
276         if test "${OPAL_HAVE_SPEEX_H}x" != "x" ; then
277           echo "#include <speex.h>" > t.c
278           echo "#include <speex_preprocess.h>" >> t.c
279         else
280           echo "#include <speex/speex.h>" > t.c
281           echo "#include <speex/speex_preprocess.h>" >> t.c
282         fi
283         cat >> t.c <<C_FILE
284           #include <stdio.h>
285           int main(int argc,char *argv[])
286           {
287              struct SpeexPreprocessState *st;
288              spx_int16_t *x;
289              float *echo;
290              speex_preprocess(st, x, echo);
291           }
292 C_FILE
293         rm -f t
294         cc -Werror -o t t.c -lspeex > /dev/null 2>&1
295         if test \! -x t ; then
296           AC_MSG_RESULT(spx_int32_t)
297         else
298           AC_MSG_RESULT(float)
299           AC_DEFINE(OPAL_SPEEX_FLOAT_NOISE)
300         fi
301       fi
302     fi
303     rm -f t t.c
304   fi
307 AC_SUBST(OPAL_HAVE_SPEEX_SPEEX_H)
309 dnl ########################################################################
310 dnl enable audio, video, SIP, H.323 and IAX
312 dnl MSWIN_DISPLAY audio,Audio
313 dnl MSWIN_DEFINE  audio,OPAL_AUDIO
314 AC_SUBST(OPAL_AUDIO, 1)
315 AC_DEFINE(OPAL_AUDIO)
318 dnl MSWIN_DISPLAY video,Video
319 dnl MSWIN_DEFINE  video,OPAL_VIDEO
320 AC_SUBST(OPAL_VIDEO, 1)
321 AC_DEFINE(OPAL_VIDEO)
324 dnl MSWIN_DISPLAY sip,SIP support
325 dnl MSWIN_DEFINE  sip,OPAL_SIP
327 sip=yes
328 AC_ARG_ENABLE(sip,
329        [  --disable-sip           disable SIP protocol support],
330        sip=$enableval)
331 AC_MSG_CHECKING(SIP protocol)
332 if test "$sip" = "yes" ; then
333   AC_SUBST(OPAL_SIP, 1)
334   AC_DEFINE(OPAL_SIP)
335   AC_MSG_RESULT(enabled)
336 else
337   AC_MSG_RESULT(disabled)
341 dnl MSWIN_DISPLAY h323,H.323 support
342 dnl MSWIN_DEFINE  h323,OPAL_H323
344 h323=yes
345 AC_ARG_ENABLE(h323,
346        [  --disable-h323          disable H.323 protocol support],
347        h323=$enableval)
348 AC_MSG_CHECKING(H.323 protocol)
349 if test "$h323" = "yes" ; then
350   AC_SUBST(OPAL_H323, 1)
351   AC_DEFINE(OPAL_H323)
352   AC_MSG_RESULT(enabled)
353 else
354   AC_SUBST(OPAL_H323, 0)
355   AC_MSG_RESULT(disabled (T.38 also disabled))
356   t38=no
358 AC_SUBST(OPAL_H323, $OPAL_H323)
361 dnl MSWIN_DISPLAY iax2,IAX2 support
362 dnl MSWIN_DEFINE  iax2,OPAL_IAX2
364 iax=yes
365 AC_ARG_ENABLE(iax,
366        [  --disable-iax           disable IAX2 protocol support],
367        iax=$enableval)
368 AC_MSG_CHECKING(IAX2 protocol)
369 if test "$iax" = "yes" ; then
370   AC_SUBST(OPAL_IAX2, 1)
371   AC_DEFINE(OPAL_IAX2)
372   AC_MSG_RESULT(enabled)
373 else
374   AC_MSG_RESULT(disabled)
377 dnl MSWIN_DISPLAY h224,H.224 support
378 dnl MSWIN_DEFINE  h224,OPAL_H224
380 h224=yes
381 AC_ARG_ENABLE(h224,
382                 [  --disable-h224          disable H.224 protocol support],
383                 h224=$enableval)
384 AC_MSG_CHECKING(H224 protocol)
385 if test "$h224" = "yes" ; then
386   AC_SUBST(OPAL_H224, 1)
387   AC_DEFINE(OPAL_H224)
388   AC_MSG_RESULT(enabled)
389 else
390   AC_MSG_RESULT(disabled)
393 dnl ########################################################################
395 dnl T.38
397 dnl MSWIN_DISPLAY    t38,T.38
398 dnl MSWIN_DEFINE     t38,OPAL_T38FAX
399 dnl MSWIN_IF_FEATURE t38,h323
401 t38=yes
402 if test "$t38" = "yes" ; then
403   AC_ARG_ENABLE(t38,
404          [  --disable-t38           disable T.38 protocol support],
405          t38=$enableval)
406   AC_MSG_CHECKING(T.38 protocol)
407   if test "$t38" = "yes" ; then
408     AC_SUBST(OPAL_T38FAX, 1)
409     AC_DEFINE(OPAL_T38FAX)
410     AC_MSG_RESULT(enabled)
411   else
412     AC_MSG_RESULT(disabled)
413   fi
417 dnl ########################################################################
419 dnl H.460
421 dnl MSWIN_DISPLAY h460,H.460
422 dnl MSWIN_DEFINE  h460,H323_H460
424 AC_ARG_ENABLE(h460,
425        [  --disable-h460          disable H.460])
426 if test "${enable_h460}x" = "x" ; then
427   enable_h460=yes
429 if test "$enable_h460" == "yes" ; then
430   H323_H460=1
431   AC_DEFINE(H323_H460, 1)
432 else
433   H323_H460=
434   AC_MSG_NOTICE(Disabling H.460)
436 AC_SUBST(H323_H460)
439 dnl ########################################################################
441 dnl LID, used for vpb, dialogic etc ...
443 dnl MSWIN_DISPLAY lids,Line Interface Device
444 dnl MSWIN_DEFINE  lids,OPAL_LID
446 OPAL_LID=
447 lid=yes
448 if test "$lid" = "yes" ; then
449   AC_ARG_ENABLE(lid,
450          [  --disable-lid           disable LID support],
451          lid=$enableval)
452   AC_MSG_CHECKING(LID support)
453   if test "$lid" = "yes" ; then
454     AC_DEFINE(OPAL_LID, 1)
455     OPAL_LID=1
456     AC_MSG_RESULT(enabled)
457   else
458     AC_MSG_RESULT(disabled)
459   fi
461 AC_SUBST(OPAL_LID)
463 dnl ########################################################################
465 dnl Cisco libSRTP
466 dnl 
468 dnl MSWIN_DISPLAY     libsrtp,Cisco libSRTP support
469 dnl MSWIN_CHECK_FILE  libsrtp,include\srtp.h,HAS_LIBSRTP=1
470 dnl MSWIN_DIR_SYMBOL  libsrtp,LIBSRTP_DIR
471 dnl MSWIN_CHECK_DIR   libsrtp,.\srtp
472 dnl MSWIN_CHECK_DIR   libsrtp,..\external\srtp
473 dnl MSWIN_CHECK_DIR   libsrtp,c:\libs
475 HAS_LIBSRTP=
476 AC_MSG_CHECKING(for libSRTP)
477 AC_TRY_COMPILE([#include "srtp/srtp.h"],
478  [int main(int argc, char *argv[]) { crypto_policy_t p; p.cipher_key_len = SRTP_MASTER_KEY_LEN; return 0; }],
479  HAS_LIBSRTP=1)
480 if test "${HAS_LIBSRTP}" = "1" ; then
481   AC_MSG_RESULT(yes)
482   AC_DEFINE(HAS_LIBSRTP, 1)
483   HAS_LIBSRTP=1
484   OPAL_SRTP=1
485 else
486   AC_MSG_RESULT(no)
488 AC_SUBST(OPAL_SRTP)
489 AC_SUBST(HAS_LIBSRTP)
492 dnl ########################################################################
493 dnl output make directives
495 AC_SUBST(STDCCFLAGS)
496 AC_SUBST(LDFLAGS)
497 AC_SUBST(ENDLDLIBS)
498 AC_PROG_INSTALL
500 dnl ########################################################################
501 dnl Output configured files
503 AC_CONFIG_SUBDIRS(plugins)
505 dnl ########################################################################
506 dnl output header file
508 AC_CONFIG_FILES(opal_inc.mak)
509 AC_CONFIG_FILES(Makefile)
510 AC_CONFIG_HEADERS(include/opal/buildopts.h)
512 AC_OUTPUT(src/codec/speex/libspeex/speex_config_types.h)