How to build java-readline on OS X

Background

Building java-readline on OS X requires substantial edits to the Makefiles supplied with the distribuition. To save you the trouble of banging your head against the differences between linux and OS X I've written this up.

Steps

  1. If you don't already have it, get the free Developer Tools from Apple. You need a number of headers that the kit installs.

  2. Download and unzip/untar java-readline from sourceforge: http://sourceforge.net/project/showfiles.php?group_id=48669
    You want libreadline-java-0.7.3-src.tar.gz

  3. Download and unzip/untar termcap: ftp://ftp.gnu.org/gnu/termcap/
  4. "./configure" and "make" and "make install" termcap. I put it in /usr/local/lib
  5. Edit the Makefiles in libreadline-java-0.7.3/ and libreadline-java-0.7.3/src/native

    in the libreadline-java-0.7.4/ dir make these changes to the Makefile:

    The following should variables should be defined, but changes their values like so:

      T_LIBS = JavaReadline #JavaEditline  
      JAVANATINC = $(JAVA_HOME)/include  
    
    Add the following:
      JAVA_HOME = /Library/Java/Home
    And rename the variable LD_LIBRARY_PATH to DYLD_LIBRARY_PATH (do a search to find it)
       DYLD_LIBRARY_PATH=. java -jar $(JAR) src/test/tinputrc 
    
    in the libreadline-java-0.7.3/src/native dir make these changes to the Makefile
      LIBPATH = -L/usr/local/lib  # should be where you put termcap
      CC = cc                    
      CFLAGS=-fno-common
    
    Also change this line:
           $(CC) -shared org_gnu_readline_Readline.o $(LIBPATH) $($(TG)_LIBS) -o $@
    
    to this:
           $(CC) -bundle -flat_namespace -undefined suppress org_gnu_readline_Readl ine.o $(LIBPATH) $($(TG)_LIBS) -o $@ 
    
  6. run make: you'll get warnings about symbols, but ignore them. You're successful if you get a .jar file and a .so file in your working directory
  7. since we've built a jni library it has to have .jnilib as a suffix rather than .so. This should be done in the Makefile, but I'm lazy so just did:
     mv libJavaReadline.so libJavaReadline.dylib

  8. make test : if all goes well you should get a "linux>" prompt
  9. I also skipped make install and just cp'ed libJavaReadline.jnilib to /usr/lib/java and put libreadline-java.jar in /usr/local/java. Put them where you will. According to Apple, standard places for java libraries are the following:
         ./
         /usr/lib
         /usr/lib/java
         /lib
         /System/Library/Framworks/JavaVM.framework/Versions/1.3/Libraries
    
  10. You're done.

Useful resources

$Header: /home/iancooke/Docs/RCS/HT-install-java-readline-on-osx.html,v 1.5 2002/09/29 00:24:48 iancooke Exp iancooke $