]> sjero.net Git - linphone/blob - linphone/mediastreamer2/acinclude.m4
remote ortp and add it as a submodule instead.
[linphone] / linphone / mediastreamer2 / acinclude.m4
1 dnl -*- autoconf -*-
2 AC_DEFUN([MS_CHECK_DEP],[
3         dnl $1=dependency description
4         dnl $2=dependency short name, will be suffixed with _CFLAGS and _LIBS
5         dnl $3=headers's place
6         dnl $4=lib's place
7         dnl $5=header to check
8         dnl $6=lib to check
9         dnl $7=function to check in library
10         
11         dep_name=$2
12         dep_headersdir=$3
13         dep_libsdir=$4
14         dep_header=$5
15         dep_lib=$6
16         dep_funclib=$7
17         other_libs=$8   
18         
19         CPPFLAGS_save=$CPPFLAGS
20         LDFLAGS_save=$LDFLAGS
21         LIBS_save=$LIBS
22
23         case "$target_os" in
24                 *mingw*)
25                         ms_check_dep_mingw_found=yes
26                 ;;
27         esac
28         if test "$ms_check_dep_mingw_found" != "yes" ; then
29                 CPPFLAGS=`echo "-I$dep_headersdir"|sed -e "s:-I/usr/include[\ ]*$::"`
30                 LDFLAGS=`echo "-L$dep_libsdir"|sed -e "s:-L/usr/lib\(64\)*[\ ]*::"`
31         else
32                 CPPFLAGS="-I$dep_headersdir"    
33                 LDFLAGS="-L$dep_libsdir"
34         fi
35
36
37         LIBS="-l$dep_lib"
38
39         
40         $2_CFLAGS="$CPPFLAGS"
41         $2_LIBS="$LDFLAGS $LIBS"
42
43         AC_CHECK_HEADERS([$dep_header],[AC_CHECK_LIB([$dep_lib],[$dep_funclib],found=yes,found=no, [$other_libs])
44         ],found=no)
45         
46         if test "$found" = "yes" ; then
47                 eval $2_found=yes
48         else
49                 eval $2_found=no
50                 eval $2_CFLAGS=
51                 eval $2_LIBS=
52         fi
53         AC_SUBST($2_CFLAGS)
54         AC_SUBST($2_LIBS)
55         CPPFLAGS=$CPPFLAGS_save
56         LDFLAGS=$LDFLAGS_save
57         LIBS=$LIBS_save
58 ])
59
60
61 AC_DEFUN([MS_CHECK_VIDEO],[
62
63         dnl conditionnal build of video support
64         AC_ARG_ENABLE(video,
65                   [  --enable-video    Turn on video support compiling],
66                   [case "${enableval}" in
67                         yes) video=true ;;
68                         no)  video=false ;;
69                         *) AC_MSG_ERROR(bad value ${enableval} for --enable-video) ;;
70                   esac],[video=true])
71                   
72         AC_ARG_WITH( ffmpeg,
73                   [  --with-ffmpeg              Sets the installation prefix of ffmpeg, needed for video support. [default=/usr] ],
74                   [ ffmpegdir=${withval}],[ ffmpegdir=/usr ])
75         
76         if test "$video" = "true"; then
77                 
78                 dnl test for ffmpeg presence
79                 PKG_CHECK_MODULES(FFMPEG, [libavcodec >= 51.0.0 ],ffmpeg_found=yes , ffmpeg_found=no)
80                 if test x$ffmpeg_found = xno ; then
81                         AC_MSG_ERROR([Could not find libavcodec (from ffmpeg) headers and library. This is mandatory for video support])
82                 fi
83                 PKG_CHECK_MODULES(SWSCALE, [libswscale >= 0.7.0 ],swscale_found=yes , swscale_found=no)
84                 if test x$swscale_found = xno ; then
85                         AC_MSG_ERROR([Could not find libswscale (from ffmpeg) headers and library. This is mandatory for video support])
86                 fi
87
88                 dnl check for new/old ffmpeg header file layout
89                 CPPFLAGS_save=$CPPFLAGS
90                 CPPFLAGS="$FFMPEG_CFLAGS $CPPFLAGS"
91                 AC_CHECK_HEADERS(libavcodec/avcodec.h)
92                 CPPFLAGS=$CPPFLAGS_save
93
94                 dnl to workaround a bug on debian and ubuntu, check if libavcodec needs -lvorbisenc to compile  
95                 AC_CHECK_LIB(avcodec,avcodec_register_all, novorbis=yes , [
96                         LIBS="$LIBS -lvorbisenc"
97                 ], $FFMPEG_LIBS )
98
99                 dnl when swscale feature is not provided by
100                 dnl libswscale, its features are swallowed by
101                 dnl libavcodec, but without swscale.h and without any
102                 dnl declaration into avcodec.h (this is to be
103                 dnl considered as an ffmpeg bug).
104                 dnl 
105                 dnl #if defined(HAVE_LIBAVCODEC_AVCODEC_H) && !defined(HAVE_LIBSWSCALE_SWSCALE_H)
106                 dnl # include "swscale.h" // private linhone swscale.h
107                 dnl #endif
108                 CPPFLAGS_save=$CPPFLAGS
109                 CPPFLAGS="$SWSCALE_CFLAGS $CPPFLAGS"
110                 AC_CHECK_HEADERS(libswscale/swscale.h)
111                 CPPFLAGS=$CPPFLAGS_save
112
113                 AC_ARG_ENABLE(sdl,
114                   [  --disable-sdl    Disable SDL support],
115                   [case "${enableval}" in
116                         yes) enable_sdl=true ;;
117                         no)  enable_sdl=false ;;
118                         *) AC_MSG_ERROR(bad value ${enableval} for --disable-sdl) ;;
119                   esac],[enable_sdl=true])
120
121                 sdl_found=no
122                 if test "$enable_sdl" = "true"; then
123                    PKG_CHECK_MODULES(SDL, [sdl >= 1.2.0 ],sdl_found=yes,sdl_found=no)
124
125                    if test "$sdl_found" = "no" && test "$mingw_found" != "yes"; then
126                         AC_MSG_ERROR([Could not find libsdl headers and library. This is mandatory for video support])
127                    fi
128                 fi
129
130                 AC_ARG_ENABLE(theora,
131                   [  --disable-theora    Disable theora support],
132                   [case "${enableval}" in
133                         yes) theora=true ;;
134                         no)  theora=false ;;
135                         *) AC_MSG_ERROR(bad value ${enableval} for --disable-theora) ;;
136                   esac],[theora=true])
137
138                 if test x$theora = xtrue; then
139                 PKG_CHECK_MODULES(THEORA, [theora >= 1.0alpha7 ], [have_theora=yes],
140                                         [have_theora=no])
141                 fi
142
143                 AC_ARG_ENABLE(x11,
144                   [  --disable-x11    Disable X11 support],
145                   [case "${enableval}" in
146                         yes) enable_x11=true ;;
147                         no)  enable_x11=false ;;
148                         *) AC_MSG_ERROR(bad value ${enableval} for --disable-x11) ;;
149                   esac],[enable_x11=true])
150
151                 if test "$enable_x11" = "true"; then
152                 AC_CHECK_HEADERS(X11/Xlib.h)
153                 fi
154                 
155                 VIDEO_CFLAGS=" $FFMPEG_CFLAGS -DVIDEO_ENABLED"
156                 VIDEO_LIBS=" $FFMPEG_LIBS $SWSCALE_LIBS"
157
158                 if test "$sdl_found" = "yes" ; then
159                         VIDEO_CFLAGS="$VIDEO_CFLAGS $SDL_CFLAGS -DHAVE_SDL"
160                         VIDEO_LIBS="$VIDEO_LIBS $SDL_LIBS"
161                 fi
162
163                 if test "${ac_cv_header_X11_Xlib_h}" = "yes" ; then
164                         VIDEO_LIBS="$VIDEO_LIBS -lX11"
165                 fi
166
167                 if test "$mingw_found" = "yes" ; then
168                         VIDEO_LIBS="$VIDEO_LIBS -lvfw32"
169                 fi
170
171                 case $target_os in
172                         *darwin*)
173                                 LIBS="$LIBS -framework QuickTime"
174                         ;;
175                 esac
176         fi
177         
178         AC_SUBST(VIDEO_CFLAGS)
179         AC_SUBST(VIDEO_LIBS)
180 ])