Skip to content

Commit e35825f

Browse files
committed
Also vendor libsodium
1 parent ab5b11f commit e35825f

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@
44
[submodule "ext/czmq"]
55
path = ext/czmq
66
url = https://github.com/zeromq/czmq
7+
[submodule "ext/libsodium"]
8+
path = ext/libsodium
9+
url = git://github.com/jedisct1/libsodium.git

ext/libsodium

Submodule libsodium added at fe27e6c

ext/rbczmq/extconf.rb

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ def fail(msg)
2525
vendor_path = cwd + '..'
2626
zmq_path = vendor_path + 'zeromq'
2727
czmq_path = vendor_path + 'czmq'
28+
libsodium_path = vendor_path + 'libsodium'
29+
libsodium_include_path = libsodium_path + 'include'
2830
zmq_include_path = zmq_path + 'include'
2931
czmq_include_path = czmq_path + 'include'
3032

@@ -96,6 +98,19 @@ def check_heads heads = [], fatal = false
9698
sys "cd ../.. && git submodule update --init", "Checking out git submodules error!"
9799
end
98100

101+
# build libsodium
102+
if with_config('system-libs')
103+
$stderr.puts "Warning -- using system version of libsodium."
104+
else
105+
lib = libs_path + "libsodium.#{LIBEXT}"
106+
Dir.chdir libsodium_path do
107+
sys "./autogen.sh", "libsodium autogen failed!" unless File.exist?(libsodium_path + 'configure')
108+
sys "./configure --prefix=#{dst_path} --without-documentation --enable-shared",
109+
"libsodium configure failed" unless File.exist?(libsodium_path + 'Makefile')
110+
sys "make && make install", "libsodium compile error!"
111+
end
112+
end
113+
99114
# build libzmq
100115
if with_config('system-libs')
101116
$stderr.puts "Warning -- using system version of libzmq."
@@ -106,7 +121,7 @@ def check_heads heads = [], fatal = false
106121
sys "./configure --prefix=#{dst_path} --without-documentation --enable-shared",
107122
"ZeroMQ configure failed" unless File.exist?(zmq_path + 'Makefile')
108123
sys "make && make install", "ZeroMQ compile error!"
109-
end #unless File.exist?(lib)
124+
end
110125
end
111126

112127
# build libczmq
@@ -116,10 +131,10 @@ def check_heads heads = [], fatal = false
116131
lib = libs_path + "libczmq.#{LIBEXT}"
117132
Dir.chdir czmq_path do
118133
sys "./autogen.sh", "CZMQ autogen failed!" unless File.exist?(czmq_path + 'configure')
119-
sys "./configure LDFLAGS=-L#{libs_path} CFLAGS='#{CZMQ_CFLAGS.join(" ")}' --prefix=#{dst_path} --with-libzmq=#{dst_path} --disable-shared",
134+
sys "./configure LDFLAGS=-L#{libs_path} CFLAGS='#{CZMQ_CFLAGS.join(" ")}' --prefix=#{dst_path} --with-libzmq=#{dst_path} --disable-shared",
120135
"CZMQ configure error!" unless File.exist?(czmq_path + 'Makefile')
121136
sys "make all && make install", "CZMQ compile error!"
122-
end #unless File.exist?(lib)
137+
end
123138
end
124139

125140
dir_config('rbczmq')
@@ -128,6 +143,7 @@ def check_heads heads = [], fatal = false
128143
have_func('rb_thread_blocking_region')
129144
have_func('rb_thread_call_without_gvl')
130145

146+
$INCFLAGS << " -I#{libsodium_include_path}" if find_header("sodidum.h", libsodium_include_path)
131147
$INCFLAGS << " -I#{zmq_include_path}" if find_header("zmq.h", zmq_include_path)
132148
$INCFLAGS << " -I#{czmq_include_path}" if find_header("czmq.h", czmq_include_path)
133149

0 commit comments

Comments
 (0)