[pylucene-dev] RAMDirectory support?
Andi Vajda
vajda at osafoundation.org
Fri Jun 25 09:35:28 PDT 2004
Even better with the attachments. Oops.
Andi..
-------------- next part --------------
/* ====================================================================
* Copyright (c) 2004 Open Source Applications Foundation.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
* ====================================================================
*/
%module PyLucene
%pythoncode %{
for fn in dir(_PyLucene):
if fn.startswith("delete_"):
setattr(_PyLucene, fn, lambda self: None)
%}
%{
#include <gcj/cni.h>
#include <java/lang/Object.h>
#include <java/lang/Thread.h>
#include <java/lang/ThreadGroup.h>
#include <java/lang/Runnable.h>
#include <java/lang/String.h>
#include <java/lang/Throwable.h>
#include <java/io/StringWriter.h>
#include <java/io/PrintWriter.h>
#include <java/io/Reader.h>
#include <java/io/File.h>
#ifdef _WITH_DB_DIRECTORY
#include "com/sleepycat/db/DbEnv.h"
#include "com/sleepycat/db/Db.h"
#include "com/sleepycat/db/DbTxn.h"
#endif
#include "org/apache/lucene/store/Directory.h"
#include "org/apache/lucene/store/FSDirectory.h"
#include "org/apache/lucene/store/RAMDirectory.h"
#ifdef _WITH_DB_DIRECTORY
#include "org/apache/lucene/store/db/DbDirectory.h"
#endif
#include "org/apache/lucene/analysis/Analyzer.h"
#include "org/apache/lucene/analysis/SimpleAnalyzer.h"
#include "org/apache/lucene/analysis/StopAnalyzer.h"
#include "org/apache/lucene/analysis/standard/StandardAnalyzer.h"
#include "org/apache/lucene/document/Field.h"
#include "org/apache/lucene/document/Document.h"
#include "org/apache/lucene/index/IndexWriter.h"
#include "org/apache/lucene/index/IndexReader.h"
#include "org/apache/lucene/index/Term.h"
#include "org/apache/lucene/index/TermDocs.h"
#include "org/apache/lucene/index/TermEnum.h"
#include "org/apache/lucene/index/TermPositions.h"
#include "org/apache/lucene/queryParser/QueryParser.h"
#include "org/apache/lucene/search/Searcher.h"
#include "org/apache/lucene/search/Query.h"
#include "org/apache/lucene/search/Hits.h"
#include "org/apache/lucene/search/IndexSearcher.h"
#include "org/osafoundation/io/PythonReader.h"
#ifdef _WITH_DB_DIRECTORY
#include <db.h>
/* from Python's _bsddb.c */
typedef struct {
PyObject_HEAD
DB_ENV *db_env;
} DBEnvObject;
typedef struct {
PyObject_HEAD
DB *db;
} DBObject;
typedef struct {
PyObject_HEAD
DB_TXN *txn;
} DBTxnObject;
typedef ::com::sleepycat::db::DbEnv *jdbenv;
typedef ::com::sleepycat::db::Db *jdb;
typedef ::com::sleepycat::db::DbTxn *jdbtxn;
#endif
typedef ::java::io::Reader *jreader;
typedef JArray<jstring> *jstringArray;
#ifndef WIN32
extern "C" {
void *GC_start_routine(void *arg);
}
static java::lang::Thread *nextThread;
static void *run(void *pyThread)
{
_Jv_AttachCurrentThread(nextThread);
nextThread = new java::lang::Thread();
return PyObject_CallMethod((PyObject *) pyThread, "run", NULL);
}
void *attachCurrentThread(PyObject *pyThread)
{
struct start_info {
void *(*start_routine)(void *);
void *arg;
unsigned int flags;
unsigned int registered;
} si;
si.registered = 0;
si.start_routine = run;
si.arg = pyThread;
si.flags = 0;
return GC_start_routine(&si);
}
#else
void *attachCurrentThread(PyObject *pyThread)
{
JvAttachCurrentThread(NULL, NULL);
return PyObject_CallMethod((PyObject *) pyThread, "run", NULL);
}
#endif
%}
%typemap(in) jstring {
if ($input == Py_None)
$1 = NULL;
else
$1 = JvNewStringUTF(PyString_AsString($input));
}
%typemap(out) jstring {
if (!$1)
$result = Py_None;
else
{
jint len = JvGetStringUTFLength($1);
char buf[len + 1];
JvGetStringUTFRegion($1, 0, len, buf);
buf[len] = '\0';
$result = Py_BuildValue("s#", buf, len);
}
}
%typemap(in) jboolean {
$1 = PyObject_IsTrue($input);
}
%typemap(out) jboolean {
$result = PyBool_FromLong((long) $1);
}
%typemap(in) jreader {
if ($input == Py_None)
$1 = NULL;
else
{
jlong ptr;
*(PyObject **) &ptr = (PyObject *) $input;
$1 = new org::osafoundation::io::PythonReader(ptr);
}
}
%typemap(in) jstringArray {
if ($input == Py_None)
{
$1 = (jstringArray)
JvNewObjectArray(0, &::java::lang::String::class$, NULL);
}
else if (!PySequence_Check($input))
{
PyErr_SetString(PyExc_ValueError, "Expected a sequence");
return NULL;
}
else
{
int len = PySequence_Length($input);
jstringArray array = (jstringArray)
JvNewObjectArray(len, &::java::lang::String::class$, NULL);
jstring *strings = elements(array);
for (int i = 0; i < len; i++) {
char *s = PyString_AsString(PySequence_GetItem($input, i));
strings[i] = JvNewStringUTF(s);
}
$1 = array;
}
}
%typemap(typecheck) jstringArray = PyObject *;
#ifdef _WITH_DB_DIRECTORY
%typemap(in) jdbenv {
if ($input == Py_None)
$1 = NULL;
else
{
jlong ptr;
*(DB_ENV **) &ptr = ((DBEnvObject *) $input)->db_env;
$1 = new ::com::sleepycat::db::DbEnv(ptr, 0);
}
}
%typemap(in) jdb {
if ($input == Py_None)
$1 = NULL;
else
{
jlong ptr;
*(DB **) &ptr = ((DBObject *) $input)->db;
$1 = new ::com::sleepycat::db::Db(ptr, 0);
}
}
%typemap(in) jdbtxn {
if ($input == Py_None)
$1 = NULL;
else
{
jlong ptr;
*(DB_TXN **) &ptr = ((DBTxnObject *) $input)->txn;
$1 = new com::sleepycat::db::DbTxn(ptr, 0);
}
}
#endif
typedef long jint;
typedef long long jlong;
typedef char jbyte;
typedef float jfloat;
%exception {
try {
$action
if (PyErr_Occurred())
return NULL;
} catch (java::lang::Throwable *e) {
java::io::StringWriter *buffer = new java::io::StringWriter();
java::io::PrintWriter *writer = new java::io::PrintWriter(buffer);
e->printStackTrace(writer);
writer->close();
jstring message = buffer->toString();
jint len = JvGetStringUTFLength(message);
char buf[len + 1];
JvGetStringUTFRegion(message, 0, len, buf);
buf[len] = '\0';
PyErr_SetString(PyExc_ValueError, buf);
return NULL;
}
}
namespace java {
namespace lang {
class Object {
virtual jstring toString();
};
}
namespace io {
%nodefault;
class Reader : public ::java::lang::Object {
};
%makedefault;
}
}
void *attachCurrentThread(PyObject *pyThread);
namespace org {
namespace apache {
namespace lucene {
namespace store {
class Directory : public ::java::lang::Object {
Directory();
};
%nodefault;
class FSDirectory : public Directory {
public:
static FSDirectory *getDirectory(jstring, jboolean);
};
%makedefault;
class RAMDirectory : public Directory {
public:
RAMDirectory();
RAMDirectory(Directory *);
RAMDirectory(jstring);
};
#ifdef _WITH_DB_DIRECTORY
namespace db {
class DbDirectory : public Directory {
public:
DbDirectory(jdbtxn, jdb, jdb, jint);
};
}
#endif
}
namespace analysis {
class Analyzer : public ::java::lang::Object {
};
class SimpleAnalyzer : public Analyzer {
public:
SimpleAnalyzer();
};
class StopAnalyzer : public Analyzer {
public:
StopAnalyzer();
StopAnalyzer(jstringArray);
};
namespace standard {
class StandardAnalyzer : public Analyzer {
public:
StandardAnalyzer();
};
}
}
namespace document {
class Field : public ::java::lang::Object {
public:
Field(jstring, jstring, jboolean, jboolean, jboolean);
static Field *Text(jstring, jreader);
static Field *UnIndexed(jstring, jstring);
static Field *UnStored(jstring, jstring);
static Field *Keyword(jstring, jstring);
};
class Document : public ::java::lang::Object {
public:
Document();
void add(Field *);
jstring get(jstring);
};
}
namespace index {
class IndexWriter : public ::java::lang::Object {
public:
IndexWriter(::org::apache::lucene::store::Directory *, ::org::apache::lucene::analysis::Analyzer *, jboolean);
virtual void close();
virtual void addDocument(::org::apache::lucene::document::Document *);
virtual void optimize();
jint maxFieldLength;
jint mergeFactor;
jint minMergeDocs;
jint maxMergeDocs;
};
class Term : public ::java::lang::Object {
public:
Term(jstring, jstring);
jstring field();
jstring text();
jint compareTo(Term *);
jstring toString();
};
%nodefault;
class TermEnum : public ::java::lang::Object {
public:
virtual jboolean next();
virtual Term *term();
virtual jint docFreq();
virtual void close();
};
class TermDocs : public ::java::lang::Object {
public:
virtual void seek(Term *);
virtual void seek(TermEnum *);
virtual jint doc();
virtual jint freq();
virtual jboolean next();
virtual jboolean skipTo(jint);
virtual void close();
};
class TermPositions : public TermDocs {
public:
virtual jint nextPosition();
};
class IndexReader : public ::java::lang::Object {
public:
static IndexReader *open(jstring);
static IndexReader *open(::org::apache::lucene::store::Directory *);
static jlong lastModified(jstring);
static jlong lastModified(::org::apache::lucene::store::Directory *);
static jlong getCurrentVersion(jstring);
static jlong getCurrentVersion(::org::apache::lucene::store::Directory *);
static jboolean indexExists(jstring);
static jboolean indexExists(::org::apache::lucene::store::Directory *);
virtual jint numDocs();
virtual jint maxDoc();
virtual ::org::apache::lucene::document::Document *document (jint);
virtual jboolean isDeleted(jint);
virtual jboolean hasDeletions();
virtual void setNorm(jint, jstring, jbyte);
virtual void setNorm(jint, jstring, jfloat);
virtual TermEnum *terms();
virtual TermEnum *terms(Term *);
virtual jint docFreq(Term *);
virtual TermDocs *termDocs(Term *);
virtual TermDocs *termDocs();
virtual TermPositions *termPositions(Term *);
virtual TermPositions *termPositions();
void deleteDocument(jint);
jint deleteDocuments(Term *);
virtual void undeleteAll();
void close();
static jboolean isLocked(::org::apache::lucene::store::Directory *);
static jboolean isLocked(jstring);
static void unlock(::org::apache::lucene::store::Directory *);
};
%makedefault;
}
namespace search {
%nodefault;
class Query : public ::java::lang::Object {
public:
virtual void setBoost(jfloat);
virtual jfloat getBoost();
virtual jstring toString();
};
class Hits : public ::java::lang::Object {
public:
jint length();
::org::apache::lucene::document::Document *doc(jint);
jfloat score(jint);
jint id(jint);
};
class Searcher : public ::java::lang::Object {
public:
Hits *search(Query *);
};
%makedefault;
class IndexSearcher : public Searcher {
public:
IndexSearcher(::org::apache::lucene::store::Directory *);
virtual void close();
};
}
namespace queryParser {
%nodefault;
class QueryParser : public ::java::lang::Object {
public:
static ::org::apache::lucene::search::Query *parse(jstring, jstring, ::org::apache::lucene::analysis::Analyzer *);
};
%makedefault;
}
}
}
}
%init %{
JvCreateJavaVM(NULL);
JvAttachCurrentThread(NULL, NULL);
#ifndef WIN32
nextThread = new java::lang::Thread();
#endif
JvInitClass(&org::apache::lucene::document::Field::class$);
JvInitClass(&org::apache::lucene::queryParser::QueryParser::class$);
JvInitClass(&org::apache::lucene::store::FSDirectory::class$);
JvInitClass(&org::apache::lucene::index::IndexReader::class$);
%}
-------------- next part --------------
# Makefile for building PyLucene
#
# Supported operating systems: Linux, Mac OS X and Windows.
# See INSTALL file for requirements.
#
# Steps to build
# 1. Edit the sections below as documented
# 2. make all
# 3. make install
#
# The install target installs the PyLucene python extension in python's
# site-packages directory. On Mac OS X, it also installs the gcj runtime
# libraries into $(PREFIX)/lib. When Berkeley DB support is enabled, the
# libdb_java JNI shared library is installed with your Berkeley DB binaries
# as follows:
# - on Unix (Mac OS X and Linux), where your DB binaries are installed
# - on Windows, where your DB binaries are built
#
# To successfully import the PyLucene extension into Python, all required
# libraries need to be found. If the locations you chose are non-standard,
# the relevant DYLD_LIBRARY_PATH (Mac OS X), LD_LIBRARY_PATH (Linux), or
# PATH (Windows) need to be set accordingly.
#
#
# You need to verify that the versions of python and Berkeley DB, should
# you require it, are correct below.
#
VERSION=0.5
LUCENE_VER=1.3-final
PYTHON_VER=2.3
DB_VER=4.2.52
PYLUCENE:=$(shell pwd)
LUCENE=$(PYLUCENE)/lucene-$(LUCENE_VER)
STORE=$(PYLUCENE)/store-$(LUCENE_VER)
#
# You need to uncomment and edit the variables below in the section
# corresponding to your operating system.
#
# PREFIX: where programs are normally installed on your system (Unix).
# PREFIX_PYTHON: where your version of python is installed.
# GCJ_HOME: where GCC/GCJ is installed.
# Windows drive-absolute paths need to be expressed cygwin style.
#
# Uncommenting DB enables Berkeley DB support. The variables below are only
# required for Berkeley DB support and should remain commented if Berkekey
# DB support is not desired.
#
# DB: where your sources for Berkeley DB are installed.
# PREFIX_DB: where your binaries for Berkeley DB are installed (Unix).
# PREFIX_DB: where your sources for Berkeley DB are installed (Windows).
#
# Mac OS X (Darwin)
#PREFIX=/usr/local
#PREFIX_PYTHON=/Library/Frameworks/Python.framework/Versions/$(PYTHON_VER)
#SWIG=$(PREFIX)/bin/swig
#GCJ_HOME=/usr/local/gcc-3.4.0
#DB=$(PYLUCENE)/db-$(DB_VER)
#PREFIX_DB=/usr/local/BerkeleyDB.4.2
# Linux
#PREFIX=/usr/local
#PREFIX_PYTHON=$(PREFIX)
#SWIG=$(PREFIX)/bin/swig
#GCJ_HOME=/usr/local
#DB=$(PYLUCENE)/db-$(DB_VER)
#PREFIX_DB=$(PREFIX)/BerkeleyDB.4.2
# Windows
#PREFIX_PYTHON=/cygdrive/o/Python-2.3.2
#SWIG=/cygdrive/c/utils/bin/swig.exe
#GCJ_HOME=/cygdrive/o/mingw-3.1
#DB=/cygdrive/o/db-$(DB_VER)
#PREFIX_DB=$(DB)
#
# No edits required below
#
OS=$(shell uname)
ifeq ($(findstring CYGWIN,$(OS)),CYGWIN)
OS=Cygwin
endif
ifeq ($(DEBUG),1)
COMP_OPT=DEBUG=1
SUFFIX=d
_SUFFIX=_d
BINDIR=debug
else
COMP_OPT=
SUFFIX=
_SUFFIX=
BINDIR=release
endif
ifeq ($(OS),Darwin)
PYTHON_SITE=$(PREFIX_PYTHON)/lib/python$(PYTHON_VER)/site-packages
PYTHON_INC=$(PREFIX_PYTHON)/include/python$(PYTHON_VER)
PYLUCENE_LIB=$(BINDIR)/_PyLucene.so
LIBDB_JAVA_LIB=$(BINDIR)/libdb_java-4.2.jnilib
ifeq ($(DEBUG),1)
CCFLAGS=-O -g
LDFLAGS=-g
else
CCFLAGS=-O2
LDFLAGS=
endif
else
ifeq ($(OS),Linux)
PYTHON_SITE=$(PREFIX_PYTHON)/lib/python$(PYTHON_VER)/site-packages
PYTHON_INC=$(PREFIX_PYTHON)/include/python$(PYTHON_VER)
PYLUCENE_LIB=$(BINDIR)/_PyLucene.so
LIBDB_JAVA_LIB=$(BINDIR)/libdb_java-4.2.so
ifeq ($(DEBUG),1)
CCFLAGS=-O -g -fPIC
LDFLAGS=-g
else
CCFLAGS=-O2 -fPIC
LDFLAGS=
endif
else
ifeq ($(OS),Cygwin)
PYTHON_SITE=`cygpath -aw $(PREFIX_PYTHON)/Lib/site-packages`
PYTHON_INC=`cygpath -aw $(PREFIX_PYTHON)/Include`
PYTHON_PC=`cygpath -aw $(PREFIX_PYTHON)/PC`
PYLUCENE_LIB=$(BINDIR)/_PyLucene$(_SUFFIX).pyd
LIBDB_JAVA_LIB=$(BINDIR)/libdb_java42$(SUFFIX).dll
ifeq ($(DEBUG),1)
CCFLAGS=-O -g
LDFLAGS=-g
else
CCFLAGS=-O2
LDFLAGS=
endif
else
PYTHON=unknown
PYTHON_SITE=unknown
endif
endif
endif
CLASSES=$(BINDIR)/classes
CC=$(GCJ_HOME)/bin/gcc
CXX=$(GCJ_HOME)/bin/g++
JCC=$(GCJ_HOME)/bin/gcj
JCCH=$(GCJ_HOME)/bin/gcjh
LUCENE_SRCS=`find lucene-$(LUCENE_VER)/src/java -name '*.java' -print`
OBJS=$(BINDIR)/lucene.o $(BINDIR)/reader.java.o $(BINDIR)/reader.cpp.o
LIBS=$(PYLUCENE_LIB)
default: all
env:
ifndef PREFIX_PYTHON
@echo Operating system is $(OS)
@echo You need to edit that section of the Makefile
@false
else
@true
endif
$(BINDIR):
mkdir -p $(BINDIR)/classes
$(LUCENE):
tar xvzf $(LUCENE)-src.tar.gz
$(STORE):
tar xvzf $(STORE)-src.tar.gz
sources: $(LUCENE) $(STORE)
apply:: patches.lucene
cd $(LUCENE)/..; patch -Nup0 < $(PYLUCENE)/patches.lucene; echo ok
ifdef DB
DISTRIB=PyLucene-db-$(VERSION)
apply:: patches.db
cd $(DB)/..; patch -Nup0 < $(PYLUCENE)/patches.db; echo ok
ifeq ($(OS),Cygwin)
DB_SRCS=`find $(DB)/java/src/com/sleepycat/db -regex '.*/db/[^/]*java' -exec cygpath -aw {} \;`
DB_CONST=`cygpath -aw $(DB)/java/src/com/sleepycat/db/$(BINDIR)/DbConstants.java`
DB_INC=-I`cygpath -aw $(PREFIX_DB)` -I`cygpath -aw $(PREFIX_DB)/dbinc` -I`cygpath -aw $(PREFIX_DB)/build_win32`
else
DB_SRCS=`find $(DB)/java/src/com/sleepycat/db -regex '.*/db/[^/]*java'`
DB_CONST=$(DB)/java/src/com/sleepycat/db/$(BINDIR)/DbConstants.java
DB_INC=-I$(PREFIX_DB)/include -I$(DB) -I$(DB)/build_unix
endif
STORE_SRCS=`find store-$(LUCENE_VER) -name '*.java' -print`
OBJS:=$(BINDIR)/store.o $(BINDIR)/db_const.o $(BINDIR)/db.o $(OBJS)
LIBS:=$(LIBDB_JAVA_LIB) $(LIBS)
SWIG_OPT=-D_WITH_DB_DIRECTORY=1
$(BINDIR)/db_const.o:
$(JCC) -C -d $(CLASSES) $(DB_CONST)
$(JCC) -fjni $(CCFLAGS) -c -o $(BINDIR)/db_const.o $(DB_CONST)
$(BINDIR)/db.o: $(BINDIR)/db_const.o
$(JCC) -C -d $(CLASSES) --classpath=$(CLASSES) $(DB_SRCS)
$(JCC) -fjni $(CCFLAGS) -c -o $(BINDIR)/db.o --classpath=$(CLASSES) $(DB_SRCS)
ifeq ($(OS),Darwin)
# with gcc 3.4-20040407, libdb_java segfaults when compiled with -O2
$(LIBDB_JAVA_LIB):
$(CC) -shared -bundle -o $@ -O $(LDFLAGS) -I$(GCJ_HOME)/include $(DB_INC) $(DB)/libdb_java/db_java_wrap.c $(PREFIX_DB)/lib/libdb-4.2.dylib
else
ifeq ($(OS),Linux)
$(LIBDB_JAVA_LIB):
$(CC) -shared -o $@ $(CCFLAGS) $(DB_INC) $(DB)/libdb_java/db_java_wrap.c $(PREFIX_DB)/lib/libdb-4.2.so
else
ifeq ($(OS),Cygwin)
$(LIBDB_JAVA_LIB):
$(CC) -shared -o $@ $(CCFLAGS) -D_NO_OLDNAMES -DGCJ $(DB_INC) `cygpath -aw $(DB)/libdb_java/db_java_wrap.c` `cygpath -aw $(PREFIX_DB)/build_win32/$(BINDIR)/libdb42$(SUFFIX).dll`
endif
endif
endif
$(BINDIR)/store.o: $(BINDIR)/db.o $(BINDIR)/lucene.o
$(JCC) -C -d $(CLASSES) --classpath=$(CLASSES) $(STORE_SRCS)
$(JCC) -fjni $(CCFLAGS) -c -o $(BINDIR)/store.o --classpath=$(CLASSES) $(STORE_SRCS)
else
DISTRIB=PyLucene-$(VERSION)
SWIG_OPT=
DB_INC=
endif
$(BINDIR)/lucene.o:
$(JCC) --encoding=UTF-8 -C -d $(CLASSES) $(LUCENE_SRCS)
$(JCC) --encoding=UTF-8 $(CCFLAGS) -c -o $(BINDIR)/lucene.o $(LUCENE_SRCS)
$(BINDIR)/reader.java.o: java/org/osafoundation/io/PythonReader.java
$(JCC) -C -d $(CLASSES) java/org/osafoundation/io/PythonReader.java
$(JCC) $(CCFLAGS) -I$(GCJ_HOME)/include -c -o $(BINDIR)/reader.java.o java/org/osafoundation/io/PythonReader.java
ifeq ($(OS),Cygwin)
$(BINDIR)/reader.cpp.o: $(CLASSES)/org/osafoundation/io/PythonReader.h cpp/PythonReader.cpp $(BINDIR)/reader.java.o
$(JCC) -I$(PYTHON_PC) -I$(PYTHON_INC) -I$(GCJ_HOME)/include -I$(CLASSES) $(CCFLAGS) -c -o $(BINDIR)/reader.cpp.o cpp/PythonReader.cpp
else
$(BINDIR)/reader.cpp.o: $(CLASSES)/org/osafoundation/io/PythonReader.h cpp/PythonReader.cpp $(BINDIR)/reader.java.o
$(JCC) -I$(PYTHON_INC) -I$(GCJ_HOME)/include -I$(CLASSES) $(CCFLAGS) -c -o $(BINDIR)/reader.cpp.o cpp/PythonReader.cpp
endif
$(CLASSES)/org/osafoundation/io/PythonReader.h:
ifdef DB
$(JCCH) -d $(CLASSES) --classpath=$(CLASSES) com.sleepycat.db.DbEnv
$(JCCH) -d $(CLASSES) --classpath=$(CLASSES) com.sleepycat.db.Db
$(JCCH) -d $(CLASSES) --classpath=$(CLASSES) com.sleepycat.db.DbTxn
endif
$(JCCH) -d $(CLASSES) --classpath=$(CLASSES) org.apache.lucene.store.Directory
$(JCCH) -d $(CLASSES) --classpath=$(CLASSES) org.apache.lucene.store.FSDirectory
$(JCCH) -d $(CLASSES) --classpath=$(CLASSES) org.apache.lucene.store.RAMDirectory
ifdef DB
$(JCCH) -d $(CLASSES) --classpath=$(CLASSES) org.apache.lucene.store.db.DbDirectory
endif
$(JCCH) -d $(CLASSES) --classpath=$(CLASSES) org.apache.lucene.analysis.Analyzer
$(JCCH) -d $(CLASSES) --classpath=$(CLASSES) org.apache.lucene.analysis.SimpleAnalyzer
$(JCCH) -d $(CLASSES) --classpath=$(CLASSES) org.apache.lucene.analysis.StopAnalyzer
$(JCCH) -d $(CLASSES) --classpath=$(CLASSES) org.apache.lucene.analysis.standard.StandardAnalyzer
$(JCCH) -d $(CLASSES) --classpath=$(CLASSES) org.apache.lucene.document.Field
$(JCCH) -d $(CLASSES) --classpath=$(CLASSES) org.apache.lucene.document.Document
$(JCCH) -d $(CLASSES) --classpath=$(CLASSES) org.apache.lucene.index.IndexWriter
$(JCCH) -d $(CLASSES) --classpath=$(CLASSES) org.apache.lucene.index.IndexReader
$(JCCH) -d $(CLASSES) --classpath=$(CLASSES) org.apache.lucene.index.Term
$(JCCH) -d $(CLASSES) --classpath=$(CLASSES) org.apache.lucene.index.TermDocs
$(JCCH) -d $(CLASSES) --classpath=$(CLASSES) org.apache.lucene.index.TermEnum
$(JCCH) -d $(CLASSES) --classpath=$(CLASSES) org.apache.lucene.index.TermPositions
$(JCCH) -d $(CLASSES) --classpath=$(CLASSES) org.apache.lucene.search.Searcher
$(JCCH) -d $(CLASSES) --classpath=$(CLASSES) org.apache.lucene.search.Query
$(JCCH) -d $(CLASSES) --classpath=$(CLASSES) org.apache.lucene.search.Hits
$(JCCH) -d $(CLASSES) --classpath=$(CLASSES) org.apache.lucene.search.IndexSearcher
$(JCCH) -d $(CLASSES) --classpath=$(CLASSES) org.apache.lucene.queryParser.QueryParser
$(JCCH) -d $(CLASSES) --classpath=$(CLASSES) org.osafoundation.io.PythonReader
PyLucene_wrap.cxx: $(BINDIR)/reader.cpp.o PyLucene.i
ifdef SWIG
$(SWIG) -modern $(SWIG_OPT) -I$(BINDIR)/classes -c++ -python PyLucene.i
endif
ifeq ($(OS),Darwin)
$(PYLUCENE_LIB): $(OBJS) PyLucene_wrap.cxx
$(CXX) -shared -bundle -o $@ $(CCFLAGS) $(SWIG_OPT) $(DB_INC) -I$(GCJ_HOME)/include -I$(CLASSES) -I$(PYTHON_INC) PyLucene_wrap.cxx $(OBJS) -L$(GCJ_HOME)/lib -lgcj -liconv -undefined suppress -flat_namespace -multiply_defined suppress
else
ifeq ($(OS),Linux)
$(PYLUCENE_LIB): $(OBJS) PyLucene_wrap.cxx
$(CXX) -shared -o $@ $(CCFLAGS) $(SWIG_OPT) $(DB_INC) -I$(CLASSES) -I$(PYTHON_INC) PyLucene_wrap.cxx $(OBJS) -lgcj
else
ifeq ($(OS),Cygwin)
$(PYLUCENE_LIB): $(OBJS) PyLucene_wrap.cxx
$(CXX) -c $(CCFLAGS) $(PYDBG) -D_NO_OLDNAMES $(SWIG_OPT) $(DB_INC) -I$(CLASSES) -I$(PYTHON_PC) -I$(PYTHON_INC) -o $(BINDIR)/PyLucene_wrap.o PyLucene_wrap.cxx
$(CXX) -shared $(LDFLAGS) -o $@ $(OBJS) `cygpath -aw $(PREFIX_PYTHON)/python23$(_SUFFIX).dll` $(BINDIR)/PyLucene_wrap.o -lgcj -lwin32k -lws2_32
endif
endif
endif
all: env sources apply $(BINDIR) $(LIBS)
@echo build of $(PYLUCENE_LIB) complete
install:: all
install PyLucene.py $(PYTHON_SITE)
install $(PYLUCENE_LIB) $(PYTHON_SITE)
ifeq ($(OS),Darwin)
install::
ifdef DB
install $(LIBDB_JAVA_LIB) $(PREFIX_DB)/lib
install libdb_java-4.2.la.osx $(PREFIX_DB)/lib/libdb_java-4.2.la
endif
install $(GCJ_HOME)/lib/libgcj.5.dylib $(PREFIX)/lib
install $(GCJ_HOME)/lib/libstdc++.6.dylib $(PREFIX)/lib
install $(GCJ_HOME)/lib/libgcc_s.1.0.dylib $(PREFIX)/lib
else
ifeq ($(OS),Linux)
install::
ifdef DB
install $(LIBDB_JAVA_LIB) $(PREFIX_DB)/lib
endif
else
ifeq ($(OS),Cygwin)
install::
ifdef DB
install $(LIBDB_JAVA_LIB) $(PREFIX_DB)/build_win32/$(BINDIR)
endif
endif
endif
endif
clean:
rm -rf $(BINDIR) PyLucene.py* PyLucene_wrap.cxx
realclean: clean
rm -rf $(LUCENE) $(STORE) $(DISTRIB)
distrib::
mkdir -p $(DISTRIB)/python
install PyLucene.py $(DISTRIB)/python
install $(PYLUCENE_LIB) $(DISTRIB)/python
install README $(DISTRIB)
ifeq ($(OS),Darwin)
distrib::
ifdef DB
mkdir -p $(DISTRIB)/db
install $(LIBDB_JAVA_LIB) $(DISTRIB)/db
install libdb_java-4.2.la.osx $(DISTRIB)/db
endif
mkdir -p $(DISTRIB)/gcj
install $(GCJ_HOME)/lib/libgcj.5.dylib $(DISTRIB)/gcj
install $(GCJ_HOME)/lib/libstdc++.6.dylib $(DISTRIB)/gcj
install $(GCJ_HOME)/lib/libgcc_s.1.0.dylib $(DISTRIB)/gcj
else
ifeq ($(OS),Linux)
distrib::
ifdef DB
mkdir -p $(DISTRIB)/db
install $(LIBDB_JAVA_LIB) $(DISTRIB)/db
endif
mkdir -p $(DISTRIB)/gcj
install $(GCJ_HOME)/lib/libgcj.so.4 $(DISTRIB)/gcj
install $(GCJ_HOME)/lib/libstdc++.so.5 $(DISTRIB)/gcj
install $(GCJ_HOME)/lib/libgcc_s.so.1 $(DISTRIB)/gcj
else
ifeq ($(OS),Cygwin)
distrib::
ifdef DB
mkdir -p $(DISTRIB)/db
install $(LIBDB_JAVA_LIB) $(DISTRIB)/db
endif
endif
endif
endif
distrib::
tar cvzf $(DISTRIB).tar.gz $(DISTRIB)
More information about the pylucene-dev
mailing list