[FFmpeg-devel] [PATCH 2/3] build: rely on pkg-config for libx264 probing
Clément Bœsch
u at pkh.me
Thu Aug 28 14:30:15 CEST 2014
On Thu, Aug 21, 2014 at 02:34:42PM +0200, Clément Bœsch wrote:
> On Thu, Aug 21, 2014 at 02:24:40PM +0200, Clément Bœsch wrote:
> > On Thu, Aug 21, 2014 at 12:16:35PM +0000, Carl Eugen Hoyos wrote:
> > > Clément Bœsch <u <at> pkh.me> writes:
> > >
> > > [...]
> > >
> > > Sorry, I seem to have lost track of what you fear
> > > will not work if pkg-config is used for x264
> > > detection but will fallback to the current
> > > system if pkg-config does not find the right
> > > version.
> >
> > It's simple really. You said earlier:
> >
> > > > or do you actually want a real fallback when it is
> > > > present but didn't succeed?
> > >
> > > This is the preferred solution imo.
> >
> > In this case, if pkg-config finds the system install, it will not honor
> > the user c/ld flags but the one from pkg-config.
> >
>
> BTW, now that I think of it, depending on where the --extra-{ld,cflags}
> are added in the compilation and linker flag, they *might* allow you to
> trick the detection.
>
> Did you try the patch with pkg-config only detection?
>
> And try to add --pkg-config=true to trick the detect function.
>
So, I did try myself, and it does the trick. Here is a new proposed diff
(will submit patches from it):
diff --git a/RELEASE_NOTES b/RELEASE_NOTES
index 3fbf556..3f7a432 100644
--- a/RELEASE_NOTES
+++ b/RELEASE_NOTES
@@ -51,3 +51,4 @@
• dctdnoiz filter now uses a block size of 8x8 instead of 16x16 by default
• -vismv option is deprecated in favor of the codecview filter
+ • libx264 is now detected through pkg-config
diff --git a/configure b/configure
index 8e5f49b..03e9108 100755
--- a/configure
+++ b/configure
@@ -408,6 +408,7 @@ warn(){
}
die(){
+ test -n "$WARNINGS" && printf "\n$WARNINGS"
echolog "$@"
cat <<EOF
@@ -1091,6 +1092,10 @@ check_pkg_config(){
headers="$2"
funcs="$3"
shift 3
+ if ! $pkg_config --version >/dev/null 2>&1; then
+ warn "$pkg_config not found but $pkg library detection relies on it"
+ return 1
+ fi
check_cmd $pkg_config --exists --print-errors $pkgandversion || return
pkg_cflags=$($pkg_config --cflags $pkg_config_flags $pkg)
pkg_libs=$($pkg_config --libs $pkg_config_flags $pkg)
@@ -1198,8 +1203,18 @@ require_cpp(){
}
require_pkg_config(){
- pkg="$1"
- check_pkg_config "$@" || die "ERROR: $pkg not found"
+ pkgandversion="$1"
+ pkg="${1%% *}"
+ if ! $pkg_config --version >/dev/null 2>&1; then
+ cat <<EOF
+ERROR: $pkg_config not found but $pkg detection relies on it.
+ You should either install pkg-config (recommended), or use
+ --pkg-config=true with the $pkg linker flags specified through
+ --extra-ldflags.
+EOF
+ die
+ fi
+ check_pkg_config "$@" || die "ERROR: $pkgandversion not found"
add_cflags $(get_safe ${pkg}_cflags)
add_extralibs $(get_safe ${pkg}_libs)
}
@@ -3038,11 +3053,6 @@ set_default arch cc cxx doxygen pkg_config ranlib strip sysinclude \
enabled cross_compile || host_cc_default=$cc
set_default host_cc
-if ! $pkg_config --version >/dev/null 2>&1; then
- warn "$pkg_config not found, library detection may fail."
- pkg_config=false
-fi
-
if test $doxygen != $doxygen_default && \
! $doxygen --version >/dev/null 2>&1; then
warn "Specified doxygen \"$doxygen\" not found, API documentation will fail to build."
@@ -4851,9 +4861,7 @@ enabled libwavpack && require libwavpack wavpack/wavpack.h WavpackOpenFil
enabled libwebp && require_pkg_config libwebp webp/encode.h WebPGetEncoderVersion &&
{ check_code cc webp/encode.h "WebPPicture wp; wp.use_argb++" ||
die "ERROR: libwebp too old."; }
-enabled libx264 && require libx264 x264.h x264_encoder_encode -lx264 &&
- { check_cpp_condition x264.h "X264_BUILD >= 118" ||
- die "ERROR: libx264 must be installed and version must be >= 0.118."; }
+enabled libx264 && require_pkg_config "x264 >= 0.118" "stdint.h x264.h" x264_encoder_encode
enabled libx265 && require_pkg_config x265 x265.h x265_encoder_encode &&
{ check_cpp_condition x265.h "X265_BUILD >= 17" ||
die "ERROR: libx265 version must be >= 17."; }
And basically, this is what happens:
• If you don't have the required x264 (but pkg-config):
[~/src/ffmpeg]☭ dash ./configure --disable-everything --enable-gpl --enable-libx264
ERROR: x264 >= 999.118 not found
If you think configure made a mistake, make sure you are using the latest
version from Git. If the latest version fails, report the problem to the
ffmpeg-user at ffmpeg.org mailing list or IRC #ffmpeg on irc.freenode.net.
Include the log file "config.log" produced by configure as this will help
solve the problem.
• If you don't have pkg-config:
[~/src/ffmpeg]☭ dash ./configure --disable-everything --enable-gpl --enable-libx264 --pkg-config=pkg-config-nope
ERROR: pkg-config-nope not found but x264 detection relies on it.
You should either install pkg-config (recommended), or use
--pkg-config=true with the x264 linker flags specified through
--extra-ldflags.
If you think configure made a mistake, make sure you are using the latest
version from Git. If the latest version fails, report the problem to the
ffmpeg-user at ffmpeg.org mailing list or IRC #ffmpeg on irc.freenode.net.
Include the log file "config.log" produced by configure as this will help
solve the problem.
• Following the instructions above in case you don't want to use pkg-config:
[~/src/ffmpeg]☭ dash ./configure --disable-everything --enable-gpl --enable-libx264 --pkg-config=/bin/true --extra-ldflags=-lx264
Anyway, the patch also includes stuff like printing the warnings when a die
occurs, and warning more appropriately when the pkg-config detection might be
helpful but is not mandatory.
Carl, this is should honor your concerns. Please comment.
--
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 473 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20140828/26b36871/attachment.asc>
More information about the ffmpeg-devel
mailing list