Browse code

configure: add optional pkg-config helper and use it.

The require variant dies if the package is not present.
The check variant does not import the flags to the used list.
The new variant imports the flags if the package is present
but does not die if it is not.
The new call graph is: require -> use -> check.

Use use_pkg_config for libx264 and libsmbclient: more readable
and three external call less per library.

Nicolas George authored on 2014/12/02 21:29:47
Showing 1 changed files
... ...
@@ -1203,13 +1203,17 @@ require_cpp(){
1203 1203
     check_lib_cpp "$headers" "$classes" "$@" || die "ERROR: $name not found"
1204 1204
 }
1205 1205
 
1206
-require_pkg_config(){
1206
+use_pkg_config(){
1207 1207
     pkg="$1"
1208
-    check_pkg_config "$@" || die "ERROR: $pkg not found"
1208
+    check_pkg_config "$@" || return 1
1209 1209
     add_cflags    $(get_safe ${pkg}_cflags)
1210 1210
     add_extralibs $(get_safe ${pkg}_libs)
1211 1211
 }
1212 1212
 
1213
+require_pkg_config(){
1214
+    use_pkg_config "$@" || die "ERROR: $pkg not found"
1215
+}
1216
+
1213 1217
 require_libfreetype(){
1214 1218
     log require_libfreetype "$@"
1215 1219
     pkg="freetype2"
... ...
@@ -4875,9 +4879,8 @@ enabled libquvi           && require_pkg_config libquvi quvi/quvi.h quvi_init
4875 4875
 enabled librtmp           && require_pkg_config librtmp librtmp/rtmp.h RTMP_Socket
4876 4876
 enabled libschroedinger   && require_pkg_config schroedinger-1.0 schroedinger/schro.h schro_init
4877 4877
 enabled libshine          && require_pkg_config shine shine/layer3.h shine_encode_buffer
4878
-enabled libsmbclient      && { { check_pkg_config smbclient libsmbclient.h smbc_init &&
4879
-                                 require_pkg_config smbclient libsmbclient.h smbc_init; } ||
4880
-                                 require smbclient libsmbclient.h smbc_init -lsmbclient; }
4878
+enabled libsmbclient      && { check_pkg_config smbclient libsmbclient.h smbc_init ||
4879
+                               require smbclient libsmbclient.h smbc_init -lsmbclient; }
4881 4880
 enabled libsoxr           && require libsoxr soxr.h soxr_create -lsoxr
4882 4881
 enabled libssh            && require_pkg_config libssh libssh/sftp.h sftp_init
4883 4882
 enabled libspeex          && require_pkg_config speex speex/speex.h speex_decoder_init -lspeex
... ...
@@ -4903,8 +4906,7 @@ enabled libvpx            && {
4903 4903
     enabled libvpx_vp9_encoder && { check_lib2 "vpx/vpx_encoder.h vpx/vp8cx.h" "vpx_codec_vp9_cx VP9E_SET_AQ_MODE" -lvpx || disable libvpx_vp9_encoder; } }
4904 4904
 enabled libwavpack        && require libwavpack wavpack/wavpack.h WavpackOpenFileOutput  -lwavpack
4905 4905
 enabled libwebp           && require_pkg_config "libwebp >= 0.2.0" webp/encode.h WebPGetEncoderVersion
4906
-enabled libx264           && { { check_pkg_config x264 "stdint.h x264.h" x264_encoder_encode &&
4907
-                                 require_pkg_config x264 "stdint.h x264.h" x264_encoder_encode; } ||
4906
+enabled libx264           && { use_pkg_config x264 "stdint.h x264.h" x264_encoder_encode ||
4908 4907
                                { require libx264 x264.h x264_encoder_encode -lx264 &&
4909 4908
                                  warn "using libx264 without pkg-config"; } } &&
4910 4909
                              { check_cpp_condition x264.h "X264_BUILD >= 118" ||