2 # Makefile for building PyLucene
4 # Supported operating systems: Mac OS X, Linux and Windows.
5 # See INSTALL file for requirements.
6 # See jcc/INSTALL for information about --shared.
9 # 1. Edit the sections below as documented
10 # 2. Edit the JARS variable to add optional contrib modules not defaulted
14 # The install target installs the lucene python extension in python's
15 # site-packages directory.
21 LUCENE_SVN=http://svn.apache.org/repos/asf/lucene/dev/tags/lucene_solr_3_4_0
22 PYLUCENE:=$(shell pwd)
23 LUCENE_SRC=lucene-java-$(LUCENE_VER)
24 LUCENE=$(LUCENE_SRC)/lucene
27 # You need to uncomment and edit the variables below in the section
28 # corresponding to your operating system.
30 # Windows drive-absolute paths need to be expressed cygwin style.
32 # PREFIX: where programs are normally installed on your system (Unix).
33 # PREFIX_PYTHON: where your version of python is installed.
34 # JCC: how jcc is invoked, depending on the python version:
38 # $(PYTHON) -m jcc.__main__
42 # $(PYTHON) $(PREFIX_PYTHON)/lib/python2.4/site-packages/jcc/__main__.py
43 # NUM_FILES is the number of wrapper files to generate. By default, jcc
44 # generates all C++ classes into one single file. This may exceed a compiler
48 # Mac OS X 10.6 (64-bit Python 2.6, Java 1.6)
51 #PYTHON=$(PREFIX_PYTHON)/bin/python
52 #JCC=$(PYTHON) -m jcc.__main__ --shared --arch x86_64
55 # Mac OS X 10.6 (MacPorts 1.8.0 64-bit Python 2.7, Java 1.6)
56 #PREFIX_PYTHON=/opt/local
58 #PYTHON=$(PREFIX_PYTHON)/bin/python
59 #JCC=$(PYTHON) -m jcc --shared --arch x86_64
62 # Mac OS X 10.6 (MacPorts 1.8.0 64-bit Python 2.6, Java 1.6)
63 #PREFIX_PYTHON=/opt/local
65 #PYTHON=$(PREFIX_PYTHON)/bin/python
66 #JCC=$(PYTHON) -m jcc.__main__ --shared --arch x86_64
69 # Mac OS X 10.6 (64-bit and 32-bit Python 2.6 together, Java 1.6)
72 #PYTHON=$(PREFIX_PYTHON)/bin/python
73 #JCC=$(PYTHON) -m jcc.__main__ --shared --arch x86_64 --arch i386
76 # Mac OS X 10.5 (32-bit Python 2.5, Java 1.5)
79 #PYTHON=$(PREFIX_PYTHON)/bin/python
80 #JCC=$(PYTHON) -m jcc --shared
83 # Mac OS X (Python 2.3.5, Java 1.5, setuptools 0.6c7, Intel Mac OS X 10.4)
86 #PYTHON=$(PREFIX_PYTHON)/bin/python
87 #JCC=$(PYTHON) /System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/JCC-2.3-py2.3-macosx-10.4-i386.egg/jcc/__init__.py
90 # Mac OS X (Python 2.3.5, Java 1.5, setuptools 0.6c7, PPC Mac OS X 10.4)
93 #PYTHON=$(PREFIX_PYTHON)/bin/python
94 #JCC=$(PYTHON) /System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/JCC-2.3-py2.3-macosx-10.4-ppc.egg/jcc/__init__.py
97 # Linux (Ubuntu 6.06, Python 2.4, Java 1.5, no setuptools)
100 #PYTHON=$(PREFIX_PYTHON)/bin/python
101 #JCC=$(PYTHON) $(PREFIX_PYTHON)/lib/python2.4/site-packages/jcc/__init__.py
104 # Linux (Ubuntu 8.10 64-bit, Python 2.5.2, OpenJDK 1.6, setuptools 0.6c9)
107 #PYTHON=$(PREFIX_PYTHON)/bin/python
108 #JCC=$(PYTHON) -m jcc --shared
114 #PYTHON=$(PREFIX_PYTHON)/bin/python
115 #JCC=$(PYTHON) -m jcc
118 # Solaris (Solaris 11, Python 2.4 32-bit, Sun Studio 12, Java 1.6)
120 #ANT=/usr/local/apache-ant-1.7.0/bin/ant
121 #PYTHON=$(PREFIX_PYTHON)/bin/python
122 #JCC=$(PYTHON) $(PREFIX_PYTHON)/lib/python2.4/site-packages/jcc/__init__.py
125 # Windows (Win32, Python 2.5.1, Java 1.6, ant 1.7.0)
126 #PREFIX_PYTHON=/cygdrive/o/Python-2.5.2/PCbuild
127 #ANT=JAVA_HOME=o:\\Java\\jdk1.6.0_02 /cygdrive/o/java/apache-ant-1.7.0/bin/ant
128 #PYTHON=$(PREFIX_PYTHON)/python.exe
129 #JCC=$(PYTHON) -m jcc --shared
132 # Windows (Win32, msys/MinGW, Python 2.6.4, Java 1.6, ant 1.7.1 (WinAnt))
133 #PREFIX_PYTHON=/c/Python26
134 #ANT=JAVA_HOME="c:\\Program Files\\Java\\jdk1.6.0_18" "/c/Program Files/WinAnt/bin/ant"
135 #PYTHON=$(PREFIX_PYTHON)/python.exe
136 #JCC=$(PYTHON) -m jcc.__main__ --shared --compiler mingw32
139 # Windows (Win32, Python 2.7, Java 1.6, ant 1.8.1, Java not on PATH)
140 #PREFIX_PYTHON=/cygdrive/c/Python27
141 #ANT=JAVA_HOME=c:\\jdk1.6.0_22 /cygdrive/c/java/apache-ant-1.8.1/bin/ant
142 #PYTHON=$(PREFIX_PYTHON)/python.exe
143 #JCC=$(PYTHON) -m jcc --shared --find-jvm-dll
148 # comment/uncomment the desired/undesired optional contrib modules below
149 JARS+=$(ANALYZERS_JAR) # many language analyzers
150 JARS+=$(MEMORY_JAR) # single-document memory index
151 JARS+=$(HIGHLIGHTER_JAR) # needs memory contrib
152 JARS+=$(EXTENSIONS_JAR) # needs highlighter contrib
153 JARS+=$(QUERIES_JAR) # regex and other contrib queries
154 #JARS+=$(SMARTCN_JAR) # smart chinese analyzer
155 #JARS+=$(SPATIAL_JAR) # spatial lucene
156 JARS+=$(GROUPING_JAR) # grouping module
157 JARS+=$(JOIN_JAR) # join module
161 # No edits required below
170 DEFINES=-DPYLUCENE_VER="\"$(VERSION)\"" -DLUCENE_VER="\"$(LUCENE_VER)\""
172 LUCENE_JAR=$(LUCENE)/build/lucene-core-$(LUCENE_VER).jar
173 ANALYZERS_JAR=$(LUCENE)/build/contrib/analyzers/common/lucene-analyzers-$(LUCENE_VER).jar
174 HIGHLIGHTER_JAR=$(LUCENE)/build/contrib/highlighter/lucene-highlighter-$(LUCENE_VER).jar
175 MEMORY_JAR=$(LUCENE)/build/contrib/memory/lucene-memory-$(LUCENE_VER).jar
176 QUERIES_JAR=$(LUCENE)/build/contrib/queries/lucene-queries-$(LUCENE_VER).jar
177 EXTENSIONS_JAR=build/jar/extensions.jar
178 SMARTCN_JAR=$(LUCENE)/build/contrib/analyzers/smartcn/lucene-smartcn-$(LUCENE_VER).jar
179 SPATIAL_JAR=$(LUCENE)/build/contrib/spatial/lucene-spatial-$(LUCENE_VER).jar
180 GROUPING_JAR=$(LUCENE)/build/contrib/grouping/lucene-grouping-$(LUCENE_VER).jar
181 JOIN_JAR=$(LUCENE)/build/contrib/join/lucene-join-$(LUCENE_VER).jar
183 ICUPKG:=$(shell which icupkg)
185 .PHONY: generate compile install default all clean realclean \
186 sources test jars distrib
191 mkdir -p $(LUCENE_SRC)
192 svn $(SVNOP) -r $(LUCENE_SVN_VER) $(LUCENE_SVN)/lucene $(LUCENE_SRC)/lucene
194 sources: $(LUCENE_SRC)
197 mkdir -p $(LUCENE)-orig
198 tar -C $(LUCENE) -cf - . | tar -C $(LUCENE)-orig -xvf -
200 from-orig: $(LUCENE)-orig
202 tar -C $(LUCENE)-orig -cf - . | tar -C $(LUCENE) -xvf -
206 $(MAKE) $(LUCENE_JAR)
208 $(LUCENE_JAR): $(LUCENE)
209 cd $(LUCENE); $(ANT) -Dversion=$(LUCENE_VER)
211 $(ANALYZERS_JAR): $(LUCENE_JAR)
212 cd $(LUCENE)/contrib/analyzers/common; $(ANT) -Dversion=$(LUCENE_VER)
214 $(MEMORY_JAR): $(LUCENE_JAR)
215 cd $(LUCENE)/contrib/memory; $(ANT) -Dversion=$(LUCENE_VER)
217 $(HIGHLIGHTER_JAR): $(LUCENE_JAR)
218 cd $(LUCENE)/contrib/highlighter; $(ANT) -Dversion=$(LUCENE_VER)
220 $(QUERIES_JAR): $(LUCENE_JAR)
221 cd $(LUCENE)/contrib/queries; $(ANT) -Dversion=$(LUCENE_VER)
223 $(EXTENSIONS_JAR): $(LUCENE_JAR)
224 $(ANT) -f extensions.xml -Dlucene.dir=$(LUCENE)
226 $(SMARTCN_JAR): $(LUCENE_JAR)
227 cd $(LUCENE)/contrib/analyzers/smartcn; $(ANT) -Dversion=$(LUCENE_VER)
229 $(SPATIAL_JAR): $(LUCENE_JAR)
230 cd $(LUCENE)/contrib/spatial; $(ANT) -Dversion=$(LUCENE_VER)
232 $(GROUPING_JAR): $(LUCENE_JAR)
233 cd $(LUCENE)/contrib/grouping; $(ANT) -Dversion=$(LUCENE_VER)
235 $(JOIN_JAR): $(LUCENE_JAR)
236 cd $(LUCENE)/contrib/join; $(ANT) -Dversion=$(LUCENE_VER)
245 RESOURCES=--resources $(LUCENE)/contrib/icu/src/resources
246 ENDIANNESS:=$(shell $(PYTHON) -c "import struct; print struct.pack('h', 1) == '\000\001' and 'b' or 'l'")
248 resources: $(LUCENE)/contrib/icu/src/resources/org/apache/lucene/analysis/icu/utr30.dat
250 $(LUCENE)/contrib/icu/src/resources/org/apache/lucene/analysis/icu/utr30.dat: $(LUCENE)/contrib/icu/src/resources/org/apache/lucene/analysis/icu/utr30.nrm
252 cd $(dir $<); $(ICUPKG) --type $(ENDIANNESS) --add $(notdir $<) new $(notdir $@)
259 @echo ICU not installed
263 GENERATE=$(JCC) $(foreach jar,$(JARS),--jar $(jar)) \
265 --package java.lang java.lang.System \
267 --package java.util java.util.Arrays \
270 java.text.SimpleDateFormat \
271 java.text.DecimalFormat \
273 --package java.util.regex \
274 --package java.io java.io.StringReader \
275 java.io.InputStreamReader \
276 java.io.FileInputStream \
277 --exclude org.apache.lucene.queryParser.Token \
278 --exclude org.apache.lucene.queryParser.TokenMgrError \
279 --exclude org.apache.lucene.queryParser.QueryParserTokenManager \
280 --exclude org.apache.lucene.queryParser.ParseException \
281 --exclude org.apache.lucene.search.regex.JakartaRegexpCapabilities \
282 --exclude org.apache.regexp.RegexpTunnel \
283 --exclude org.apache.lucene.analysis.cn.smart.AnalyzerProfile \
285 --mapping org.apache.lucene.document.Document 'get:(Ljava/lang/String;)Ljava/lang/String;' \
286 --mapping java.util.Properties 'getProperty:(Ljava/lang/String;)Ljava/lang/String;' \
287 --sequence java.util.AbstractList 'size:()I' 'get:(I)Ljava/lang/Object;' \
288 --rename org.apache.lucene.search.highlight.SpanScorer=HighlighterSpanScorer \
289 --version $(LUCENE_VER) \
290 --module python/collections.py \
291 --module python/ICUNormalizer2Filter.py \
292 --module python/ICUFoldingFilter.py \
293 --module python/ICUTransformFilter.py \
301 $(GENERATE) --build $(DEBUG_OPT)
304 $(GENERATE) --install $(DEBUG_OPT) $(INSTALL_OPT)
310 $(GENERATE) --wininst
312 all: sources jars resources compile
313 @echo build of $(PYLUCENE_LIB) complete
316 if test -f $(LUCENE)/build.xml; then cd $(LUCENE); $(ANT) clean; fi
317 rm -rf $(LUCENE)/build build
320 if test ! -d $(LUCENE)/.svn; then rm -rf $(LUCENE_SRC); else rm -rf $(LUCENE)/build; fi
321 rm -rf build samples/LuceneInAction/index
324 BUILD_TEST:=$(PYLUCENE)/build/test
326 ifeq ($(findstring CYGWIN,$(OS)),CYGWIN)
327 BUILD_TEST:=`cygpath -aw $(BUILD_TEST)`
329 ifeq ($(findstring MINGW,$(OS)),MINGW)
330 BUILD_TEST:=`$(PYTHON) -c "import os, sys; print os.path.normpath(sys.argv[1]).replace(chr(92), chr(92)*2)" $(BUILD_TEST)`
335 mkdir -p $(BUILD_TEST)
336 PYTHONPATH=$(BUILD_TEST) $(GENERATE) --install $(DEBUG_OPT) --install-dir $(BUILD_TEST)
338 samples/LuceneInAction/index:
339 cd samples/LuceneInAction; PYTHONPATH=$(BUILD_TEST) $(PYTHON) index.py
341 test: install-test samples/LuceneInAction/index
342 find test -name 'test_*.py' | PYTHONPATH=$(BUILD_TEST) xargs -t -n 1 $(PYTHON)
343 ls samples/LuceneInAction/*Test.py | PYTHONPATH=$(BUILD_TEST) xargs -t -n 1 $(PYTHON)
344 PYTHONPATH=$(BUILD_TEST) $(PYTHON) samples/LuceneInAction/AnalyzerDemo.py
345 PYTHONPATH=$(BUILD_TEST) $(PYTHON) samples/LuceneInAction/AnalyzerUtils.py
346 PYTHONPATH=$(BUILD_TEST) $(PYTHON) samples/LuceneInAction/BooksLikeThis.py
347 PYTHONPATH=$(BUILD_TEST) $(PYTHON) samples/LuceneInAction/Explainer.py samples/LuceneInAction/index programming
348 PYTHONPATH=$(BUILD_TEST) $(PYTHON) samples/LuceneInAction/HighlightIt.py
349 PYTHONPATH=$(BUILD_TEST) $(PYTHON) samples/LuceneInAction/SortingExample.py
352 ARCHIVE=pylucene-$(VERSION)-src.tar.gz
353 SITE=../site/build/site/en
357 svn export . distrib/pylucene-$(VERSION)
358 tar -cf - --exclude build $(LUCENE_SRC) | tar -C distrib/pylucene-$(VERSION) -xvf -
359 mkdir distrib/pylucene-$(VERSION)/doc
360 tar -C $(SITE) -cf - . | tar -C distrib/pylucene-$(VERSION)/doc -xvf -
361 cd distrib; tar -cvzf $(ARCHIVE) pylucene-$(VERSION)
362 cd distrib; gpg2 --armor --output $(ARCHIVE).asc --detach-sig $(ARCHIVE)
363 cd distrib; openssl md5 < $(ARCHIVE) > $(ARCHIVE).md5
366 cd distrib; scp -p $(ARCHIVE) $(ARCHIVE).asc $(ARCHIVE).md5 \
367 people.apache.org:public_html/staging_area
370 cd distrib; scp -p $(ARCHIVE) $(ARCHIVE).asc $(ARCHIVE).md5 \
371 people.apache.org:/www/www.apache.org/dist/lucene/pylucene