diff options
-rw-r--r-- | chickadee/audio/mpg123.scm | 2 | ||||
-rw-r--r-- | chickadee/audio/openal.scm | 2 | ||||
-rw-r--r-- | chickadee/audio/vorbis.scm | 2 | ||||
-rw-r--r-- | chickadee/config.scm.in | 26 | ||||
-rw-r--r-- | chickadee/freetype.scm | 2 |
5 files changed, 25 insertions, 9 deletions
diff --git a/chickadee/audio/mpg123.scm b/chickadee/audio/mpg123.scm index 20ff3ea..45c319a 100644 --- a/chickadee/audio/mpg123.scm +++ b/chickadee/audio/mpg123.scm @@ -89,7 +89,7 @@ ;;; (define mpg123-func - (let ((lib (dynamic-link %libmpg123))) + (let ((lib (dynamic-link* %libmpg123))) (lambda (return-type function-name arg-types) (pointer->procedure return-type (dynamic-func function-name lib) diff --git a/chickadee/audio/openal.scm b/chickadee/audio/openal.scm index acffe6a..0f0c947 100644 --- a/chickadee/audio/openal.scm +++ b/chickadee/audio/openal.scm @@ -95,7 +95,7 @@ ;;; (define openal-func - (let ((lib (dynamic-link %libopenal))) + (let ((lib (dynamic-link* %libopenal))) (lambda (return-type function-name arg-types) (pointer->procedure return-type (dynamic-func function-name lib) diff --git a/chickadee/audio/vorbis.scm b/chickadee/audio/vorbis.scm index e54e943..92574c8 100644 --- a/chickadee/audio/vorbis.scm +++ b/chickadee/audio/vorbis.scm @@ -48,7 +48,7 @@ ;;; (define vorbis-func - (let ((lib (dynamic-link %libvorbisfile))) + (let ((lib (dynamic-link* %libvorbisfile))) (lambda (return-type function-name arg-types) (pointer->procedure return-type (dynamic-func function-name lib) diff --git a/chickadee/config.scm.in b/chickadee/config.scm.in index 76f70ce..d540231 100644 --- a/chickadee/config.scm.in +++ b/chickadee/config.scm.in @@ -22,7 +22,10 @@ ;;; Code: (define-module (chickadee config) - #:export (%datadir + #:use-module (ice-9 match) + #:use-module (system foreign) + #:export (dynamic-link* + %datadir %chickadee-version %libopenal %libvorbisfile @@ -30,15 +33,28 @@ %libfreetype scope-datadir)) +;; Try to link against multiple library possibilities, such as the +;; absolute file name discovered by ./configure or by searching the +;; library load path as a fallback method. Useful when restributing +;; relocatable builds. +(define (dynamic-link* names) + (let loop ((names names)) + (match names + (() + (error "could not find library" names)) + ((name . rest) + (or (false-if-exception (dynamic-link name)) + (loop rest)))))) + (define %datadir (or (getenv "CHICKADEE_DATADIR") "@chickadee_datadir@/chickadee")) (define %chickadee-version "@PACKAGE_VERSION@") -(define %libopenal "@OPENAL_LIBDIR@/libopenal") -(define %libvorbisfile "@VORBIS_LIBDIR@/libvorbisfile") -(define %libmpg123 "@MPG123_LIBDIR@/libmpg123") -(define %libfreetype "@FREETYPE_LIBDIR@/libfreetype") +(define %libopenal '("@OPENAL_LIBDIR@/libopenal" "libopenal")) +(define %libvorbisfile '("@VORBIS_LIBDIR@/libvorbisfile" "libvorbisfile")) +(define %libmpg123 '("@MPG123_LIBDIR@/libmpg123" "libmpg123")) +(define %libfreetype '("@FREETYPE_LIBDIR@/libfreetype" "libfreetype")) (define (scope-datadir file) "Append the Chickadee data directory to FILE." diff --git a/chickadee/freetype.scm b/chickadee/freetype.scm index 58a1d08..73c0791 100644 --- a/chickadee/freetype.scm +++ b/chickadee/freetype.scm @@ -54,7 +54,7 @@ ;;; Low-level bindings ;;; -(define %lib (dynamic-link %libfreetype)) +(define %lib (dynamic-link* %libfreetype)) (define (freetype-func return-type function-name arg-types) (pointer->procedure return-type |