@@ -45,8 +45,8 @@ function includeDir()
45
45
return abspath (Sys. BINDIR, Base. INCLUDEDIR, " julia" )
46
46
end
47
47
48
- function ldflags (doframework )
49
- doframework && return " -F$(shell_escape (frameworkDir ())) "
48
+ function ldflags (; framework :: Bool = false )
49
+ framework && return " -F$(shell_escape (frameworkDir ())) "
50
50
fl = " -L$(shell_escape (libDir ())) "
51
51
if Sys. iswindows ()
52
52
fl = fl * " -Wl,--stack,8388608"
@@ -56,27 +56,40 @@ function ldflags(doframework)
56
56
return fl
57
57
end
58
58
59
- function ldlibs (doframework)
59
+ function ldrpath ()
60
+ libname = if Base. isdebugbuild ()
61
+ " julia-debug"
62
+ else
63
+ " julia"
64
+ end
65
+ return " -Wl,-rpath,$(shell_escape (private_libDir ())) -Wl,-rpath,$(shell_escape (libDir ())) -l$libname "
66
+ end
67
+
68
+ function ldlibs (; framework:: Bool = false , rpath:: Bool = true )
60
69
# Return "Julia" for the framework even if this is a debug build.
61
70
# If the user wants the debug framework, DYLD_IMAGE_SUFFIX=_debug
62
71
# should be used (refer to man 1 dyld).
63
- doframework && return " -framework $(Base. DARWIN_FRAMEWORK_NAME) "
72
+ framework && return " -framework $(Base. DARWIN_FRAMEWORK_NAME) "
64
73
libname = if Base. isdebugbuild ()
65
74
" julia-debug"
66
75
else
67
76
" julia"
68
77
end
69
78
if Sys. isunix ()
70
- return " -L$(shell_escape (private_libDir ())) -Wl,-rpath,$(shell_escape (libDir ())) -Wl,-rpath,$(shell_escape (private_libDir ())) -l$libname "
79
+ if rpath
80
+ return " -L$(shell_escape (private_libDir ())) $(ldrpath ()) "
81
+ else
82
+ return " -L$(shell_escape (private_libDir ())) "
83
+ end
71
84
else
72
85
return " -l$libname -lopenlibm"
73
86
end
74
87
end
75
88
76
- function cflags (doframework )
89
+ function cflags (; framework :: Bool = false )
77
90
flags = IOBuffer ()
78
91
print (flags, " -std=gnu11" )
79
- if doframework
92
+ if framework
80
93
include = shell_escape (frameworkDir ())
81
94
print (flags, " -F" , include)
82
95
else
@@ -89,8 +102,8 @@ function cflags(doframework)
89
102
return String (take! (flags))
90
103
end
91
104
92
- function allflags (doframework )
93
- return " $(cflags (doframework )) $(ldflags (doframework )) $(ldlibs (doframework )) "
105
+ function allflags (; framework :: Bool = false , rpath :: Bool = true )
106
+ return " $(cflags (; framework )) $(ldflags (; framework )) $(ldlibs (; framework, rpath )) "
94
107
end
95
108
96
109
function check_args (args)
@@ -102,31 +115,29 @@ function check_args(args)
102
115
end
103
116
104
117
function check_framework_flag (args)
105
- doframework = " --framework" in args
106
- if doframework && ! Base. DARWIN_FRAMEWORK
118
+ framework = " --framework" in args
119
+ if framework && ! Base. DARWIN_FRAMEWORK
107
120
println (stderr , " NOTICE: Ignoring --framework because Julia is not packaged as a framework." )
108
121
return false
109
- elseif ! doframework && Base. DARWIN_FRAMEWORK
122
+ elseif ! framework && Base. DARWIN_FRAMEWORK
110
123
println (stderr , " NOTICE: Consider using --framework because Julia is packaged as a framework." )
111
124
return false
112
125
end
113
- return doframework
126
+ return framework
114
127
end
115
128
116
- function main ( )
117
- check_args (ARGS )
118
- doframework = check_framework_flag (ARGS )
119
- for args in ARGS
129
+ function ( @ main)(args )
130
+ check_args (args )
131
+ framework = check_framework_flag (args )
132
+ for args in args
120
133
if args == " --ldflags"
121
- println (ldflags (doframework ))
134
+ println (ldflags (; framework ))
122
135
elseif args == " --cflags"
123
- println (cflags (doframework ))
136
+ println (cflags (; framework ))
124
137
elseif args == " --ldlibs"
125
- println (ldlibs (doframework ))
138
+ println (ldlibs (; framework ))
126
139
elseif args == " --allflags"
127
- println (allflags (doframework ))
140
+ println (allflags (; framework ))
128
141
end
129
142
end
130
143
end
131
-
132
- main ()
0 commit comments