1# Configure paths for libebml 2 3dnl PATH_EBML([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) 4dnl Test for libebml, and define EBML_CFLAGS and EBML_LIBS 5dnl 6AC_DEFUN([PATH_EBML], 7[dnl 8dnl Get the cflags and libraries 9dnl 10AC_ARG_WITH(ebml-prefix,[ --with-ebml-prefix=PFX Prefix where libebml is installed (optional)], ebml_prefix="$withval", ebml_prefix="") 11AC_ARG_WITH(ebml-include,[ --with-ebml-include=DIR Path to where the libebml include files installed (optional)], ebml_include="$withval", ebml_include="") 12AC_ARG_WITH(ebml-lib,[ --with-ebml-lib=DIR Path to where the libebml library installed (optional)], ebml_lib="$withval", ebml_lib="") 13AC_ARG_ENABLE(ebmltest, [ --disable-ebmltest Do not try to compile and run a test EBML program],, enable_ebmltest=yes) 14 15 if test "x$ebml_prefix" != "x"; then 16 ebml_args="$ebml_args --prefix=$ebml_prefix" 17 if test "x$ebml_include" != "x"; then 18 EBML_CFLAGS="-I$ebml_include" 19 else 20 EBML_CFLAGS="-I$ebml_prefix/include/ebml" 21 fi 22 if test "x$ebml_lib" != "x"; then 23 EBML_LIBS="-L$ebml_lib" 24 else 25 EBML_LIBS="-L$ebml_prefix/lib" 26 fi 27 elif test "x$prefix" != "xNONE"; then 28 ebml_args="$ebml_args --prefix=$prefix" 29 if test "x$ebml_include" != "x"; then 30 EBML_CFLAGS="-I$ebml_include" 31 else 32 EBML_CFLAGS="-I$prefix/include/ebml" 33 fi 34 if test "x$ebml_lib" != "x"; then 35 EBML_LIBS="-L$ebml_lib" 36 else 37 EBML_LIBS="-L$prefix/lib" 38 fi 39 else 40 if test "x$ebml_include" != "x"; then 41 EBML_CFLAGS="-I$ebml_include" 42 else 43 EBML_CFLAGS="-I/usr/include/ebml -I/usr/local/include/ebml" 44 fi 45 if test "x$ebml_lib" != "x"; then 46 EBML_LIBS="-L$ebml_lib" 47 else 48 EBML_LIBS="-L/usr/local/lib" 49 fi 50 fi 51 52 EBML_LIBS="$EBML_LIBS -lebml" 53 54 AC_MSG_CHECKING(for EBML) 55 no_ebml="" 56 57 58 if test "x$enable_ebmltest" = "xyes" ; then 59 ac_save_CFLAGS="$CFLAGS" 60 ac_save_LIBS="$LIBS" 61 CFLAGS="$CFLAGS $EBML_CFLAGS" 62 LIBS="$LIBS $EBML_LIBS" 63dnl 64dnl Now check if the installed EBML is sufficiently new. 65dnl 66 rm -f conf.ebmltest 67 AC_TRY_RUN([ 68#include <stdio.h> 69#include <stdlib.h> 70#include <string.h> 71#include <EbmlConfig.h> 72 73int main () 74{ 75 system("touch conf.ebmltest"); 76 return 0; 77} 78 79],, no_ebml=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) 80 CFLAGS="$ac_save_CFLAGS" 81 LIBS="$ac_save_LIBS" 82 fi 83 84 if test "x$no_ebml" = "x" ; then 85 AC_MSG_RESULT(yes) 86 ifelse([$1], , :, [$1]) 87 else 88 AC_MSG_RESULT(no) 89 if test -f conf.ebmltest ; then 90 : 91 else 92 echo "*** Could not run Ebml test program, checking why..." 93 CFLAGS="$CFLAGS $EBML_CFLAGS" 94 LIBS="$LIBS $EBML_LIBS" 95 AC_TRY_LINK([ 96#include <stdio.h> 97#include <EbmlConfig.h> 98], [ return 0; ], 99 [ echo "*** The test program compiled, but did not run. This usually means" 100 echo "*** that the run-time linker is not finding EBML or finding the wrong" 101 echo "*** version of EBML. If it is not finding EBML, you'll need to set your" 102 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" 103 echo "*** to the installed location Also, make sure you have run ldconfig if that" 104 echo "*** is required on your system" 105 echo "***" 106 echo "*** If you have an old version installed, it is best to remove it, although" 107 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"], 108 [ echo "*** The test program failed to compile or link. See the file config.log for the" 109 echo "*** exact error that occured. This usually means EBML was incorrectly installed" 110 echo "*** or that you have moved EBML since it was installed." ]) 111 CFLAGS="$ac_save_CFLAGS" 112 LIBS="$ac_save_LIBS" 113 fi 114 EBML_CFLAGS="" 115 EBML_LIBS="" 116 ifelse([$2], , :, [$2]) 117 fi 118 AC_SUBST(EBML_CFLAGS) 119 AC_SUBST(EBML_LIBS) 120 rm -f conf.ebmltest 121]) 122 123# Configure paths for libmatroska 124 125dnl PATH_MATROSKA(MIN_VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) 126dnl Test for libmatroska, and define MATROSKA_CFLAGS and MATROSKA_LIBS 127dnl 128AC_DEFUN([PATH_MATROSKA], 129[dnl 130dnl Get the cflags and libraries 131dnl 132AC_ARG_WITH(matroska-prefix,[ --with-matroska-prefix=PFX Prefix where libmatroska is installed (optional)], matroska_prefix="$withval", matroska_prefix="") 133AC_ARG_WITH(matroska-include,[ --with-matroska-include=DIR Path to where the libmatroska include files installed (optional)], matroska_include="$withval", matroska_include="") 134AC_ARG_WITH(matroska-lib,[ --with-matroska-lib=DIR Path to where the libmatroska library installed (optional)], matroska_lib="$withval", matroska_lib="") 135AC_ARG_ENABLE(matroskatest, [ --disable-matroskatest Do not try to compile and run a test Matroska program],, enable_matroskatest=yes) 136 137 if test "x$matroska_prefix" != "x"; then 138 matroska_args="$matroska_args --prefix=$matroska_prefix" 139 if test "x$matroska_include" != "x"; then 140 MATROSKA_CFLAGS="-I$matroska_include" 141 else 142 MATROSKA_CFLAGS="-I$matroska_prefix/include/matroska" 143 fi 144 if test "x$matroska_lib" != "x"; then 145 MATROSKA_LIBS="-L$matroska_lib" 146 else 147 MATROSKA_LIBS="-L$matroska_prefix/lib" 148 fi 149 elif test "x$prefix" != "xNONE"; then 150 matroska_args="$matroska_args --prefix=$prefix" 151 if test "x$matroska_include" != "x"; then 152 MATROSKA_CFLAGS="-I$matroska_include" 153 else 154 MATROSKA_CFLAGS="-I$prefix/include/matroska" 155 fi 156 if test "x$matroska_lib" != "x"; then 157 MATROSKA_LIBS="-L$matroska_lib" 158 else 159 MATROSKA_LIBS="-L$prefix/lib" 160 fi 161 else 162 if test "x$matroska_include" != "x"; then 163 MATROSKA_CFLAGS="-I$matroska_include" 164 else 165 MATROSKA_CFLAGS="-I/usr/include/matroska -I/usr/local/include/matroska" 166 fi 167 if test "x$matroska_lib" != "x"; then 168 MATROSKA_LIBS="-L$matroska_lib" 169 else 170 MATROSKA_LIBS="-L/usr/local/lib" 171 fi 172 fi 173 174 MATROSKA_LIBS="$MATROSKA_LIBS -lmatroska" 175 176 AC_MSG_CHECKING(for Matroska) 177 no_matroska="" 178 179 180 if test "x$enable_matroskatest" = "xyes" ; then 181 ac_save_CXXFLAGS="$CXXFLAGS" 182 ac_save_LIBS="$LIBS" 183 CXXFLAGS="$CXXFLAGS $MATROSKA_CFLAGS $EBML_CFLAGS" 184 LIBS="$LIBS $MATROSKA_LIBS $EBML_LIBS" 185dnl 186dnl Now check if the installed Matroska is sufficiently new. 187dnl 188 rm -f conf.matroskatest 189 AC_LANG_CPLUSPLUS 190 AC_TRY_RUN([ 191#include <stdio.h> 192#include <stdlib.h> 193#include <string.h> 194#include <EbmlConfig.h> 195#include <KaxVersion.h> 196 197using namespace LIBMATROSKA_NAMESPACE; 198 199int main () 200{ 201 FILE *f; 202 f = fopen("conf.matroskatest", "wb"); 203 if (f == NULL) 204 return 1; 205 fprintf(f, "%s\n", KaxCodeVersion.c_str()); 206 fclose(f); 207 return 0; 208} 209 210],, no_matroska=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) 211 AC_LANG_C 212 CXXFLAGS="$ac_save_CXXFLAGS" 213 LIBS="$ac_save_LIBS" 214 fi 215 216 if test "x$no_matroska" = "x" -a -f conf.matroskatest ; then 217 AC_MSG_RESULT(yes) 218 219 AC_MSG_CHECKING(Matroska version) 220 221 matroska_version=`cat conf.matroskatest` 222 mk_MAJVER=`echo $1 | cut -d"." -f1` 223 mk_MINVER=`echo $1 | cut -d"." -f2` 224 mk_RELVER=`echo $1 | cut -d"." -f3` 225 mver_ok=`sed 's;\.;\ ;g' < conf.matroskatest | (read -a mver 226 if test ${mver[[0]]} -gt $mk_MAJVER ; then 227 mver_ok=1 228 elif test ${mver[[0]]} -lt $mk_MAJVER ; then 229 mver_ok=0 230 else 231 if test ${mver[[1]]} -gt $mk_MINVER ; then 232 mver_ok=1 233 elif test ${mver[[1]]} -lt $mk_MINVER ; then 234 mver_ok=0 235 else 236 if test ${mver[[2]]} -ge $mk_RELVER ; then 237 mver_ok=1 238 else 239 mver_ok=0 240 fi 241 fi 242 fi 243 echo $mver_ok )` 244 if test "$mver_ok" = "1" ; then 245 AC_MSG_RESULT($matroska_version ok) 246 ifelse([$2], , :, [$2]) 247 else 248 AC_MSG_RESULT($matroska_version too old) 249 echo '*** Your Matroska version is too old. Upgrade to at least version' 250 echo '*** $1 and re-run configure.' 251 ifelse([$3], , :, [$3]) 252 fi 253 254 else 255 AC_MSG_RESULT(no) 256 ifelse([$3], , :, [$3]) 257 fi 258 259 AC_SUBST(MATROSKA_CFLAGS) 260 AC_SUBST(MATROSKA_LIBS) 261 rm -f conf.matroskatest 262]) 263