acinclude.m4 8.36 KB
Newer Older
aymeric's avatar
aymeric committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
dnl -*- autoconf -*-
AC_DEFUN([MS_CHECK_DEP],[
	dnl $1=dependency description
	dnl $2=dependency short name, will be suffixed with _CFLAGS and _LIBS
	dnl $3=headers's place
	dnl $4=lib's place
	dnl $5=header to check
	dnl $6=lib to check
	dnl $7=function to check in library
	
	dep_name=$2
	dep_headersdir=$3
	dep_libsdir=$4
	dep_header=$5
	dep_lib=$6
	dep_funclib=$7
	other_libs=$8	
	
	CPPFLAGS_save=$CPPFLAGS
	LDFLAGS_save=$LDFLAGS
smorlat's avatar
smorlat committed
21
	LIBS_save=$LIBS
smorlat's avatar
smorlat committed
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36

	case "$target_os" in
		*mingw*)
			ms_check_dep_mingw_found=yes
		;;
	esac
	if test "$ms_check_dep_mingw_found" != "yes" ; then
		CPPFLAGS=`echo "-I$dep_headersdir"|sed -e "s:-I/usr/include[\ ]*$::"`
		LDFLAGS=`echo "-L$dep_libsdir"|sed -e "s:-L/usr/lib\(64\)*[\ ]*::"`
	else
		CPPFLAGS="-I$dep_headersdir"	
		LDFLAGS="-L$dep_libsdir"
	fi


aymeric's avatar
aymeric committed
37
	LIBS="-l$dep_lib"
smorlat's avatar
smorlat committed
38

aymeric's avatar
aymeric committed
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
	
	$2_CFLAGS="$CPPFLAGS"
	$2_LIBS="$LDFLAGS $LIBS"

	AC_CHECK_HEADERS([$dep_header],[AC_CHECK_LIB([$dep_lib],[$dep_funclib],found=yes,found=no, [$other_libs])
	],found=no)
	
	if test "$found" = "yes" ; then
		eval $2_found=yes
	else
		eval $2_found=no
		eval $2_CFLAGS=
		eval $2_LIBS=
	fi
	AC_SUBST($2_CFLAGS)
	AC_SUBST($2_LIBS)
	CPPFLAGS=$CPPFLAGS_save
	LDFLAGS=$LDFLAGS_save
smorlat's avatar
smorlat committed
57
	LIBS=$LIBS_save
aymeric's avatar
aymeric committed
58 59 60 61 62 63 64
])


AC_DEFUN([MS_CHECK_VIDEO],[

	dnl conditionnal build of video support
	AC_ARG_ENABLE(video,
65
		  [AS_HELP_STRING([--enable-video], [Turn on video support compiling (default=yes])],
aymeric's avatar
aymeric committed
66 67 68 69 70
		  [case "${enableval}" in
			yes) video=true ;;
			no)  video=false ;;
			*) AC_MSG_ERROR(bad value ${enableval} for --enable-video) ;;
		  esac],[video=true])
71 72

	AC_ARG_ENABLE(ffmpeg,
73
		  [AS_HELP_STRING([--disable-ffmpeg], [Disable ffmpeg support])],
74 75 76 77 78
		  [case "${enableval}" in
			yes) ffmpeg=true ;;
			no)  ffmpeg=false ;;
			*) AC_MSG_ERROR(bad value ${enableval} for --disable-ffmpeg) ;;
		  esac],[ffmpeg=true])
aymeric's avatar
aymeric committed
79 80 81
	
	if test "$video" = "true"; then
		
82 83 84 85 86 87
		if test "$ffmpeg" = "true"; then
			dnl test for ffmpeg presence
			PKG_CHECK_MODULES(FFMPEG, [libavcodec >= 51.0.0 ],ffmpeg_found=yes , ffmpeg_found=no)
			if test x$ffmpeg_found = xno ; then
			   AC_MSG_ERROR([Could not find libavcodec (from ffmpeg) headers and library. This is mandatory for video support])
			fi
Simon Morlat's avatar
Simon Morlat committed
88 89 90
			
			FFMPEG_LIBS="$FFMPEG_LIBS -lavutil"
			
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
			PKG_CHECK_MODULES(SWSCALE, [libswscale >= 0.7.0 ],swscale_found=yes , swscale_found=no)
			if test x$swscale_found = xno ; then
			   AC_MSG_ERROR([Could not find libswscale (from ffmpeg) headers and library. This is mandatory for video support])
			fi

			dnl check for new/old ffmpeg header file layout
			CPPFLAGS_save=$CPPFLAGS
			CPPFLAGS="$FFMPEG_CFLAGS $CPPFLAGS"
			AC_CHECK_HEADERS(libavcodec/avcodec.h)
			CPPFLAGS=$CPPFLAGS_save

			dnl to workaround a bug on debian and ubuntu, check if libavcodec needs -lvorbisenc to compile	
			AC_CHECK_LIB(avcodec,avcodec_register_all, novorbis=yes , [
				LIBS="$LIBS -lvorbisenc"
				], $FFMPEG_LIBS )

			dnl when swscale feature is not provided by
			dnl libswscale, its features are swallowed by
			dnl libavcodec, but without swscale.h and without any
			dnl declaration into avcodec.h (this is to be
			dnl considered as an ffmpeg bug).
			dnl 
			dnl #if defined(HAVE_LIBAVCODEC_AVCODEC_H) && !defined(HAVE_LIBSWSCALE_SWSCALE_H)
			dnl # include "swscale.h" // private linhone swscale.h
			dnl #endif
			CPPFLAGS_save=$CPPFLAGS
			CPPFLAGS="$SWSCALE_CFLAGS $CPPFLAGS"
			AC_CHECK_HEADERS(libswscale/swscale.h)
			CPPFLAGS=$CPPFLAGS_save

121
			if test "$macosx_found" = "yes" ; then
122 123
				dnl we use quartz+opengl directly on mac os for video display.
				enable_sdl_default=false
124
				enable_x11_default=false
125
				enable_glx_default=false
126
				OBJCFLAGS="$OBJCFLAGS -framework QTKit"
127
				LIBS="$LIBS -framework QTKit -framework CoreVideo "
128 129 130 131
				dnl the following check is necessary but due to automake bug it forces every platform to have an objC compiler !
				dnl AC_LANG_PUSH([Objective C])
				dnl AC_CHECK_HEADERS([QTKit/QTKit.h],[],[AC_MSG_ERROR([QTKit framework not found, required for video support])])
				dnl AC_LANG_POP([Objective C])
132 133 134
			elif test "$ios_found" = "yes" ; then
				enable_sdl_default=false
				enable_x11_default=false
135
				enable_glx_default=false
Simon Morlat's avatar
Simon Morlat committed
136 137 138
			elif test "$ms_check_dep_mingw_found" = "yes" ; then
				enable_sdl_default=false
				enable_x11_default=false
139
				enable_glx_default=false
140 141 142
			else
				enable_sdl_default=false
				enable_x11_default=true
143
				enable_glx_default=true
144 145
			fi

146
			AC_ARG_ENABLE(sdl,
147
			  [AS_HELP_STRING([--disable-sdl], [Disable SDL support (default: disabled except on macos)])],
148 149 150 151
			  	  [case "${enableval}" in
				  yes) enable_sdl=true ;;
				  no)  enable_sdl=false ;;
			  *) AC_MSG_ERROR(bad value ${enableval} for --disable-sdl) ;;
152
		  	  esac],[enable_sdl=$enable_sdl_default])
153

154
			sdl_found="false"
155
			if test "$enable_sdl" = "true"; then
156
				   PKG_CHECK_MODULES(SDL, [sdl >= 1.2.0 ],sdl_found=true,[AC_MSG_ERROR([No SDL library found])])
157 158
			fi

159

160
			AC_ARG_ENABLE(x11,
161
			  [AS_HELP_STRING([--disable-x11], [Disable X11 support])],
162 163 164 165
		 	  [case "${enableval}" in
			  yes) enable_x11=true ;;
			  no)  enable_x11=false ;;
			  *) AC_MSG_ERROR(bad value ${enableval} for --disable-x11) ;;
166
		  	  esac],[enable_x11=$enable_x11_default])
167 168 169 170 171 172

			if test "$enable_x11" = "true"; then
			   AC_CHECK_HEADERS(X11/Xlib.h)
			fi

			AC_ARG_ENABLE(xv,
173
			  [AS_HELP_STRING([--enable-xv], [Enable xv support])],
174 175 176 177
			  [case "${enableval}" in
			  yes) enable_xv=true ;;
			  no)  enable_xv=false ;;
			  *) AC_MSG_ERROR(bad value ${enableval} for --enable-xv) ;;
178
		  	  esac],[enable_xv=$enable_x11_default])
179 180

			if test "$enable_xv" = "true"; then
181 182 183 184
				AC_CHECK_HEADERS(X11/extensions/Xv.h,[] ,[enable_xv=false])
				AC_CHECK_HEADERS(X11/extensions/Xvlib.h,[] ,[enable_xv=false],[
					#include <X11/Xlib.h>
				])
185 186 187 188
				AC_CHECK_LIB(Xv,XvCreateImage,[LIBS="$LIBS -lXv"],[enable_xv=false])
				if test "$enable_xv" = "false" ; then
					AC_MSG_ERROR([No X video output API found. Please install X11+Xv headers.])
				fi
Simon Morlat's avatar
Simon Morlat committed
189
			fi
190 191
			AC_ARG_ENABLE(glx,
			  [AS_HELP_STRING([--enable-glx], [Enable X11+OpenGL rendering support (requires glx and glew)])],
192
			  [case "${enableval}" in
193 194 195 196
			  yes) enable_glx=true ;;
			  no)  enable_glx=false ;;
			  *) AC_MSG_ERROR(bad value ${enableval} for --enable-glx) ;;
		  	  esac],[enable_glx=$enable_glx_default])
197

198 199 200
			if test "$enable_glx" = "true"; then
				AC_CHECK_HEADERS(GL/gl.h,[] ,[enable_glx=false])
				AC_CHECK_HEADERS(GL/glx.h,[] ,[enable_glx=false],[
201 202
					#include <GL/glx.h>
				])
203
				if test "$enable_glx" = "false" ; then
204 205
					AC_MSG_ERROR([No GL/GLX API found. Please install GL and GLX headers.])
				fi
206
				PKG_CHECK_MODULES(GLEW,[glew >= 1.5])
207
				AC_CHECK_HEADERS(X11/Xlib.h)
208
			fi
aymeric's avatar
aymeric committed
209
		fi
210
		
smorlat's avatar
smorlat committed
211
		AC_ARG_ENABLE(theora,
212
		  [AS_HELP_STRING([--disable-theora], [Disable theora support])],
smorlat's avatar
smorlat committed
213 214 215 216 217 218 219
		  [case "${enableval}" in
			yes) theora=true ;;
			no)  theora=false ;;
			*) AC_MSG_ERROR(bad value ${enableval} for --disable-theora) ;;
		  esac],[theora=true])

		if test x$theora = xtrue; then
aymeric's avatar
aymeric committed
220 221
		PKG_CHECK_MODULES(THEORA, [theora >= 1.0alpha7 ], [have_theora=yes],
					[have_theora=no])
smorlat's avatar
smorlat committed
222
		fi
223
		
224
		AC_ARG_ENABLE(vp8,
225
		  [AS_HELP_STRING([--disable-vp8], [Disable vp8 support])],
226 227 228 229 230 231
		  [case "${enableval}" in
			yes) vp8=true ;;
			no)  vp8=false ;;
			*) AC_MSG_ERROR(bad value ${enableval} for --disable-vp8) ;;
		  esac],[vp8=true])

232
		vp8dir=/usr
233
		if test x$vp8 = xtrue; then
Simon Morlat's avatar
Simon Morlat committed
234
			PKG_CHECK_MODULES(VP8, [vpx >= 0.9.6 ], [have_vp8=yes],
235
					[have_vp8=no])
Simon Morlat's avatar
Simon Morlat committed
236
			if test "$have_vp8" = "no" ; then
237 238 239 240 241
				MS_CHECK_DEP([VP8 codec],[VP8],[${vp8dir}/include],
					[${vp8dir}/lib],[vpx/vpx_encoder.h],[vpx],[vpx_codec_encode])
				if test "$VP8_found" = "yes" ; then
					have_vp8=yes
				fi
Simon Morlat's avatar
Simon Morlat committed
242
			fi
243 244
		fi

245 246
		if test "$ffmpeg" = "false"; then
		   FFMPEG_CFLAGS=" $FFMPEG_CFLAGS -DNO_FFMPEG"
smorlat's avatar
smorlat committed
247
		fi
248

smorlat's avatar
smorlat committed
249 250 251
		VIDEO_CFLAGS=" $FFMPEG_CFLAGS -DVIDEO_ENABLED"
		VIDEO_LIBS=" $FFMPEG_LIBS $SWSCALE_LIBS"

Simon Morlat's avatar
Simon Morlat committed
252
		if test "$sdl_found" = "true" ; then
smorlat's avatar
smorlat committed
253 254 255
			VIDEO_CFLAGS="$VIDEO_CFLAGS $SDL_CFLAGS -DHAVE_SDL"
			VIDEO_LIBS="$VIDEO_LIBS $SDL_LIBS"
		fi
aymeric's avatar
aymeric committed
256 257 258 259

		if test "${ac_cv_header_X11_Xlib_h}" = "yes" ; then
			VIDEO_LIBS="$VIDEO_LIBS -lX11"
		fi
260 261

		if test "$mingw_found" = "yes" ; then
262
			VIDEO_LIBS="$VIDEO_LIBS -lvfw32 -lgdi32"
263
		fi
jehan's avatar
jehan committed
264 265 266
		if test "$ios_found" = "yes" ; then
			LIBS="$LIBS -framework AVFoundation -framework CoreVideo -framework CoreMedia"
		fi
267
		if test "$enable_glx" = "true"; then
268
			VIDEO_LIBS="$VIDEO_LIBS -lGL -lGLEW"
Simon Morlat's avatar
Simon Morlat committed
269
			VIDEO_CFLAGS="$VIDEO_CFLAGS -DHAVE_GL"
270 271
		fi
		if test "$enable_xv" = "true"; then
Simon Morlat's avatar
Simon Morlat committed
272
			VIDEO_CFLAGS="$VIDEO_CFLAGS -DHAVE_XV"
273
		fi
aymeric's avatar
aymeric committed
274 275 276 277 278
	fi
	
	AC_SUBST(VIDEO_CFLAGS)
	AC_SUBST(VIDEO_LIBS)
])