-
Notifications
You must be signed in to change notification settings - Fork 19
/
julia-config.jl
executable file
·67 lines (59 loc) · 1.7 KB
/
julia-config.jl
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
# This file is based on the file `contrib/julia-config.jl` which is a
# part of Julia. License is MIT: https://julialang.org/license
import Libdl
function shell_escape(str)
str = replace(str, "'" => "'\''")
return "'$str'"
end
function libDir()
return if ccall(:jl_is_debugbuild, Cint, ()) != 0
if Base.DARWIN_FRAMEWORK
joinpath(dirname(abspath(Libdl.dlpath(Base.DARWIN_FRAMEWORK_NAME * "_debug"))),"lib")
else
dirname(abspath(Libdl.dlpath("libjulia-debug")))
end
else
if Base.DARWIN_FRAMEWORK
joinpath(dirname(abspath(Libdl.dlpath(Base.DARWIN_FRAMEWORK_NAME))),"lib")
else
dirname(abspath(Libdl.dlpath("libjulia")))
end
end
end
private_libDir() = abspath(Sys.BINDIR, Base.PRIVATE_LIBDIR)
function includeDir()
return abspath(Sys.BINDIR, Base.INCLUDEDIR, "julia")
end
function ldflags()
fl = "-L$(shell_escape(libDir()))"
if Sys.iswindows()
fl = fl * " -Wl,--stack,8388608"
elseif !Sys.isapple()
fl = fl * " -Wl,--export-dynamic"
end
return fl
end
function ldlibs()
libname = if ccall(:jl_is_debugbuild, Cint, ()) != 0
"julia-debug"
else
"julia"
end
if Sys.isunix()
return "-Wl,-rpath,$(shell_escape(libDir())) " *
(Sys.isapple() ? string() : "-Wl,-rpath,$(shell_escape(private_libDir())) ") *
"-l$libname"
else
return "-l$libname -lopenlibm"
end
end
function cflags()
flags = IOBuffer()
print(flags, "-std=gnu99")
include = shell_escape(includeDir())
print(flags, " -I", include)
if Sys.isunix()
print(flags, " -fPIC")
end
return String(take!(flags))
end