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
|
class Lightning < Formula
homepage "https://www.gnu.org/software/lightning/"
url "http://ftpmirror.gnu.org/lightning/lightning-2.1.0.tar.gz"
mirror "https://ftp.gnu.org/gnu/lightning/lightning-2.1.0.tar.gz"
sha1 "d08aa434fba8fb29d0c1b240b034042c26cbf2b3"
bottle do
cellar :any
sha1 "e80a9133db39040b776db67ab92e47c2d813d795" => :yosemite
sha1 "e1cdb55c958c945853e310fb4753fe7ba00250d6" => :mavericks
sha1 "bc7d44348a84cb3de048b079bbebcf906f4a9a45" => :mountain_lion
end
depends_on "binutils" => [:build, :optional]
def install
args = [
"--disable-dependency-tracking",
"--disable-silent-rules",
"--prefix=#{prefix}",
]
args << "--disable-disassembler" if build.without? "binutils"
system "./configure", *args
system "make", "check", "-j1"
system "make", "install"
end
test do
# from http://www.gnu.org/software/lightning/manual/lightning.html#incr
(testpath/"test.c").write <<-EOS.undent
#include <stdio.h>
#include <lightning.h>
static jit_state_t *_jit;
typedef int (*pifi)(int);
int main(int argc, char *argv[]) {
jit_node_t *in;
pifi incr;
init_jit(argv[0]);
_jit = jit_new_state();
jit_prolog();
in = jit_arg();
jit_getarg(JIT_R0, in);
jit_addi(JIT_R0, JIT_R0, 1);
jit_retr(JIT_R0);
incr = jit_emit();
jit_clear_state();
printf("%d + 1 = %d\\n", 5, incr(5));
jit_destroy_state();
finish_jit();
return 0;
}
EOS
system ENV.cc, "test.c", "-L#{lib}", "-llightning", "-o", "test"
system "./test"
end
end
|