-
Notifications
You must be signed in to change notification settings - Fork 40
/
gen-config.ss
executable file
·84 lines (78 loc) · 2.71 KB
/
gen-config.ss
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/env scheme-script
(import (except (chezscheme) scheme))
(include "utils.ss")
(define scheme (make-parameter "scheme"))
(define bootpath (make-parameter "."))
(define prefixdir
(make-parameter
(case (os-name)
[windows (string-append (getenv "LOCALAPPDATA") "\\chez-exe")]
[else "/usr/local"])))
(define libdir (make-parameter #f))
(define bindir (make-parameter #f))
(define args
(param-args (command-line-arguments)
[#f "--help" (lambda ()
(printlns
"Usage:"
"gen-config.ss [--prefix prefix] [--bindir bindir]"
" [--libdir libdir] [--bootpath bootpath]"
" [--scheme scheme] [c-compiler-arg ...]"
""
" --scheme: path to scheme exe"
" --bootpath: path to boot files"
" --prefix: root path for chez-exe installation"
" --libdir: path to location for install of chez-exe libraries"
" --bindir: path to location for install of chez-exe binaries"
""
" On UNIX-like machines, bindir and libdir default to"
" $prefix/bin and $prefix/lib respectively, and the default"
" for prefix is /usr/local"
" On Windows, bindir and libdir both default to $prefix, and the"
" default for prefix is %LOCALAPPDATA%\\chez-exe")
(exit))]
["--scheme" scheme]
["--bootpath" bootpath]
["--prefix" prefixdir]
["--libdir" libdir]
["--bindir" bindir]))
(unless (libdir)
(libdir
(case (os-name)
[windows (prefixdir)]
[else
(string-append (prefixdir) "/lib")])))
(unless (bindir)
(bindir
(case (os-name)
[windows (prefixdir)]
[else
(string-append (prefixdir) "/bin")])))
(with-output-to-file "config.ss"
(lambda ()
(write `(chez-lib-dir ,(libdir)))
(write `(static-compiler-args ',args)))
'(replace))
(case (os-name)
[windows
(with-output-to-file "tools.ini"
(lambda ()
(printlns
"[NMAKE]"
(format "scheme = ~a" (scheme))
(format "bootpath = ~a" (bootpath))
(format "installbindir = ~a" (bindir))
(format "installlibdir = ~a" (libdir))))
'(replace))]
[else
(with-output-to-file "make.in"
(lambda ()
(printlns
(format "CFLAGS += -m~a" (machine-bits))
(format "scheme = ~a" (scheme))
(format "bootpath = ~a" (bootpath))
(format "prefix = ~a" (prefixdir))
(format "installlibdir = ~a" (libdir))
(format "installbindir = ~a" (bindir))))
'(replace))])
(system "make")