-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
/
julia-config.jl
executable file
·45 lines (38 loc) · 957 Bytes
/
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
const options =
[
"--cflags",
"--ldflags"
];
function libdir()
opts = Base.compileropts();
image_path = bytestring(opts.image_file);
@windows_only dir = joinpath(Base.JULIA_HOME, "julia");
@unix_only dir = match(r"(.*)(sys.ji)",image_path).captures[1];
end
function includedir()
dir = match(r"(.*)(bin)",JULIA_HOME).captures[1]*"include/julia";
end
function ldflags()
@unix_only "-L$(libdir()) -Wl,-rpath $(libdir()) -ljulia";
end
function cflags()
@unix_only "-I$(includedir())";
end
function check_args(args)
checked = intersect(args,options);
if length(checked) == 0 || length(checked) != length(args)
println(STDERR,"Usage: julia-config [",reduce((x,y)->"$x|$y",options),"]");
exit(1);
end
end
function main()
check_args(ARGS);
for args in ARGS
if args == "--ldflags"
println(ldflags());
elseif args == "--cflags"
println(cflags());
end
end
end
main();