aboutsummaryrefslogtreecommitdiff
path: root/autosetup
diff options
context:
space:
mode:
authorSteve Bennett <steveb@workware.net.au>2020-12-30 11:39:05 +1000
committerSteve Bennett <steveb@workware.net.au>2021-01-01 16:54:24 +1000
commit3b834e42ee5887f85d10d7e50814b29d1b81a09f (patch)
tree7458adbd80a56028addff1b879d726187d4fe81b /autosetup
parent982ec4f524bc81a240cb729cf09bd3c677aea485 (diff)
downloadjimtcl-3b834e42ee5887f85d10d7e50814b29d1b81a09f.zip
jimtcl-3b834e42ee5887f85d10d7e50814b29d1b81a09f.tar.gz
jimtcl-3b834e42ee5887f85d10d7e50814b29d1b81a09f.tar.bz2
sdl: Add support for SDL2
Now we only support using pkg-config to find SDL, and prefer SDL2 over SDL. For compatibility between versions, the render surface is now cleared on flip. And closing the window now results in a JIM_EXIT return code from flip. Also supports [sdl clear] to clear the background to a given colour. Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'autosetup')
-rw-r--r--autosetup/local.tcl57
1 files changed, 43 insertions, 14 deletions
diff --git a/autosetup/local.tcl b/autosetup/local.tcl
index ba2bb3d..c31ba18 100644
--- a/autosetup/local.tcl
+++ b/autosetup/local.tcl
@@ -59,13 +59,34 @@ proc check-extension-status {ext required {asmodule 0}} {
set use_pkgconfig 0
set pkgconfig [ext-get $ext pkg-config]
if {$pkgconfig ne ""} {
- # pkg-config support is optional, so explicitly initialse it here
+ # pkg-config support is optional, so explicitly initialise 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
+ # Check for at least one set of alternates
+ foreach pinfo [split $pkgconfig |] {
+ set ok 1
+ set pkgs {}
+ foreach pkg [split $pinfo ,] {
+ set args [lassign $pkg pkgname]
+ set pkg [string trim $pkg]
+ set optional 0
+ if {[string match {*[*]} $pkg]} {
+ # This package is optional
+ set optional 1
+ set pkg [string range $pkg 0 end-1]
+ }
+ if {![pkg-config $pkg {*}$args]} {
+ if {!$optional} {
+ set ok 0
+ break
+ }
+ } else {
+ lappend pkgs $pkg
+ }
+ }
+ if {$ok} {
+ set use_pkgconfig 1
+ break
+ }
}
}
}
@@ -124,10 +145,7 @@ proc check-extension-status {ext required {asmodule 0}} {
} else {
msg-result "Extension $ext...module"
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]
- define-append PKG_CONFIG_REQUIRES $pkg
+ add-pkgconfig-deps $ext $pkgs $asmodule
} else {
foreach i [ext-get $ext libdep] {
define-append LDLIBS_$ext [get-define $i ""]
@@ -149,10 +167,7 @@ proc check-extension-status {ext required {asmodule 0}} {
return [ext-set-status $ext x]
}
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]
- define-append PKG_CONFIG_REQUIRES $pkg
+ add-pkgconfig-deps $ext $pkgs $asmodule
} else {
foreach i [ext-get $ext libdep] {
define-append LDLIBS [get-define $i ""]
@@ -161,6 +176,20 @@ proc check-extension-status {ext required {asmodule 0}} {
return [ext-set-status $ext y]
}
+# Add dependencies for a pkg-config module to the extension
+proc add-pkgconfig-deps {ext pkgs asmodule} {
+ foreach pkg $pkgs {
+ if {$asmodule} {
+ define-append LDLIBS_$ext [pkg-config-get $pkg LIBS]
+ } else {
+ define-append LDLIBS [pkg-config-get $pkg LIBS]
+ }
+ define-append LDFLAGS [pkg-config-get $pkg LDFLAGS]
+ define-append CCOPTS [pkg-config-get $pkg CFLAGS]
+ define-append PKG_CONFIG_REQUIRES $pkg
+ }
+}
+
# Examines the user options (the $withinfo array)
# and the extension database ($extdb) to determine
# what is selected, and in what way.