forked from rdowinton/homebrew-x11
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mit-scheme.rb
100 lines (87 loc) · 3.25 KB
/
mit-scheme.rb
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
class MitScheme < Formula
desc "MIT/GNU Scheme development tools and runtime library"
homepage "https://www.gnu.org/software/mit-scheme/"
url "http://ftpmirror.gnu.org/mit-scheme/stable.pkg/9.2/mit-scheme-c-9.2.tar.gz"
mirror "https://ftp.gnu.org/gnu/mit-scheme/stable.pkg/9.2/mit-scheme-c-9.2.tar.gz"
sha256 "4f6a16f9c7d4b4b7bb3aa53ef523cad39b54ae1eaa3ab3205930b6a87759b170"
revision 1
bottle do
sha256 "736068c47a7b3dd3f683be45140afc10ea1af016ea4f39bb571e71ae1d609a78" => :yosemite
sha256 "0ba9fef9bc17b763339d9dbf9e370963db39f0655f5bfde6e05834abbce80397" => :mavericks
sha256 "10dcb8d02d2733041092df680440f14a2654ff620bfac4fb03ca523198121263" => :mountain_lion
end
conflicts_with "tinyscheme", :because => "both install a `scheme` binary"
# Has a hardcoded compile check for /Applications/Xcode.app
# Dies on "configure: error: SIZEOF_CHAR is not 1" without Xcode.
# https://github.com/Homebrew/homebrew-x11/issues/103#issuecomment-125014423
depends_on :xcode => :build
depends_on "openssl"
depends_on :x11 => :recommended
def install
# The build breaks __HORRIBLY__ with parallel make -- one target will
# erase something before another target gets it, so it's easier to change
# the environment than to change_make_var, because there are Makefiles
# littered everywhere
ENV.deparallelize
# Liarc builds must launch within the src dir, not using the top-level
# Makefile
cd "src"
# Take care of some hard-coded paths
%w[
6001/edextra.scm
6001/floppy.scm
compiler/etc/disload.scm
edwin/techinfo.scm
edwin/unix.scm
microcode/configure
swat/c/tk3.2-custom/Makefile
swat/c/tk3.2-custom/tcl/Makefile
swat/scheme/other/btest.scm
].each do |f|
inreplace f, "/usr/local", prefix
end
# The configure script will add "-isysroot" to CPPFLAGS, so it didn't
# check .h here by default even Homebrew is installed in /usr/local. This
# breaks things when gdbm or other optional dependencies was installed
# using Homebrew
ENV.prepend "CPPFLAGS", "-I#{HOMEBREW_PREFIX}/include"
ENV["MACOSX_SYSROOT"] = MacOS.sdk_path
system "etc/make-liarc.sh", "--prefix=#{prefix}", "--mandir=#{man}"
system "make", "install"
end
test do
# ftp://ftp.cs.indiana.edu/pub/scheme-repository/code/num/primes.scm
(testpath/"primes.scm").write <<-EOS.undent
;
; primes
; By Ozan Yigit
;
(define (interval-list m n)
(if (> m n)
'()
(cons m (interval-list (+ 1 m) n))))
(define (sieve l)
(define (remove-multiples n l)
(if (null? l)
'()
(if (= (modulo (car l) n) 0) ; division test
(remove-multiples n (cdr l))
(cons (car l)
(remove-multiples n (cdr l))))))
(if (null? l)
'()
(cons (car l)
(sieve (remove-multiples (car l) (cdr l))))))
(define (primes<= n)
(sieve (interval-list 2 n)))
; (primes<= 300)
EOS
output = shell_output(
"mit-scheme --load primes.scm --eval '(primes<= 72)' < /dev/null"
)
assert_match(
/;Value 2: \(2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71\)/,
output
)
end
end