From 55ef898d62bb944b1dd995e334c08980c75a8c45 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Sun, 14 Nov 2004 12:14:16 +0000 Subject: [PATCH] Made the checks for libebml and libmatroska work for cross-compilation, too. Also check if EBML_DLL and MATROSKA_DLL have to be defined. --- configure.in | 321 +++++++++++++++++++++++++-------------------------- 1 file changed, 160 insertions(+), 161 deletions(-) diff --git a/configure.in b/configure.in index 257092354..605771d83 100644 --- a/configure.in +++ b/configure.in @@ -411,111 +411,108 @@ dnl ebml_ver_req_micro=3 AC_CACHE_CHECK([for libebml version >= ${ebml_ver_req_major}.${ebml_ver_req_minor}.${ebml_ver_req_micro}], - [ac_cv_ebml_version],[ + [ac_cv_ebml_found],[ - EBML_LIBS="-lebml" - ac_save_CXXFLAGS="$CXXFLAGS" - ac_save_LIBS="$LIBS" - LIBS="$LIBS $EBML_LIBS" - rm -f conf.ebmltest - AC_LANG_PUSH(C++) - AC_TRY_RUN([ -#include -#include -#include + EBML_LIBS="-lebml" + ac_save_CXXFLAGS="$CXXFLAGS" + ac_save_LIBS="$LIBS" + LIBS="$LIBS $EBML_LIBS" + AC_LANG_PUSH(C++) + AC_TRY_COMPILE([ #include #include using namespace libebml; -int main () -{ - EbmlDummy d; - FILE *f; - f = fopen("conf.ebmltest", "wb"); - if (f == NULL) - return 1; - fprintf(f, "%s\n", EbmlCodeVersion.c_str()); - fclose(f); - return 0; -} +#if LIBEBML_VERSION < (${ebml_ver_req_major} << 16 + ${ebml_ver_req_minor} << 8 + ${ebml_ver_req_micro}) +# error libebml is too old +#endif + ], + [], + ac_cv_ebml_found=yes, + ac_cv_ebml_found=no) -],ebml_found=yes,ebml_found=no,) - - if test "$ebml_found" = "no" ; then - EBML_CFLAGS="-I/usr/local/include" - EBML_LIBS="-L/usr/local/lib $EBML_LIBS" - CXXFLAGS="-I/usr/local/include $CXXFLAGS" - LIBS="-L/usr/local/lib $LIBS" - AC_TRY_RUN([ -#include -#include -#include + if test "${ac_cv_ebml_found}" = "no" ; then + EBML_CFLAGS="-I/usr/local/include" + EBML_LIBS="-L/usr/local/lib $EBML_LIBS" + CXXFLAGS="-I/usr/local/include $CXXFLAGS" + LIBS="-L/usr/local/lib $LIBS" + AC_TRY_COMPILE([ #include #include using namespace libebml; -int main () -{ - EbmlDummy d; - FILE *f; - f = fopen("conf.ebmltest", "wb"); - if (f == NULL) - return 1; - fprintf(f, "%s\n", EbmlCodeVersion.c_str()); - fclose(f); - return 0; -} +#if LIBEBML_VERSION < (${ebml_ver_req_major} << 16 + ${ebml_ver_req_minor} << 8 + ${ebml_ver_req_micro}) +# error libebml is too old +#endif + ], + [], + ac_cv_ebml_found=yes, + ac_cv_ebml_found=no) + fi -],ebml_found=yes,ebml_found=no,) - fi - AC_LANG_POP - CXXFLAGS="$ac_save_CXXFLAGS" - LIBS="$ac_save_LIBS" - - if test "$ebml_found" = "yes" -a -f conf.ebmltest ; then - ac_cv_ebml_version=`cat conf.ebmltest` - else - ac_cv_ebml_version="not found" - fi - rm -f conf.ebmltest + AC_LANG_POP + CXXFLAGS="$ac_save_CXXFLAGS" + LIBS="$ac_save_LIBS" ]) - if test x"$ac_cv_ebml_version" = "xnot found" -o x"$ac_cv_ebml_version" = x; then - echo '*** The EBML library was not found.' - exit 1 - fi - - set - `echo $ac_cv_ebml_version | sed 's/\./\ /g'` - if test "x$1" = "x" -o $1 -lt ${ebml_ver_req_major} ; then - mver_ok=0 - elif test $1 -gt ${ebml_ver_req_major} ; then - mver_ok=1 - else - if test "x$2" = "x" -o $2 -lt ${ebml_ver_req_minor} ; then - mver_ok=0 - elif test $2 -gt ${ebml_ver_req_minor} ; then - mver_ok=1 - else - if test "x$3" = "x" -o $3 -lt ${ebml_ver_req_micro} ; then - mver_ok=0 - else - mver_ok=1 - fi - fi - fi - if test $mver_ok -ne 1 ; then + if test x"${ac_cv_ebml_found}" != "xyes" ; then echo '*** Your Ebml version is too old. Upgrade to at least version' echo '*** '${ebml_ver_req_major}.${ebml_ver_req_minor}.${ebml_ver_req_micro}' and re-run configure.' exit 1 fi +dnl +dnl Test if libebml has to be compiled with -DEBML_DLL on Windows. +dnl + AC_CACHE_CHECK([if linking against libebml requires -DEBML_DLL], + [ac_cv_ebml_dll],[ + AC_LANG_PUSH(C++) + ac_save_CXXFLAGS="$CXXFLAGS" + ac_save_LIBS="$LIBS" + CXXFLAGS="$CXXFLAGS $EBML_CFLAGS" + LIBS="$LIBS $EBML_LIBS" + AC_TRY_LINK([ +#include +#include + +using namespace libebml; + ], + [EbmlDummy d;], + ac_cv_ebml_dll=no, + ac_cv_ebml_dll="not found") + + if test x"${ac_cv_mingw32}" = "xyes" ; then + if test x"${ac_cv_ebml_dll}" != "xno" ; then + CXXFLAGS="$CXXFLAGS -DEBML_DLL" + AC_TRY_LINK([ +#include +#include + +using namespace libebml; + ], + [EbmlDummy d;], + ac_cv_ebml_dll=yes) + fi + fi + AC_LANG_POP + CXXFLAGS="${ac_save_CXXFLAGS}" + LIBS="${ac_save_LIBS}" + ]) + + if test x"${ac_cv_ebml_dll}" != "xyes" -a x"${ac_cv_ebml_dll}" != "xno" ; then + echo *** libebml was not found. + exit 1 + fi + + if test x"${ac_cv_ebml_dll}" = "xyes" ; then + EBML_CFLAGS="$EBML_CFLAGS -DEBML_DLL" + fi + AC_SUBST(EBML_CFLAGS) AC_SUBST(EBML_LIBS) - - dnl dnl Test for libmatroska, and define MATROSKA_CFLAGS and MATROSKA_LIBS dnl @@ -523,106 +520,108 @@ dnl kax_ver_req_minor=7 kax_ver_req_micro=4 - AC_CACHE_CHECK([for libmatroska version >= ${kax_ver_req_major}.${kax_ver_req_minor}.${kax_ver_req_micro}],[ac_cv_matroska_version],[ - MATROSKA_LIBS="-lmatroska" - ac_save_CXXFLAGS="$CXXFLAGS" - ac_save_LIBS="$LIBS" - CXXFLAGS="$CFLAGS $MATROSKA_CFLAGS" - LIBS="$LIBS $MATROSKA_LIBS $EBML_LIBS" - rm -f conf.matroskatest - AC_LANG_PUSH(C++) - AC_TRY_RUN([ -#include -#include + AC_CACHE_CHECK([for libmatroska version >= ${kax_ver_req_major}.${kax_ver_req_minor}.${kax_ver_req_micro}], + [ac_cv_matroska_found], + [ + + MATROSKA_LIBS="-lmatroska" + ac_save_CXXFLAGS="$CXXFLAGS" + ac_save_LIBS="$LIBS" + CXXFLAGS="$CFLAGS $MATROSKA_CFLAGS" + LIBS="$LIBS $MATROSKA_LIBS $EBML_LIBS" + rm -f conf.matroskatest + AC_LANG_PUSH(C++) + AC_TRY_COMPILE([ #include #include #include using namespace libmatroska; -int main () -{ - KaxTracks tracks; - FILE *f; - f = fopen("conf.matroskatest", "wb"); - if (f == NULL) - return 1; - fprintf(f, "%s\n", KaxCodeVersion.c_str()); - fclose(f); - return 0; -} +#if LIBMATROSKA_VERSION < (${kax_ver_req_major} << 16 + ${kax_ver_req_minor} << 8 + ${kax_ver_req_micro}) +# error libmatroska is too old +#endif + ], + [], + ac_cv_matroska_found=yes, + ac_cv_matroska_found=no) -],matroska_found=yes,matroska_found=no,) - if test "$matroska_found" = "no" ; then - MATROSKA_CFLAGS="-I/usr/local/include" - MATROSKA_LIBS="-L/usr/local/lib $MATROSKA_LIBS" - CXXFLAGS="-I/usr/local/include $CXXFLAGS" - LIBS="-L/usr/local/lib $LIBS" - AC_TRY_RUN([ -#include -#include + if test x"${ac_cv_matroska_found}" != "xyes" ; then + MATROSKA_CFLAGS="-I/usr/local/include" + MATROSKA_LIBS="-L/usr/local/lib $MATROSKA_LIBS" + CXXFLAGS="-I/usr/local/include $CXXFLAGS" + LIBS="-L/usr/local/lib $LIBS" + AC_TRY_COMPILE([ #include #include #include using namespace libmatroska; -int main () -{ - KaxTracks tracks; - FILE *f; - f = fopen("conf.matroskatest", "wb"); - if (f == NULL) - return 1; - fprintf(f, "%s\n", KaxCodeVersion.c_str()); - fclose(f); - return 0; -} +#if LIBMATROSKA_VERSION < (${kax_ver_req_major} << 16 + ${kax_ver_req_minor} << 8 + ${kax_ver_req_micro}) +# error libmatroska is too old +#endif + ], + [], + ac_cv_matroska_found=yes, + ac_cv_matroska_found=no) + fi -],matroska_found=yes,matroska_found=no,) - fi - AC_LANG_POP - CXXFLAGS="$ac_save_CXXFLAGS" - LIBS="$ac_save_LIBS" - - if test "$matroska_found" = "yes" -a -f conf.matroskatest ; then - ac_cv_matroska_version=`cat conf.matroskatest` - else - ac_cv_matroska_version="not found" - fi - rm -f conf.matroskatest + AC_LANG_POP + CXXFLAGS="$ac_save_CXXFLAGS" + LIBS="$ac_save_LIBS" ]) - if test x"$ac_cv_matroska_version" = "xnot found" -o x"$ac_cv_matroska_version" = x ; then - echo '*** The Matroska library was not found.' - exit 1 - fi - - set - `echo $ac_cv_matroska_version | sed 's/\./\ /g'` - if test "x$1" = "x" -o $1 -lt ${kax_ver_req_major} ; then - mver_ok=0 - elif test $1 -gt ${kax_ver_req_major} ; then - mver_ok=1 - else - if test "x$2" = "x" -o $2 -lt ${kax_ver_req_minor} ; then - mver_ok=0 - elif test $2 -gt ${kax_ver_req_minor} ; then - mver_ok=1 - else - if test "x$3" = "x" -o $3 -lt ${kax_ver_req_micro} ; then - mver_ok=0 - else - mver_ok=1 - fi - fi - fi - - if test $mver_ok -ne 1 ; then + if test x"${ac_cv_matroska_found}" != "xyes" ; then echo '*** Your Matroska version is too old. Upgrade to at least version' echo '*** '${kax_ver_req_major}.${kax_ver_req_minor}.${kax_ver_req_micro}' and re-run configure.' exit 1 fi + AC_CACHE_CHECK([if linking against libmatroska requires -DMATROSKA_DLL], + [ac_cv_matroska_dll],[ + AC_LANG_PUSH(C++) + ac_save_CXXFLAGS="$CXXFLAGS" + ac_save_LIBS="$LIBS" + CXXFLAGS="$CXXFLAGS $EBML_CFLAGS $MATROSKA_CFLAGS" + LIBS="$LIBS $MATROSKA_LIBS $EBML_LIBS" + AC_TRY_LINK([ +#include +#include + +using namespace libmatroska; + ], + [KaxSegment s;], + ac_cv_matroska_dll=no, + ac_cv_matroska_dll="not found") + + if test x"${ac_cv_mingw32}" = "xyes" ; then + if test x"${ac_cv_matroska_dll}" != "xno" ; then + CXXFLAGS="$CXXFLAGS -DMATROSKA_DLL" + AC_TRY_LINK([ +#include +#include + +using namespace libmatroska; + ], + [KaxSegment s;], + ac_cv_matroska_dll=yes) + fi + fi + AC_LANG_POP + CXXFLAGS="${ac_save_CXXFLAGS}" + LIBS="${ac_save_LIBS}" + ]) + + if test x"${ac_cv_matroska_dll}" != "xyes" -a x"${ac_cv_matroska_dll}" != "xno" ; then + echo *** libmatroska was not found. + exit 1 + fi + + if test x"${ac_cv_matroska_dll}" = "xyes" ; then + MATROSKA_CFLAGS="$MATROSKA_CFLAGS -DMATROSKA_DLL" + fi + AC_SUBST(MATROSKA_CFLAGS) AC_SUBST(MATROSKA_LIBS)