blob: 6a35836a6abfb856ef0bffdaab81235941ff3046 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
(define-module (sdl2 config)
#:use-module (ice-9 match)
#:use-module (system foreign)
#:export (dynamic-link*
%libsdl2
%libsdl2-image
%libsdl2-ttf
%libsdl2-mixer))
;; 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))))))
;; Special case Windows since the DLL names are different. Performing
;; this check at runtime allows a Linux machine to cross-compile
;; guile-sdl2 for a Windows target.
;;
;; Another special case is when LD_LIBRARY_PATH is set. We *don't*
;; want to use the absolute file name of the library that pkgconfig
;; found. Instead, we want to use the library name itself so the
;; search path is used.
(define %windows? (string-prefix? "Windows" (utsname:sysname (uname))))
(define-syntax-rule (define-library-name name
(absolute ...)
(relative ...)
(windows ...))
(define name
(cond
(%windows? '(windows ...))
((getenv "LD_LIBRARY_PATH")
'(relative ...))
(else
'(absolute ...)))))
(define-library-name %libsdl2
("@SDL2_LIBDIR@/libSDL2")
("libSDL2" "libSDL2-2.0")
("SDL2"))
(define-library-name %libsdl2-image
("@SDL2_IMAGE_LIBDIR@/libSDL2_image")
("libSDL2_image" "libSDL2_image-2.0")
("SDL2_image"))
(define-library-name %libsdl2-ttf
("@SDL2_TTF_LIBDIR@/libSDL2_ttf")
("libSDL2_ttf" "libSDL2_ttf-2.0")
("SDL2_ttf"))
(define-library-name %libsdl2-mixer
("@SDL2_MIXER_LIBDIR@/libSDL2_mixer")
("libSDL2_mixer" "libSDL2_mixer-2.0")
("SDL2_mixer"))
|