diff options
author | Steve Bennett <steveb@workware.net.au> | 2016-08-27 20:22:46 +1000 |
---|---|---|
committer | Steve Bennett <steveb@workware.net.au> | 2016-08-28 13:01:31 +1000 |
commit | bf354111c9372a562370234a6c60d4acc7b40c19 (patch) | |
tree | a4dea941e42d40d3d2a09021977b4b2eea4312e9 | |
parent | 339204cccb2930435552f296fe5b9184ad6836af (diff) | |
download | jimtcl-bf354111c9372a562370234a6c60d4acc7b40c19.zip jimtcl-bf354111c9372a562370234a6c60d4acc7b40c19.tar.gz jimtcl-bf354111c9372a562370234a6c60d4acc7b40c19.tar.bz2 |
configure: Use pkg-config if possible
Use the new pkg-config support in autosetup to search for certain
packages such as sqlite3 and sdl
-rw-r--r-- | auto.def | 10 | ||||
-rw-r--r-- | autosetup/local.tcl | 49 | ||||
-rw-r--r-- | jim-sdl.c | 4 |
3 files changed, 44 insertions, 19 deletions
@@ -4,7 +4,7 @@ define JIM_VERSION 76 # Note: modules which support options *must* be included before 'options' -use cc cc-shared cc-db cc-lib +use cc cc-shared cc-db cc-lib pkg-config use local options { @@ -280,15 +280,15 @@ dict set extdb info { namespace { dep nshelper } posix { check {[have-feature waitpid]} } readdir { check {[have-feature opendir]} } - readline { check {[cc-check-function-in-lib readline readline]} libdep lib_readline} + readline { pkg-config readline check {[cc-check-function-in-lib readline readline]} libdep lib_readline} rlprompt { dep readline } tree { dep oo } - sdl { check {[cc-check-function-in-lib SDL_SetVideoMode SDL] && [cc-check-function-in-lib rectangleRGBA SDL_gfx]} + sdl { pkg-config SDL_gfx check {[cc-check-function-in-lib SDL_SetVideoMode SDL] && [cc-check-function-in-lib rectangleRGBA SDL_gfx]} libdep {lib_SDL_SetVideoMode lib_rectangleRGBA} } signal { check {[have-feature sigaction] && [have-feature vfork]} } - sqlite3 { check {[cc-check-function-in-lib sqlite3_prepare_v2 sqlite3]} libdep lib_sqlite3_prepare_v2 } - zlib { check {[cc-check-function-in-lib deflate z]} libdep lib_deflate } + sqlite3 { pkg-config sqlite3 check {[cc-check-function-in-lib sqlite3_prepare_v2 sqlite3]} libdep lib_sqlite3_prepare_v2 } + zlib { pkg-config zlib check {[cc-check-function-in-lib deflate z]} libdep lib_deflate } syslog { check {[have-feature syslog]} } tree { dep oo } win32 { check {[have-feature windows]} } diff --git a/autosetup/local.tcl b/autosetup/local.tcl index a5da8b0..bf86c5c 100644 --- a/autosetup/local.tcl +++ b/autosetup/local.tcl @@ -1,5 +1,3 @@ -# The complex extension checking is done here. - global withinfo global extdb @@ -58,12 +56,27 @@ proc check-extension-status {ext required} { # Stash the current value of LIBS set LIBS [get-define LIBS] - # Check direct dependencies - if [ext-get $ext check 1] { - # "check" conditions are met - } else { - # not met - incr depinfo(n) + set use_pkgconfig 0 + set pkgconfig [ext-get $ext pkg-config] + if {$pkgconfig ne ""} { + # pkg-config support is optional, so explicitly initialse it here + if {[pkg-config-init 0]} { + lassign $pkgconfig pkg args + + if {[pkg-config {*}$pkgconfig]} { + # Found via pkg-config so ignore check and libdep + set use_pkgconfig 1 + } + } + } + if {!$use_pkgconfig} { + # Check direct dependencies + if [ext-get $ext check 1] { + # "check" conditions are met + } else { + # not met + incr depinfo(n) + } } if {$ext in $withinfo(mod)} { @@ -104,8 +117,14 @@ proc check-extension-status {ext required} { user-error "Extension $ext can't be a module" } else { msg-result "Extension $ext...module" - foreach i [ext-get $ext libdep] { - define-append LDLIBS_$ext [get-define $i ""] + if {$use_pkgconfig} { + define-append LDLIBS_$ext [pkg-config-get $pkg LIBS] + define-append LDFLAGS [pkg-config-get $pkg LDFLAGS] + define-append CCOPTS [pkg-config-get $pkg CFLAGS] + } else { + foreach i [ext-get $ext libdep] { + define-append LDLIBS_$ext [get-define $i ""] + } } } return [ext-set-status $ext m] @@ -122,8 +141,14 @@ proc check-extension-status {ext required} { # Could be selected, but isn't (yet) return [ext-set-status $ext x] } - foreach i [ext-get $ext libdep] { - define-append LDLIBS [get-define $i ""] + if {$use_pkgconfig} { + define-append LDLIBS [pkg-config-get $pkg LIBS] + define-append LDFLAGS [pkg-config-get $pkg LDFLAGS] + define-append CCOPTS [pkg-config-get $pkg CFLAGS] + } else { + foreach i [ext-get $ext libdep] { + define-append LDLIBS [get-define $i ""] + } } return [ext-set-status $ext y] } @@ -36,8 +36,8 @@ #include <stdlib.h> #include <string.h> #include <errno.h> -#include <SDL/SDL.h> -#include <SDL/SDL_gfxPrimitives.h> +#include <SDL.h> +#include <SDL_gfxPrimitives.h> #include <jim.h> |