123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169 |
- use cc
- options {
- sysroot:dir => "Override compiler sysroot for pkg-config search path"
- }
- proc pkg-config-init {{required 1}} {
- if {[is-defined HAVE_PKG_CONFIG]} {
- return [get-define HAVE_PKG_CONFIG]
- }
- set found 0
- define PKG_CONFIG [get-env PKG_CONFIG pkg-config]
- msg-checking "Checking for pkg-config..."
- if {[catch {exec [get-define PKG_CONFIG] --version} version]} {
- msg-result "[get-define PKG_CONFIG] (not found)"
- if {$required} {
- user-error "No usable pkg-config"
- }
- } else {
- msg-result $version
- define PKG_CONFIG_VERSION $version
- set found 1
- if {[opt-str sysroot o]} {
- define SYSROOT [file-normalize $o]
- msg-result "Using specified sysroot [get-define SYSROOT]"
- } elseif {[get-define build] ne [get-define host]} {
- if {[catch {exec-with-stderr {*}[get-define CC] -print-sysroot} result errinfo] == 0} {
-
- define SYSROOT $result
- msg-result "Found compiler sysroot $result"
- } else {
- configlog "[get-define CC] -print-sysroot: $result"
- set msg "pkg-config: Cross compiling, but no compiler sysroot and no --sysroot supplied"
- if {$required} {
- user-error $msg
- } else {
- msg-result $msg
- }
- set found 0
- }
- }
- if {[is-defined SYSROOT]} {
- set sysroot [get-define SYSROOT]
-
- global env
- set env(PKG_CONFIG_DIR) ""
-
-
- set env(PKG_CONFIG_PATH) ""
-
- set env(PKG_CONFIG_LIBDIR) $sysroot/usr/lib/pkgconfig:$sysroot/usr/share/pkgconfig
- set env(PKG_CONFIG_SYSROOT_DIR) $sysroot
- }
- }
- define HAVE_PKG_CONFIG $found
- return $found
- }
- proc pkg-config {module args} {
- set ok [pkg-config-init]
- msg-checking "Checking for $module $args..."
- if {!$ok} {
- msg-result "no pkg-config"
- return 0
- }
- set pkgconfig [get-define PKG_CONFIG]
- set ret [catch {exec $pkgconfig --modversion "$module $args"} version]
- configlog "$pkgconfig --modversion $module $args: $version"
- if {$ret} {
- msg-result "not found"
- return 0
- }
-
-
- set ret [catch {exec $pkgconfig --cflags $module} cflags]
- if {$ret} {
- msg-result "unusable ($version - see config.log)"
- configlog "$pkgconfig --cflags $module"
- configlog $cflags
- return 0
- }
- msg-result $version
- set prefix [feature-define-name $module PKG_]
- define HAVE_${prefix}
- define ${prefix}_VERSION $version
- define ${prefix}_CFLAGS $cflags
- define ${prefix}_LIBS [exec $pkgconfig --libs-only-l $module]
- define ${prefix}_LDFLAGS [exec $pkgconfig --libs-only-L $module]
- return 1
- }
- proc pkg-config-get {module name} {
- set prefix [feature-define-name $module PKG_]
- get-define ${prefix}_${name} ""
- }
- proc pkg-config-get-var {module variable} {
- set pkgconfig [get-define PKG_CONFIG]
- set prefix [feature-define-name $module HAVE_PKG_]
- exec $pkgconfig $module --variable $variable
- }
|