diff --git a/README.md b/README.md
index 790f628..bdf7490 100644
--- a/README.md
+++ b/README.md
@@ -240,13 +240,10 @@ and input file to .sps file and other way around is undefined behaviour.
### Chicken
-To run executable at place set LD\_LIBRARY\_PATH=. (executable directory)
-before running it. For example:
+By default Chicken 6 is assumed, for Chicken 5 use environment variable to
+add R7RS libraries:
- LD\_LIBRARY\_PATH=. ./test
-
-If you are using Chicken you should propably read the next section too, you
-will most propably run into it soon.
+ COMPILE_R7RS_CHIKEN="-X r7r -R r7rs"
### mit-scheme
diff --git a/libs/data.sld b/libs/data.sld
index 1d7245b..c4dd1a3 100644
--- a/libs/data.sld
+++ b/libs/data.sld
@@ -51,25 +51,53 @@
(out (string-append (if (string-starts-with? library-file "srfi")
(string-replace (string-cut-from-end library-file 4) #\/ #\-)
(string-replace (string-cut-from-end library-file 4) #\/ #\.))
- ".so")))
- (apply string-append `("csc -R r7rs -X r7rs -s -J"
+ ".o"))
+ (static-out (string-append (if (string-starts-with? library-file "srfi")
+ (string-replace (string-cut-from-end library-file 4) #\/ #\-)
+ (string-replace (string-cut-from-end library-file 4) #\/ #\.))
+ ".a")))
+ (apply string-append `("csc -static -c -J"
+ " "
+ ,(util-getenv "COMPILE_R7RS_CHICKEN")
" "
"-o"
" "
,out
" "
- ,(util-getenv "COMPILE_R7RS_CHICKEN")
+ ,(search-library-file (append prepend-directories append-directories) library-file)
" "
- ,(search-library-file (append prepend-directories append-directories) library-file))))))
+ "-unit"
+ " "
+ ,unit
+ " "
+ "&&"
+ " "
+ "ar"
+ " "
+ "rcs"
+ " "
+ ,static-out
+ " "
+ ,out)))))
(command . ,(lambda (input-file output-file prepend-directories append-directories library-files r6rs?)
- (apply string-append `("csc -R r7rs -X r7rs"
+ (apply string-append `("csc"
" "
,(util-getenv "COMPILE_R7RS_CHICKEN")
" "
+ "-static"
+ " "
,@(map (lambda (item)
(string-append "-I " item " "))
(append append-directories prepend-directories))
" "
+ ,@(map (lambda (library-file)
+ (string-append "-uses "
+ (if (string-starts-with? library-file "srfi")
+ (string-replace (string-cut-from-end library-file 4) #\/ #\-)
+ (string-replace (string-cut-from-end library-file 4) #\/ #\.))
+ " "))
+ library-files)
+
"-output-file"
" "
,output-file