Commit 1862cf03 authored by Artiom Di's avatar Artiom Di

JRuby support

parent b3e3978b
require 'mkmf'
RbConfig::MAKEFILE_CONFIG['CC'] = ENV['CC'] if ENV['CC']
$CFLAGS << " #{ENV["CFLAGS"]}"
def sys(cmd) def sys(cmd)
puts " -- #{cmd}" puts " -- #{cmd}"
unless ret = xsystem(cmd) unless ret = system(cmd)
raise "ERROR: '#{cmd}' failed" raise "ERROR: '#{cmd}' failed"
end end
ret ret
end end
if !(MAKE = find_executable('gmake') || find_executable('make')) mkfl = <<MAKEFILE
abort "ERROR: GNU make is required to build libsodium." install:
end \t@echo "Nothing to do"
clean:
\t@echo "Nothing to do"
MAKEFILE
CWD = File.expand_path(File.dirname(__FILE__)) CWD = File.expand_path(File.dirname(__FILE__))
LIBSODIUM_DIR = File.expand_path(File.join(CWD, '..', '..', 'vendor', 'libsodium')) LIBSODIUM_DIR = File.expand_path(File.join(CWD, '..', '..', 'vendor', 'libsodium'))
MAKE = ENV['MAKE'] || ENV['make'] || "make"
Dir.chdir(LIBSODIUM_DIR) do Dir.chdir(LIBSODIUM_DIR) do
sys("./autogen.sh") sys("./autogen.sh")
...@@ -26,11 +25,6 @@ Dir.chdir(LIBSODIUM_DIR) do ...@@ -26,11 +25,6 @@ Dir.chdir(LIBSODIUM_DIR) do
sys("#{MAKE} install") sys("#{MAKE} install")
end end
$DEFLIBPATH.unshift("#{LIBSODIUM_DIR}/dist") File.open("Makefile", "w") do |f|
dir_config('sodium', "#{LIBSODIUM_DIR}/dist/include", "#{LIBSODIUM_DIR}/dist/lib") f.write(mkfl)
unless have_library 'sodium'
abort "ERROR: Failed to build libsodium"
end end
create_makefile("rbnacl-libsodium/rbnacl-libsodium")
...@@ -3,7 +3,7 @@ require "rbnacl/libsodium/version" ...@@ -3,7 +3,7 @@ require "rbnacl/libsodium/version"
module RbNaCl module RbNaCl
module Libsodium module Libsodium
sodiumlib_dir = File.expand_path(File.join(File.dirname(__FILE__), "../../vendor/libsodium/dist/lib/")) sodiumlib_dir = File.expand_path(File.join(File.dirname(__FILE__), "../../vendor/libsodium/dist/lib/"))
sodiumlib_filename = RUBY_PLATFORM =~ /darwin/ ? "libsodium.dylib" : "libsodium.so" sodiumlib_filename = RUBY_DESCRIPTION =~ /darwin/ ? "libsodium.dylib" : "libsodium.so"
::RBNACL_LIBSODIUM_GEM_LIB_PATH = File.join(sodiumlib_dir, sodiumlib_filename) ::RBNACL_LIBSODIUM_GEM_LIB_PATH = File.join(sodiumlib_dir, sodiumlib_filename)
end end
end end
......
module RbNaCl module RbNaCl
module Libsodium module Libsodium
VERSION = "0.0.1" VERSION = "0.0.2"
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment