Commit 5bc022c1 authored by Tony Mancill's avatar Tony Mancill

Imported Upstream version 0.8.0.1

parent f389bf9e
This diff is collapsed.
......@@ -23,92 +23,105 @@
#
# Toplevel Makefile for Java-Readline
#
# $Author: Bablokb $
# $Revision: 1.10 $
# $Author: bablokb $
# $Revision: 1.18 $
#
TARGET := java_readline
README := README README.1st
CHANGELOG := ChangeLog
LICENSE := COPYING.LIB
TODO := TODO
NAME := The Java-Readline Library
HOMEPAGE := http://www.bablokb.de/java/readline.html
COPYRIGHT := Released under the LGPL, (c) Bernhard Bablok 1998-2001
WTITLE := "$(NAME)"
DTITLE = "$(NAME), Version $(VERSION)"
DBOTTOM := "$(COPYRIGHT)<br>Homepage: <a href="$(HOMEPAGE)">$(HOMEPAGE)</a>"
DHEADER = "<strong>$(NAME), Version $(VERSION)</strong>"
DFOOTER = "<strong>$(NAME), Version $(VERSION)</strong>"
PACKROOT :=
SUBDIRS := src etc
PACKAGES := test org.gnu.readline
BIN_ADD = $(README) $(TODO) $(CHANGELOG) $(LICENSE) \
$(JAR) $(shell ls *.so) $(APIDIR)
SRC_ADD := $(README) $(TODO) $(CHANGELOG) $(LICENSE) \
Makefile VERSION $(SUBDIRS) contrib
MF_STUB := etc/manifest.stub
# native stuff
export JAVAINCLUDE := $(JAVA_HOME)/include
export JAVANATINC := $(JAVA_HOME)/include/linux
export INCLUDES := -I $(JAVAINCLUDE) -I $(JAVANATINC)
export LIBPATH := -L/usr/lib/termcap
export T_LIBS := JavaReadline JavaEditline
export JavaReadline_LIBS := -lreadline -ltermcap -lhistory
export JavaEditline_LIBS := -ledit -ltermcap
VERSION := $(shell cat VERSION)
export ROOTDIR := $(shell pwd)
export BUILDDIR := $(shell pwd)/build
export METADIR := $(BUILDDIR)/META-INF
export CLASSDIR := $(BUILDDIR)
export JAR := $(TARGET).jar
APIDIR := ./api
export JAVAC := jikes
export CLASSPATH := $(BUILDDIR):$(JAVA_HOME)/jre/lib/rt.jar
export JAVAC_OPT := -O +E
.PHONY: src-dist bin-dist test apidoc jar subdirs $(SUBDIRS)
jar: subdirs
$(MAKE) $(JAR)
$(JAR): $(MF_STUB) $(shell find build -type f)
ifeq ($(strip $(MF_STUB)),)
jar -cvf $(JAR) -C $(BUILDDIR)/ .
else
jar -cvfm $(JAR) $(MF_STUB) -C $(BUILDDIR)/ .
TARGET = libreadline-java
README = README README.1st
NEWS = NEWS
CHANGELOG = ChangeLog
LICENSE = COPYING.LIB
TODO = TODO
NAME = The Java-Readline Library
HOMEPAGE = http://java-readline.sourceforge.net/
COPYRIGHT = Released under the LGPL, (c) Bernhard Bablok, Henner Zeller 1998-2002
WTITLE = "$(NAME)"
DTITLE = "$(NAME), Version $(VERSION)"
DBOTTOM = "$(COPYRIGHT)<br>Homepage: <a href="$(HOMEPAGE)">$(HOMEPAGE)</a>"
DHEADER = "<strong>$(NAME), Version $(VERSION)</strong>"
DFOOTER = "<strong>$(NAME), Version $(VERSION)</strong>"
BIN_ADD = $(README) $(NEWS) $(TODO) $(CHANGELOG) $(LICENSE) \
$(JAR) *.so $(APIDIR)
SRC_ADD = $(README) $(NEWS) $(TODO) $(CHANGELOG) $(LICENSE) \
Makefile VERSION $(SUBDIRS) contrib src etc
MF_STUB = etc/manifest.stub
# installation procedure
PREFIX = /usr
BINLIBDIR = $(PREFIX)/lib
DOCDIR = $(PREFIX)/doc
JAVALIBDIR= $(PREFIX)/share/java
# libraries to build
T_LIBS = JavaReadline
# Operating system dependent
JAVAINCLUDE = $(JAVA_HOME)/include
JAVANATINC = $(JAVA_HOME)/include/linux
ifeq (MSC,$(WIN32))
JAVA_HOME := c:/j2sdk1.4.0
JAVANATINC = $(JAVA_HOME)/include/win32
export PATH:=/cygdrive/$(subst :,,$(JAVA_HOME))/bin:/cygdrive/c/Programme/DevStudio/VC/bin:/cygdrive/c/Programme/DevStudio/SharedIDE/bin/:$(PATH)
T_LIBS = JavaGetline
ARGS = Getline
endif
## normal javac
JAVAC = javac
JC_FLAGS =
## with jikes
#JAVAC = jikes
#JC_FLAGS = -O +E
VERSION = `cat VERSION`
JAR = $(TARGET).jar
APIDIR = ./api
BUILDDIR = ./build
# we build the rpm relative to our build..
RPM_BASE = `pwd`/$(BUILDDIR)/
world : jar build-native
jar: build-java
cd $(BUILDDIR) ; jar -cvmf ../$(MF_STUB) ../$(JAR) *
$(JAR):
cd $(BUILDDIR) ; jar -cvmf ../$(MF_STUB) ../$(JAR) *
build-java: $(BUILDDIR)
cd src ; $(MAKE) JAVAC="$(JAVAC)" JC_FLAGS="$(JC_FLAGS)" java
build-native:
cd src; $(MAKE) T_LIBS="$(T_LIBS)" JAVAINCLUDE="$(JAVAINCLUDE)" \
JAVANATINC="$(JAVANATINC)" native
apidoc: $(APIDIR)
javadoc -sourcepath src -d $(APIDIR) -windowtitle $(WTITLE) \
-doctitle $(DTITLE) -footer $(DFOOTER) -header $(DHEADER) \
-bottom $(DBOTTOM) \
-version -author $(patsubst %,$(PACKROOT)%,$(PACKAGES))
bin-dist: jar apidoc
tar -czf $(TARGET)-$(VERSION)-bin.tgz --exclude "CVS" $(BIN_ADD)
-rm -fr $(TARGET)-$(VERSION)
mkdir $(TARGET)-$(VERSION)
(cd $(TARGET)-$(VERSION); tar -xzf ../$(TARGET)-$(VERSION)-bin.tgz)
tar -cjf $(TARGET)-$(VERSION)-bin.tar.bz2 $(TARGET)-$(VERSION)
-rm -fr $(TARGET)-$(VERSION) $(TARGET)-$(VERSION)-bin.tgz
-version -author org.gnu.readline test
src-dist: clean
tar -czf $(TARGET)-$(VERSION)-src.tgz --exclude "CVS" $(SRC_ADD)
-rm -fr $(TARGET)-$(VERSION)
mkdir $(TARGET)-$(VERSION)
(cd $(TARGET)-$(VERSION); tar -xzf ../$(TARGET)-$(VERSION)-src.tgz)
tar -cjf $(TARGET)-$(VERSION)-src.tar.bz2 $(TARGET)-$(VERSION)
rm -fr $(TARGET)-$(VERSION) $(TARGET)-$(VERSION)-src.tgz
install: jar build-native apidoc
install -D $(JAR) $(DESTDIR)$(JAVALIBDIR)/$(JAR)
install -d $(DESTDIR)$(BINLIBDIR)
install *.so $(DESTDIR)$(BINLIBDIR)
install -d $(DESTDIR)$(DOCDIR)/$(TARGET)-$(VERSION)
cp -r api $(DESTDIR)$(DOCDIR)/$(TARGET)-$(VERSION)
subdirs: $(BUILDDIR) $(METADIR) $(SUBDIRS)
bin-dist: jar build-native apidoc
mkdir -p "$(TARGET)-$(VERSION)"
-cp -r $(BIN_ADD) "$(TARGET)-$(VERSION)"
tar -czf $(TARGET)-$(VERSION)-bin.tar.gz --exclude "CVS" "$(TARGET)-$(VERSION)"
rm -rf "$(TARGET)-$(VERSION)"
$(SUBDIRS):
$(MAKE) -C $@
src-dist: clean
mkdir -p "$(TARGET)-$(VERSION)"
-cp -r $(SRC_ADD) "$(TARGET)-$(VERSION)"
tar -czf $(TARGET)-$(VERSION)-src.tar.gz --exclude "CVS" "$(TARGET)-$(VERSION)"
rm -rf "$(TARGET)-$(VERSION)"
$(APIDIR):
mkdir $(APIDIR)
......@@ -119,10 +132,18 @@ $(BUILDDIR):
$(METADIR):
mkdir $(METADIR)
test: jar
LD_LIBRARY_PATH=$(ROOTDIR) java -jar $(JAR) src/test/tinputrc
rpm: src-dist
mkdir -p $(RPM_BASE)/SPECS $(RPM_BASE)/SOURCES $(RPM_BASE)/BUILD \
$(RPM_BASE)/SRPMS $(RPM_BASE)/RPMS
cp etc/libreadline-java.spec $(RPM_BASE)/SPECS
cp $(TARGET)-$(VERSION)-src.tar.gz $(RPM_BASE)/SOURCES
rpm --define _topdir$(RPM_BASE) -ba $(RPM_BASE)/SPECS/libreadline-java.spec
test: $(JAR) build-native
LD_LIBRARY_PATH=. java -jar $(JAR) src/test/tinputrc $(ARGS)
clean:
-rm -fr $(JAR) $(TARGET)-*.tar.bz2 $(APIDIR) $(BUILDDIR) .rltest_history
for dir in $(SUBDIRS); do \
$(MAKE) -C $$dir clean; \
done
$(MAKE) -C src/native clean
-rm -fr `find . -name "*.o" -o -name "*~"` \
$(JAR) $(TARGET)-*.tar.*z* $(APIDIR) \
$(BUILDDIR) *.so .rltest_history
For release 0.8.0:
- added JScheme completer. Provided by Samer Abdallah
- added support for Getline (Bernhard)
- added support for WIN32
For release 0.7.3:
- don't add history automatically for each line. Provided by Brian Clapper
- removed 1024-byte limitation (useful for long multiline input)
For release 0.7.2:
- no functionality changes; only modified build process a bit
for first libreadline-java release on sourceforge (Henner)
For release 0.7.1:
(provided by Henner Zeller <H.Zeller@acm.org>)
- provide method hasTerminal() to check, if we are run from a terminal
(calls isatty())
- make build process work on Solaris
- provide RPM-spec file
For release 0.7.0:
- bugfix: setCompleter(null) crashed the virtual machine. Now, it sets
the completer back to default behaviour (filename completion)
- native functions added:
o cleanupReadlineImpl() does a reset of the readline lib and the
terminal. Exported as 'void cleanup()' to the java user.
o getLineBufferImpl() returns the current line buffer. This is
usually needed within completers to access the _full_ line (the
completer only gets the last word). Exported as
'String getLineBuffer()' to the java user.
- documentation: complete example for ReadlineCompleter interface;
better indented example for Readline. Added cleanup() in the example.
- declare the 'UnsatisfiedLinkError' in the load() method for
documentation purposes.
(all changes provided by Henner Zeller <H.Zeller@acm.org>)
- added note about Debian-packages in README
- new description on how to make Jython work with JavaReadline
(copied from a posting of Steve Cohen <SteveC@ignitesports.com> to
jython-users@lists.sourceforge.net)
For release 0.6.1:
- bugfix: fallback-solution did not throw EOFException
- bugfix: missing P ("ureJava") in method Readline.byName()
For release 0.6:
- added ReadlineLibrary
- implemented Editline-support
- improved documentation
For release 0.5.2:
- added ReadlineReader (provided by Shane Celis <shane@terrapsring.com>)
- added contrib-directory with
* bsh (provided by Shane Celis <shane@terrapsring.com>)
* jpython (moved from my own website into this package)
- added section about LICENSING ISSUES in README
- updated TODO
For release 0.5.1:
- added word break patch (sets rl_completer_word_break_characters,
provided by David Dribin <dave@dribin.org>)
For release 0.5:
- added code for reading/writing history files
(provided by erik@skiinfo.fr)
- added code for setting a custom completer
(provided by erik@skiinfo.fr)
- added a sample custom completer
- changed ReadlineTest to include new methods
For release 0.43:
- rewrote makefile(s)
- changed directory structure
- moved ReadlineTest to package test
- removed file INSTALL
For release 0.42:
- Moved native code to native subdirectory
- Reorganized makefiles
For release 0.41:
- Changed package name to org.gnu.readline (to be SUN compliant)
For release 0.4:
- Added the following methods: readInitFile() and parseAndBind()
For release 0.3:
- Added UTF-8 to UCS-1 conversion: characters with 8'th bit set are now
supported
For release 0.2:
- Initial public release
......@@ -12,13 +12,12 @@ This version implements basic readline functionality like line editing and
filename completion, which should be just enough for normal use. Not all
functionality is available with all implementations.
Various people contributed code (see the file ChangeLog for details).
Various people contributed code (see the file NEWS for details).
Since I changed some of the code, all bugs are my fault and bugreports
should be adressed to me.
The binary distribution contains the API documentation, a JAR with the
Readline class and the shared libraries libJavaReadline.so and
libJavaEditline.so. It was compiled running Linux 2.2.18 with glibc 2.2.
Readline class and the shared library libJavaReadline.so.
The source distribution contains all the source (I hope this doesn't surprise
you ;-) and a system of makefiles. You need the JDK to compile it.
......@@ -40,6 +39,11 @@ need libedit2 and libedit-dev. Source code is also available, although
I must admit I did not succeed in compiling it on my non-BSD and
non-Debian system :-(
A second Readline replacement is called Getline. This is a very minimal
Readline-clone with a liberal license, and the source-code is provided
in the java-readline distribution. It has the advantage that it
compiles natively on Windows.
COMPILATION
===========
......@@ -49,10 +53,23 @@ variable JAVA_HOME (or edit the makefile). Also, if you don't use jikes,
you should change the variables JAVAC and JAVAC_OPT in the makefile. A better
alternative is to install jikes, it will speed up your development by
a factor of 2-3.
JAVAC and JAVAC_OPT can also be set in the environment or from the
make commandline.
If you want Editline support, use "make T_LIBS=JavaEditline". Getline support
is selected with "make T_LIBS=JavaGetline".
Getline support is also available for (native) WIN32. To build it from
source, you need the cygwin-environment (only necessary because we still
use GNU-make) and a native C-compiler. All necessary variables are configured
in the toplevel Makefile. Before running make, set the WIN32-variable to MSC:
> WIN32=MSC make
If you don't have the Editline libraries installed, use
"make T_LIBS=JavaReadline" (the default creates both JavaReadline and
JavaEditline).
A ready-to-use DLL is in the contrib/win32 directory. Since this feature
is experimental, your feedback is appreciated. If you figure out how to
link JavaReadline with cygwin, please let me know as well (some stubs
are already built into the makefiles).
INSTALLATION
......
package samer.silk;
import java.util.*;
import org.gnu.readline.*;
import jsint.*;
/**
This completer works with the JScheme scheme
interpreter by looking up symbols in the global
namespace. You can register it with the Java
Readline library either in Java or in scheme. Something
like the following should do it:
<pre>
;;; Switches JScheme's input port to a new one that uses
;;; a ReadlineReader with a ">" prompt.
;;; (Note that on some systems, you might get a double
;;; prompt "> >" because JScheme's main loop also prints
;;; a prompt. If this bugs you a lot, you can just write your
;;; own main loop to replace jsint.Scheme.readEvalWriteLoop().)
(set! jsint.Scheme.input$ (jsint.InputPort.
(org.gnu.readline.ReadlineReader. "> "
org.gnu.readline.ReadlineLibrary.GnuReadline$)))
;;; not sure that this helps a lot, but I suppose it's good practice...
(.addShutdownHook (Runtime.getRuntime)
(Thread. (lambda ()
(display "cleaning up readline.\n")
(org.gnu.readline.Readline.cleanup))))
;;; set Readline's completer to a new Scheme-aware one
(org.gnu.readline.Readline.setCompleter (samer.silk.SilkCompleter.))
</pre>
Author: Samer Abdallah (samer.abdallah@elec.qmul.ac.uk)
November 2002
*/
public class SilkCompleter implements ReadlineCompleter {
Iterator it; // iterates over symbols in JScheme hashtable
/** Implementation of abstract function. Finds
possible completions of the given text. */
public String completer(String text, int state)
{
if (state == 0) { // first call to completer(): initialize iterator
// it=Symbol.symbolTable.entrySet().iterator();
it=Symbol.symbolTable.values().iterator();
}
while (it.hasNext()) { // subsequent calls
// Map.Entry entry = (Map.Entry)it.next();
// Symbol symbol=(Symbol)entry.getValue();
// String name=(String)entry.getKey();
Symbol symbol=(Symbol)it.next();
String name=(String)symbol.toString();
// Jscheme seems to keep a lot of undefined symbols
// in the table---pretty much anything you type, actually.
// so we check and only return defined symbols.
if (name.startsWith(text) && symbol.isDefined()) return name;
}
return null; // we reached the last choice.
}
}
\ No newline at end of file
#**************************************************************************
#* Makefile for libJavaReadline.so -- load library for JNI wrapper
#* of GNU readline
#*
#* Copyright (c) 1987-1998 Free Software Foundation, Inc.
#* Java Wrapper Copyright (c) 1998-2001 by Bernhard Bablok (mail@bablokb.de)
#*
#* This program is free software; you can redistribute it and/or modify
#* it under the terms of the GNU Library General Public License as published
#* by the Free Software Foundation; either version 2 of the License or
#* (at your option) any later version.
#*
#* This program is distributed in the hope that it will be useful, but
#* WITHOUT ANY WARRANTY; without even the implied warranty of
#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#* GNU Library General Public License for more details.
#*
#* You should have received a copy of the GNU Library General Public License
#* along with this program; see the file COPYING.LIB. If not, write to
#* the Free Software Foundation Inc., 59 Temple Place - Suite 330,
#* Boston, MA 02111-1307 USA
#***************************************************************************
#
# $Author: Bablokb $
# $Revision: 1.2 $
#
SUBDIRS := $(shell find . -type d -not -name "." -not -name "CVS" -maxdepth 1)
.PHONY: all clean subdirs $(SUBDIRS)
META-FILES :=
META_TARGETS := $(META-FILES:%=$(METADIR)/%)
all: subdirs $(META_TARGETS)
subdirs: $(SUBDIRS)
$(SUBDIRS):
-mkdir $(METADIR)/$@
$(MAKE) -C $@ METADIR=$(METADIR)/$@
$(METADIR)/%: %
cp -vu $< $(METADIR)
clean:
# for dir in $(SUBDIRS); do \
# $(MAKE) -C $$dir clean; \
# done
\ No newline at end of file
%define version 0.8.0
Summary: java wrapper for the GNU-readline library
Copyright: GNU Lesser General Public License
Group: Development/Java
Name: libreadline-java
Prefix: /usr
Provides: java_readline
Packager: Henner Zeller <H.Zeller@acm.org>
Release: 1
Source: %{name}-%{version}-src.tar.gz
URL: http://java-readline.sourceforge.net/
Version: %{version}
Buildroot: /tmp/javareadline-build
BuildRequires: readline-devel
%description
This is a Java-wrapper for the GNU-Readline using the
Java Native Interface (JNI). It allows to write console Java applications
that provide commandline editing functions like history and TAB-completion.
%prep
%setup -q
%build
%install
rm -fr $RPM_BUILD_ROOT
make DESTDIR=$RPM_BUILD_ROOT T_LIBS="JavaReadline" install
%clean
rm -rf $RPM_BUILD_ROOT
%files
%defattr(-,root,root)
%{prefix}/lib/libJavaReadline.so
%{prefix}/share/java/%{name}.jar
%doc NEWS ChangeLog README README.1st VERSION api
#**************************************************************************
#* Makefile for libJavaReadline.so -- load library for JNI wrapper
#* of GNU readline
#*
#* Copyright (c) 1987-1998 Free Software Foundation, Inc.
#* Java Wrapper Copyright (c) 1998-2001 by Bernhard Bablok (mail@bablokb.de)
#*
#* This program is free software; you can redistribute it and#or modify
#* it under the terms of the GNU Library General Public License as published
#* by the Free Software Foundation; either version 2 of the License or
#* (at your option) any later version.
#*
#* This program is distributed in the hope that it will be useful, but
#* WITHOUT ANY WARRANTY; without even the implied warranty of
#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#* GNU Library General Public License for more details.
#*
#* You should have received a copy of the GNU Library General Public License
#* along with this program; see the file COPYING.LIB. If not, write to
#* the Free Software Foundation Inc., 59 Temple Place - Suite 330,
#* Boston, MA 02111-1307 USA
#***************************************************************************
#
# $Author: Bablokb $
# $Revision: 1.2 $
#
SUBDIRS := $(shell find . -type d -not -name "." -not -name "CVS" -maxdepth 1)
export SRCROOT := $(shell pwd)
BUILD=../build
.PHONY: subdirs $(SUBDIRS) clean
all : java native
subdirs: $(SUBDIRS)
java: always $(BUILD)
$(JAVAC) $(JC_FLAGS) -d $(BUILD) `find . -name "*.java"`
$(SUBDIRS):
$(MAKE) -C $@
native: always
cd native ; $(MAKE) T_LIBS="$(T_LIBS)" JAVAINCLUDE="$(JAVAINCLUDE)" \
JAVANATINC="$(JAVANATINC)" all
clean:
for dir in $(SUBDIRS); do \
$(MAKE) -C $$dir clean; \
done
$(BUILD):
mkdir $@
always:
#**************************************************************************
#* Makefile for libJavaReadline.so -- load library for JNI wrapper
#* of GNU readline
#*
#* Copyright (c) 1987-1998 Free Software Foundation, Inc.
#* Java Wrapper Copyright (c) 1998-2001 by Bernhard Bablok (mail@bablokb.de)
#*
#* This program is free software; you can redistribute it and#or modify
#* it under the terms of the GNU Library General Public License as published
#* by the Free Software Foundation; either version 2 of the License or
#* (at your option) any later version.
#*
#* This program is distributed in the hope that it will be useful, but
#* WITHOUT ANY WARRANTY; without even the implied warranty of
#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#* GNU Library General Public License for more details.
#*
#* You should have received a copy of the GNU Library General Public License
#* along with this program; see the file COPYING.LIB. If not, write to
#* the Free Software Foundation Inc., 59 Temple Place - Suite 330,
#* Boston, MA 02111-1307 USA
#***************************************************************************
#
# $Author: Bablokb $
# $Revision: 1.2 $
#
SUBDIRS := $(shell find . -type d -not -name "." -not -name "CVS" -maxdepth 1)
PACKDIR := $(CLASSDIR)/$(shell echo `pwd` | sed -e's!.*/src/!!')
.PHONY: all classes subdirs clean $(SUBDIRS)
JAVA_SOURCES := $(wildcard *.java)
JAVA_TARGETS := $(JAVA_SOURCES:%.java=$(PACKDIR)/%.class)
GIF_SOURCES := $(wildcard *.gif)
GIF_TARGETS := $(GIF_SOURCES:%=$(PACKDIR)/%)
all: $(PACKDIR) subdirs $(JAVA_TARGETS) $(GIF_TARGETS)
subdirs: $(SUBDIRS)
$(PACKDIR):
mkdir $(PACKDIR)
$(SUBDIRS):
$(MAKE) -C $@
$(PACKDIR)/%.class: %.java
$(JAVAC) $(JAVAC_OPT) $< -d $(CLASSDIR)
$(PACKDIR)/%.gif: %.gif
cp -vu $< $(PACKDIR)
clean:
......@@ -23,29 +23,96 @@
#
# Makefile for JNI-library libJava*.so
#
# $Author: Bablokb $
# $Revision: 1.9 $
# $Author: bablokb $
# $Revision: 1.13 $
#
.PHONY: all lib clean
export
SO := $(patsubst %,$(ROOTDIR)/lib%.so,$(T_LIBS))
.PHONY: org_gnu_readline_Readline.o
ROOTDIR=../..
BUILDDIR=$(ROOTDIR)/build
ifeq (MSC,$(WIN32))
INCLUDES = -I "c:/Programme/DevStudio/VC/include" \
-I $(JAVAINCLUDE) -I $(JAVANATINC)
LIB = "c:/Programme/DevStudio/VC/lib"
CC = cl
OBJ_EXT := obj
LIB_PRE :=
LIB_EXT := dll
CFLAGS=-DWIN32=$(WIN32) -D__IBMC__
else
INCLUDES = -I $(JAVAINCLUDE) -I $(JAVANATINC)
LIBPATH = -L/usr/lib/termcap
JavaReadline_LIBS = -lreadline -ltermcap -lhistory
JavaEditline_LIBS = -ledit -ltermcap
ifeq (cygwin,$(WIN32))
JavaGetline_LIBS = -lcygwin
endif
CC = gcc
OBJ_EXT := o
LIB_PRE := lib
LIB_EXT := so
CFLAGS=-fPIC -DPOSIX
endif
OBJECTS := org_gnu_readline_Readline.$(OBJ_EXT)
ifeq ($(TG),JavaGetline)
OBJECTS += getline.$(OBJ_EXT)
endif
all: $(T_LIBS)
lib: $(ROOTDIR)/lib$(TG).so
lib: $(ROOTDIR)/$(LIB_PRE)$(TG).$(LIB_EXT)
JavaReadline:
make TG=$@ lib
JavaEditline:
make TG=$@ lib
Java%:
JavaGetline:
make TG=$@ lib
$(ROOTDIR)/lib%.so: org_gnu_readline_Readline.c org_gnu_readline_Readline.h
$(ROOTDIR)/$(LIB_PRE)$(TG).$(LIB_EXT): $(OBJECTS)
ifeq (MSC,$(WIN32))
$(CC) $(INCLUDES) -LD $(OBJECTS) -Fe$@
else
ifeq (CYGWIN,$(WIN32))
$(CC) -s -W1,--base-file,$(ROOTDIR)/lib$(TG).base -o $@ \
$(OBJECTS) -W1,-e,_readline_init@12
dlltool --base-file $(ROOTDIR)/lib$(TG).base \
--def $(ROOTDIR)/lib$(TG).def \
--output-exp $(ROOTDIR)/lib$(TG).exp \
--dllname $(ROOTDIR)/lib$(TG).dll
$(CC) -s -W1,--base-file $(ROOTDIR)/lib$(TG).base,$(ROOTDIR)/lib$(TG).exp \
-o $@ $(OBJECTS) -W1,-e,_readline_init@12
dlltool --base-file $(ROOTDIR)/lib$(TG).base \
--def $(ROOTDIR)/lib$(TG).def \
--output-exp $(ROOTDIR)/lib$(TG).exp \
--dllname $(ROOTDIR)/lib$(TG).dll
$(CC) -W1,$(ROOTDIR)/lib$(TG).exp -o $@ \
$(OBJECTS) -W1,-e,_readline_init@12
else
$(CC) -shared $(OBJECTS) $(LIBPATH) $($(TG)_LIBS) -o $@
endif
endif
getline.$(OBJ_EXT): getline.c
$(CC) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) -D$(TG) -c getline.c
org_gnu_readline_Readline.$(OBJ_EXT): org_gnu_readline_Readline.h \
org_gnu_readline_Readline.c
$(CC) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) -D$(TG) \
-c org_gnu_readline_Readline.c
gcc -shared $(LIBPATH) $($(TG)_LIBS) org_gnu_readline_Readline.o -o $@
-c org_gnu_readline_Readline.c
org_gnu_readline_Readline.h: $(BUILDDIR)/org/gnu/readline/Readline.class
javah -jni org.gnu.readline.Readline
javah -classpath $(BUILDDIR) -jni org.gnu.readline.Readline
touch org_gnu_readline_Readline.h
clean:
-rm -f $(SO) org_gnu_readline_Readline.h org_gnu_readline_Readline.o
\ No newline at end of file
-rm -f org_gnu_readline_Readline.h \
org_gnu_readline_Readline.$(OBJ_EXT) getline.$(OBJ_EXT)
This diff is collapsed.
#ifndef GETLINE_H
#define GETLINE_H
/* unix systems can #define POSIX to use termios, otherwise
* the bsd or sysv interface will be used
*/
/* readline compatibility stuff */
extern char* rl_readline_name; /* unused by getline */
#define add_history(buffer) gl_histadd(buffer)
#define readline(buffer) getline(buffer)
#define clear_history() hist_init()
#define using_history() hist_init()
#if __STDC__ > 0
#include <stddef.h>
typedef size_t (*gl_strwidth_proc)(char *);
char *getline(char *); /* read a line of input */
void gl_setwidth(int); /* specify width of screen */
void gl_histadd(char *); /* adds entries to hist */
void gl_strwidth(gl_strwidth_proc); /* to bind gl_strlen */
void hist_init();
extern int (*gl_in_hook)(char *);
extern int (*gl_out_hook)(char *);
extern int (*gl_tab_hook)(char *, int, int *);