forked from necromant2005/homebrew-boneyard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlibiomp.rb
50 lines (42 loc) · 1.37 KB
/
libiomp.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
class Libiomp < Formula
desc "Manage multiple threads in an OpenMP program as it executes"
homepage "https://www.openmprtl.org/download"
url "https://www.openmprtl.org/sites/default/files/libomp_20150701_oss.tgz"
sha256 "d0c1fcb5997c53e0c9ff4eec1de3392a21308731c06e6663f9d32ceb15f14e88"
depends_on :arch => :intel
depends_on "cmake" => :build
fails_with :gcc do
cause "libiomp can only be built with clang."
end
fails_with :gcc_4_0 do
cause "libiomp can only be built with clang."
end
("4.3".."4.9").each do |n|
fails_with :gcc => n do
cause "libiomp can only be built with clang."
end
end
def install
intel_arch = MacOS.prefer_64_bit? ? "mac_32e" : "mac_32"
args = std_cmake_args
args << (MacOS.prefer_64_bit? ? "-DLIBOMP_ARCH=32e" : "-DLIBOMP_ARCH=32")
system "cmake", ".", *args
system "make", "all"
(include/"libiomp").install Dir["exports/common/include/*"]
lib.install "exports/#{intel_arch}/lib.thin/libiomp5.dylib"
end
test do
testfile = <<-EOS.undent
#include <omp.h>
#include <stdlib.h>
int main(void) {
omp_set_num_threads(2);
omp_get_num_threads();
return EXIT_SUCCESS;
}
EOS
(testpath/"test.c").write(testfile)
system ENV.cc, "-L#{lib}", "-liomp5", "-I#{include}/libiomp", "test.c", "-o", "test"
system "./test"
end
end