2012-09-10 10:31:40 +00:00
|
|
|
require 'formula'
|
|
|
|
|
|
|
|
class LibreadlineJava < Formula
|
|
|
|
homepage 'http://java-readline.sourceforge.net/'
|
2014-02-27 14:19:55 +00:00
|
|
|
url 'https://downloads.sourceforge.net/project/java-readline/java-readline/0.8.0/libreadline-java-0.8.0-src.tar.gz'
|
2012-09-10 10:31:40 +00:00
|
|
|
sha1 '1f5574f9345afc039e9c7a09ae4979129891d52a'
|
|
|
|
|
2014-07-03 21:00:26 +00:00
|
|
|
bottle do
|
|
|
|
cellar :any
|
2014-10-20 07:57:57 +00:00
|
|
|
revision 1
|
|
|
|
sha1 "6e108ba60e76149db1d0d1275ba5806eda0f2a69" => :yosemite
|
|
|
|
sha1 "d69632b706e1bc325f53a2fab43d86258760368d" => :mavericks
|
|
|
|
sha1 "7bd2a8227ce2c9055471fd864a19faf943a10263" => :mountain_lion
|
2014-07-03 21:00:26 +00:00
|
|
|
end
|
|
|
|
|
2012-09-10 10:31:40 +00:00
|
|
|
depends_on 'readline'
|
|
|
|
|
2014-03-19 17:07:55 +00:00
|
|
|
# Fix "non-void function should return a value"-Error
|
|
|
|
# https://sourceforge.net/tracker/?func=detail&atid=453822&aid=3566332&group_id=48669
|
|
|
|
patch :DATA
|
2012-09-10 10:31:40 +00:00
|
|
|
|
|
|
|
def install
|
2014-05-20 22:10:29 +00:00
|
|
|
java_home = ENV["JAVA_HOME"] = `/usr/libexec/java_home`.chomp
|
2012-09-10 10:31:40 +00:00
|
|
|
|
|
|
|
# Current Oracle JDKs put the jni.h and jni_md.h in a different place than the
|
|
|
|
# original Apple/Sun JDK used to.
|
2014-05-20 22:10:29 +00:00
|
|
|
if File.exist? "#{java_home}/include/jni.h"
|
|
|
|
ENV["JAVAINCLUDE"] = "#{java_home}/include"
|
|
|
|
ENV["JAVANATINC"] = "#{java_home}/include/darwin"
|
2013-12-09 19:44:45 +00:00
|
|
|
elsif File.exist? "/System/Library/Frameworks/JavaVM.framework/Versions/Current/Headers/jni.h"
|
2014-05-20 22:10:29 +00:00
|
|
|
ENV["JAVAINCLUDE"] = "/System/Library/Frameworks/JavaVM.framework/Versions/Current/Headers/"
|
|
|
|
ENV["JAVANATINC"] = "/System/Library/Frameworks/JavaVM.framework/Versions/Current/Headers/"
|
2012-09-10 10:31:40 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
# Take care of some hard-coded paths,
|
|
|
|
# adjust postfix of jni libraries,
|
|
|
|
# adjust gnu install parameters to bsd install
|
|
|
|
inreplace 'Makefile' do |s|
|
|
|
|
s.change_make_var! "PREFIX", prefix
|
|
|
|
s.change_make_var! "JAVALIBDIR", "$(PREFIX)/share/libreadline-java"
|
|
|
|
s.change_make_var! "JAVAINCLUDE", ENV['JAVAINCLUDE']
|
|
|
|
s.change_make_var! "JAVANATINC", ENV['JAVANATINC']
|
|
|
|
s.gsub! "*.so", "*.jnilib"
|
|
|
|
s.gsub! "install -D", "install -c"
|
|
|
|
end
|
|
|
|
|
|
|
|
# Take care of some hard-coded paths,
|
|
|
|
# adjust CC variable,
|
|
|
|
# adjust postfix of jni libraries
|
|
|
|
inreplace 'src/native/Makefile' do |s|
|
2014-05-20 22:10:29 +00:00
|
|
|
readline = Formula["readline"]
|
|
|
|
s.change_make_var! "INCLUDES", "-I $(JAVAINCLUDE) -I $(JAVANATINC) -I #{readline.opt_include}"
|
|
|
|
s.change_make_var! "LIBPATH", "-L#{readline.opt_lib}"
|
2012-09-10 10:31:40 +00:00
|
|
|
s.change_make_var! "CC", "cc"
|
|
|
|
s.gsub! "LIB_EXT := so", "LIB_EXT := jnilib"
|
|
|
|
s.gsub! "$(CC) -shared $(OBJECTS) $(LIBPATH) $($(TG)_LIBS) -o $@", "$(CC) -install_name #{HOMEBREW_PREFIX}/lib/$(LIB_PRE)$(TG).$(LIB_EXT) -dynamiclib $(OBJECTS) $(LIBPATH) $($(TG)_LIBS) -o $@"
|
|
|
|
end
|
|
|
|
|
2014-05-20 22:10:29 +00:00
|
|
|
(share/"libreadline-java").mkpath
|
2012-09-10 10:31:40 +00:00
|
|
|
|
|
|
|
system "make jar"
|
|
|
|
system "make build-native"
|
|
|
|
system "make install"
|
|
|
|
|
2014-03-31 17:33:38 +00:00
|
|
|
doc.install "api"
|
2012-09-10 10:31:40 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def caveats; <<-EOS.undent
|
|
|
|
You may need to set JAVA_HOME:
|
|
|
|
export JAVA_HOME="$(/usr/libexec/java_home)"
|
|
|
|
EOS
|
|
|
|
end
|
|
|
|
|
|
|
|
# Testing libreadline-java (can we execute and exit libreadline without exceptions?)
|
|
|
|
test do
|
|
|
|
system "echo 'exit' | java -Djava.library.path=#{lib} -cp #{share}/libreadline-java/libreadline-java.jar test.ReadlineTest | grep -v Exception"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
__END__
|
|
|
|
diff --git a/src/native/org_gnu_readline_Readline.c b/src/native/org_gnu_readline_Readline.c
|
|
|
|
index f601c73..b26cafc 100644
|
|
|
|
--- a/src/native/org_gnu_readline_Readline.c
|
|
|
|
+++ b/src/native/org_gnu_readline_Readline.c
|
|
|
|
@@ -430,7 +430,7 @@ const char *java_completer(char *text, int state) {
|
|
|
|
jtext = (*jniEnv)->NewStringUTF(jniEnv,text);
|
|
|
|
|
|
|
|
if (jniMethodId == 0) {
|
|
|
|
- return;
|
|
|
|
+ return ((const char *)NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
completion = (*jniEnv)->CallObjectMethod(jniEnv, jniObject,
|