From 979044a6595c7d01d14bca0360f0e94bb815af70 Mon Sep 17 00:00:00 2001 From: Anton Mitrofanov Date: Thu, 11 Feb 2021 21:10:31 +0300 Subject: [PATCH] mp4: Add GPAC detection with pkg-config --- configure | 35 +++++++++++++++++++++++++++-------- x264.c | 2 +- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/configure b/configure index e41664cd..fdac0581 100755 --- a/configure +++ b/configure @@ -124,6 +124,7 @@ cl_ldflags() { arg=${arg/pthreadGC/pthreadVC} [ "$arg" = avifil32.lib ] && arg=vfw32.lib [ "$arg" = gpac_static.lib ] && arg=libgpac_static.lib + [ "$arg" = gpac.lib ] && arg=libgpac.lib [ "$arg" = x264.lib ] && arg=libx264.lib [ -n "$arg" ] && echo -n "$arg " @@ -1244,15 +1245,32 @@ fi if [ "$gpac" = "auto" -a "$lsmash" != "yes" ] ; then gpac="no" - GPAC_LIBS="-lgpac_static" - cc_check "" -lz && GPAC_LIBS="$GPAC_LIBS -lz" - cc_check "" -ldl && GPAC_LIBS="$GPAC_LIBS -ldl" - if [ "$SYS" = "WINDOWS" ] ; then - cc_check "" -lws2_32 && GPAC_LIBS="$GPAC_LIBS -lws2_32" - cc_check "" -lwinmm && GPAC_LIBS="$GPAC_LIBS -lwinmm" + if pkg_check gpac ; then + GPAC_LIBS_TMP="$GPAC_LIBS $($PKGCONFIG --libs gpac)" + GPAC_CFLAGS_TMP="$GPAC_CFLAGS $($PKGCONFIG --cflags gpac)" + if cc_check gpac/isomedia.h "$GPAC_CFLAGS_TMP $GPAC_LIBS_TMP" "gf_isom_close(0);" ; then + GPAC_LIBS="$GPAC_LIBS_TMP" + GPAC_CFLAGS="$GPAC_CFLAGS_TMP" + else + GPAC_LIBS_TMP="$GPAC_LIBS $($PKGCONFIG --static --libs gpac | sed 's/-lgpac //')" + GPAC_CFLAGS_TMP="$GPAC_CFLAGS $($PKGCONFIG --static --cflags gpac)" + if cc_check gpac/isomedia.h "$GPAC_CFLAGS_TMP $GPAC_LIBS_TMP" "gf_isom_close(0);" ; then + GPAC_LIBS="$GPAC_LIBS_TMP" + GPAC_CFLAGS="$GPAC_CFLAGS_TMP" + fi + fi + fi + if [ -z "$GPAC_LIBS" ] ; then + GPAC_LIBS="-lgpac_static" + cc_check "" -lz && GPAC_LIBS="$GPAC_LIBS -lz" + cc_check "" -ldl && GPAC_LIBS="$GPAC_LIBS -ldl" + if [ "$SYS" = "WINDOWS" ] ; then + cc_check "" -lws2_32 && GPAC_LIBS="$GPAC_LIBS -lws2_32" + cc_check "" -lwinmm && GPAC_LIBS="$GPAC_LIBS -lwinmm" + fi fi - if cc_check gpac/isomedia.h "$GPAC_LIBS" "gf_isom_close(0);" ; then - if cc_check gpac/isomedia.h "$GPAC_LIBS" "gf_isom_set_pixel_aspect_ratio(0,0,0,0,0,0);" ; then + if cc_check gpac/isomedia.h "$GPAC_CFLAGS $GPAC_LIBS" "gf_isom_close(0);" ; then + if cc_check gpac/isomedia.h "$GPAC_CFLAGS $GPAC_LIBS" "gf_isom_set_pixel_aspect_ratio(0,0,0,0,0,0);" ; then gpac="yes" else echo "Warning: gpac is too old, update to v0.8.0 or later" @@ -1268,6 +1286,7 @@ if [ "$lsmash" = "yes" ] ; then elif [ "$gpac" = "yes" ] ; then mp4="gpac" LDFLAGSCLI="$GPAC_LIBS $LDFLAGSCLI" + CFLAGS="$CFLAGS $GPAC_CFLAGS" define HAVE_GPAC fi diff --git a/x264.c b/x264.c index 5ead60b0..88190d00 100644 --- a/x264.c +++ b/x264.c @@ -66,7 +66,7 @@ #endif #if HAVE_GPAC -#include +#include #endif #if HAVE_LSMASH -- 2.40.0