Do not build FFMpeg plugin if FFMpeg is not installed.
[2oom.git] / acinclude.m4
blob89db997c57a7231a67683d5de4b1395ccb351f6c
1 dnl Borrowed from Transcode (http://www.transcoding.org/cgi-bin/transcode)
3 dnl PKG_INIT(rptfile, errfile)
4 dnl
5 AC_DEFUN([PKG_INIT],
7 pkg_err="no"
8 pkg_err_file="pkg_err_file"
9 pkg_rpt_file="pkg_rpt_file"
11 if test x"$1" != x"" ; then
12   pkg_rpt_file="$1"
14 echo -n > $pkg_rpt_file
16 if test x"$2" != x"" ; then
17   pkg_err_file="$2"
19 echo -n > $pkg_err_file
23 dnl PKG_ERROR(name, object, req-enable, pkg, url, [error message])
24 AC_DEFUN([PKG_ERROR],
26 pkg_err="yes"
27 this_pkg_err="yes"
29 prob=""
30 if test x"$3" = x"required" ; then
31   prob="requirement failed"
32 else
33   prob="option '--enable-$1' failed"
36 cat >> $pkg_err_file <<EOF
37 ERROR: $prob: $6
38 $2 can be found in the following packages:
39   $4  $5
41 EOF
45 dnl PKG_CHECK(pkg-name, def-enabled, var-name, pkgconfig-name, conf-script,
46 dnl     header, lib, symbol)
47 dnl Test for pkg-name, and define var-name_CFLAGS and var-name_LIBS
48 dnl   and HAVE_var-name if found
49 dnl
50 dnl 1 name          name of package; required (pkg-config name if applicable)
51 dnl 2 req-enable    enable  by default, 'required', 'yes' or 'no'; required
52 dnl 3 var-name      name stub for variables, preferably uppercase; required
53 dnl 4 conf-script   name of "-config" script or 'no'
54 dnl 5 header        header file to check or 'none'
55 dnl 6 lib           library to check or 'none'
56 dnl 7 symbol        symbol from the library to check or ''
57 dnl 8 pkg           package (pkg-config name if applicable)
58 dnl 9 url           homepage for the package
60 AC_DEFUN([PKG_CHECK],
62 if test x"$2" != x"required" ; then
63   AC_MSG_CHECKING([whether $1 support is requested])
64   AC_ARG_ENABLE($1,
65     AC_HELP_STRING([--enable-$1],
66       [build with $1 support ($2)]),
67     [case "${enableval}" in
68       yes) ;;
69       no)  ;;
70       *) AC_MSG_ERROR(bad value ${enableval} for --enable-$1) ;;
71     esac],
72     enable_$1="$2")
73   AC_MSG_RESULT($enable_$1)
74 else
75   enable_$1="yes"
78 AC_ARG_WITH($1-prefix,
79   AC_HELP_STRING([--with-$1-prefix=PFX],
80     [prefix where $1 is installed (/usr)]),
81   w_$1_p="$withval", w_$1_p="")
83 AC_ARG_WITH($1-includes,
84   AC_HELP_STRING([--with-$1-includes=DIR],
85     [directory where $1 headers ($5) are installed (/usr/include)]),
86   w_$1_i="$withval", w_$1_i="")
88 AC_ARG_WITH($1-libs,
89   AC_HELP_STRING([--with-$1-libs=DIR],
90     [directory where $1 libararies (lib$6.so) are installed (/usr/lib)]),
91   w_$1_l="$withval", w_$1_l="")
93 have_$1="no"
94 this_pkg_err="no"
96 if test x"$enable_$1" = x"yes" ; then
98   dnl pkg-config
100   pkg_config_$1="no"
101   AC_MSG_CHECKING([for pkgconfig support for $1])
102   if test x"$PKG_CONFIG" != x"no" ; then
103     if $PKG_CONFIG $8 --exists ; then
104       pkg_config_$1="yes"
105     fi
106   fi
107   AC_MSG_RESULT($pkg_config_$1)
109   dnl *-config
111   if test x"$4" != x"no" ; then
112     if test x"$w_$1_p" != x"" ; then
113       if test -x $w_$1_p/bin/$4 ; then
114         $1_config="$w_$1_p/bin/$4"
115       fi
116     fi
117     AC_PATH_PROG($1_config, $4, no)
118   else
119     $1_config="no"
120   fi
122   # get and test the _CFLAGS
124   AC_MSG_CHECKING([how to determine $3_CFLAGS])
125   if test x"$w_$1_i" != x"" ; then
126     $1_ii="-I$w_$1_i"
127     AC_MSG_RESULT(user)
128   else
129     if test x"$pkg_config_$1" != x"no" ; then
130       $1_ii="`$PKG_CONFIG $8 --cflags`"
131       AC_MSG_RESULT(pkg-config)
132     else
133       if test x"$$1_config" != x"no" ; then
134         $1_ii="`$$1_config --cflags`"
135         AC_MSG_RESULT($$1_config)
136       else
137         if test x"$w_$1_p" != x"" ; then
138           $1_ii="-I$w_$1_p/include"
139           AC_MSG_RESULT(prefix)
140         else
141           $1_ii="-I/usr/include"
142           AC_MSG_RESULT(default)
143         fi
144       fi
145     fi
146   fi
147   ipaths="" ; xi=""
148   for i in $$1_ii ; do
149     case $i in
150       -I*) ipaths="$ipaths $i" ;;
151         *) xi="$xi $i" ;;
152     esac
153   done
154   $1_ii="$ipaths"
155   $1_ii="`echo $$1_ii | sed -e 's/  */ /g'`"
156   $3_EXTRA_CFLAGS="$$3_EXTRA_CFLAGS $xi"
157   $3_EXTRA_CFLAGS="`echo $$3_EXTRA_CFLAGS | sed -e 's/  */ /g'`"
159   if test x"$5" != x"none" ; then
160     save_CPPFLAGS="$CPPFLAGS"
161     CPPFLAGS="$CPPFLAGS $$1_ii"
162     AC_CHECK_HEADER([$5],
163       [$3_CFLAGS="$$1_ii"],
164       [PKG_ERROR($1, $5, $2, $8, $9, [cannot compile $5])])
165     CPPFLAGS="$save_CPPFLAGS"
166   fi
168   # get and test the _LIBS
170   AC_MSG_CHECKING([how to determine $3_LIBS])
171   if test x"$w_$1_l" != x"" ; then
172     $1_ll="-L$w_$1_l"
173     AC_MSG_RESULT(user)
174   else
175     if test x"$pkg_config_$1" != x"no" ; then
176       $1_ll="`$PKG_CONFIG $8 --libs`"
177       AC_MSG_RESULT(pkg-config)
178     else
179       if test x"$$1_config" != x"no" ; then
180         $1_ll="`$$1_config --libs`"
181         AC_MSG_RESULT($$1_config)
182       else
183         if test x"$w_$1_p" != x"" ; then
184           $1_ll="-L$w_$1_p${deflib}"
185           AC_MSG_RESULT(prefix)
186         else
187           $1_ll="-L/usr${deflib}"
188           AC_MSG_RESULT(default)
189         fi
190       fi
191     fi
192   fi
193   lpaths="" ; xlibs="" ; xlf=""
194   for l in $$1_ll ; do
195     case $l in
196       -L*) lpaths="$lpaths $l" ;;
197       -l*) test x"$l" != x"-l$6" && xlibs="$xlibs $l" ;;
198         *) xlf="$xlf $l" ;;
199     esac
200   done
201   $1_ll="$lpaths"
202   $1_ll="`echo $$1_ll | sed -e 's/  */ /g'`"
203   xl=""
204   for i in $xlibs $xlf ; do
205     echo " $$3_EXTRA_LIBS " | grep -vq " $i " && xl="$xl $i"
206   done
207   $3_EXTRA_LIBS="$$3_EXTRA_LIBS $xl"
208   $3_EXTRA_LIBS="`echo $$3_EXTRA_LIBS | sed -e 's/  */ /g'`"
210   if test x"$6" != x"none" ; then
211     save_LDFLAGS="$LDFLAGS"
212     LDFLAGS="$LDFLAGS $$1_ll"
213     AC_CHECK_LIB([$6], [$7],
214       [$3_LIBS="$$1_ll -l$6 $$3_EXTRA_LIBS"],
215       [PKG_ERROR($1, lib$6, $2, $8, $9, [cannot link against lib$6])],
216       [$$3_EXTRA_LIBS])
217     LDFLAGS="$save_LDFLAGS"
218   fi
220   if test x"$this_pkg_err" = x"no" ; then
221     have_$1="yes"
222   fi
224 else
225   $3_CFLAGS=""
226   $3_LIBS=""