3 $description = 'Test the $(guile ...) function.';
5 $details = 'This only works on systems that support it.';
7 # If this instance of make doesn't support GNU Guile, skip it
8 # This detects if guile is loaded using the "load" directive
9 # $makefile = get_tmpfile();
10 # open(MAKEFILE, "> $makefile") || die "Failed to open $makefile: $!\n";
13 # all: ; @echo $(filter guile,$(.LOADED))
15 # close(MAKEFILE) || die "Failed to write $makefile: $!\n";
16 # $cmd = subst_make_string("#MAKEPATH# -f $makefile");
17 # $log = get_logfile(0);
18 # $code = run_command_with_output($log, $cmd);
19 # read_file_into_string ($log) eq "guile\n" and $FEATURES{guile} = 1;
21 # If we don't have Guile support, never mind.
22 exists $FEATURES{guile} or return -1;
24 # Verify simple data type conversions
25 # Currently we don't support vectors:
26 # echo '$(guile (vector 1 2 3))'; \
28 x:;@echo '$(guile #f)'; \
30 echo '$(guile #\c)'; \
31 echo '$(guile 1234)'; \
32 echo '$(guile 'foo)'; \
33 echo '$(guile "bar")'; \
34 echo '$(guile (cons 'a 'b))'; \
35 echo '$(guile '(a b (c . d) 1 (2) 3))'
37 '', "\n#t\nc\n1234\nfoo\nbar\na b\na b c d 1 2 3");
39 # Verify the gmk-expand function
41 VAR = $(guile (gmk-expand "$(shell echo hi)"))
46 # Verify the gmk-eval function
48 $(guile (gmk-eval "VAR = hi $(shell echo there)"))
53 # Verify the gmk-eval function with a list
55 $(guile (gmk-eval '(VAR = 1 (2) () 3)))
60 # Verify the gmk-var function
62 VALUE = hi $(shell echo there)
63 VAR = $(guile (gmk-var "VALUE"))
68 # Verify the gmk-var function with a symbol
70 VALUE = hi $(shell echo there)
71 VAR = $(guile (gmk-var 'VALUE))
76 # Write a Guile program using define and run it
78 # Define the "fib" function in Guile
80 ;; A procedure for counting the n:th Fibonacci number
85 (else (+ (fib (- n 1))
91 x:;@echo $(guile (fib $(FIB)))