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
111 PREFIX_PYTHON=$(VIRTUAL_ENV)
113 PYTHON=$(PREFIX_PYTHON)/bin/python
114 JCC=$(PYTHON) -m jcc --shared
120 #PYTHON=$(PREFIX_PYTHON)/bin/python
121 #JCC=$(PYTHON) -m jcc
124 # Solaris (Solaris 11, Python 2.4 32-bit, Sun Studio 12, Java 1.6)
126 #ANT=/usr/local/apache-ant-1.7.0/bin/ant
127 #PYTHON=$(PREFIX_PYTHON)/bin/python
128 #JCC=$(PYTHON) $(PREFIX_PYTHON)/lib/python2.4/site-packages/jcc/__init__.py
131 # Windows (Win32, Python 2.5.1, Java 1.6, ant 1.7.0)
132 #PREFIX_PYTHON=/cygdrive/o/Python-2.5.2/PCbuild
133 #ANT=JAVA_HOME=o:\\Java\\jdk1.6.0_02 /cygdrive/o/java/apache-ant-1.7.0/bin/ant
134 #PYTHON=$(PREFIX_PYTHON)/python.exe
135 #JCC=$(PYTHON) -m jcc --shared
138 # Windows (Win32, msys/MinGW, Python 2.6.4, Java 1.6, ant 1.7.1 (WinAnt))
139 #PREFIX_PYTHON=/c/Python26
140 #ANT=JAVA_HOME="c:\\Program Files\\Java\\jdk1.6.0_18" "/c/Program Files/WinAnt/bin/ant"
141 #PYTHON=$(PREFIX_PYTHON)/python.exe
142 #JCC=$(PYTHON) -m jcc.__main__ --shared --compiler mingw32
145 # Windows (Win32, Python 2.7, Java 1.6, ant 1.8.1, Java not on PATH)
146 #PREFIX_PYTHON=/cygdrive/c/Python27
147 #ANT=JAVA_HOME=c:\\jdk1.6.0_22 /cygdrive/c/java/apache-ant-1.8.1/bin/ant
148 #PYTHON=$(PREFIX_PYTHON)/python.exe
149 #JCC=$(PYTHON) -m jcc --shared --find-jvm-dll
154 # comment/uncomment the desired/undesired optional contrib modules below
155 JARS+=$(ANALYZERS_JAR) # many language analyzers
156 JARS+=$(MEMORY_JAR) # single-document memory index
157 JARS+=$(HIGHLIGHTER_JAR) # needs memory contrib
158 JARS+=$(EXTENSIONS_JAR) # needs highlighter contrib
159 JARS+=$(QUERIES_JAR) # regex and other contrib queries
161 #JARS+=$(SMARTCN_JAR) # smart chinese analyzer
162 #JARS+=$(SPATIAL_JAR) # spatial lucene
163 JARS+=$(GROUPING_JAR) # grouping module
164 JARS+=$(JOIN_JAR) # join module
168 # No edits required below
177 DEFINES=-DPYLUCENE_VER="\"$(VERSION)\"" -DLUCENE_VER="\"$(LUCENE_VER)\""
179 LUCENE_JAR=$(LUCENE)/build/lucene-core-$(LUCENE_VER).jar
180 ANALYZERS_JAR=$(LUCENE)/build/contrib/analyzers/common/lucene-analyzers-$(LUCENE_VER).jar
181 HIGHLIGHTER_JAR=$(LUCENE)/build/contrib/highlighter/lucene-highlighter-$(LUCENE_VER).jar
182 MEMORY_JAR=$(LUCENE)/build/contrib/memory/lucene-memory-$(LUCENE_VER).jar
183 QUERIES_JAR=$(LUCENE)/build/contrib/queries/lucene-queries-$(LUCENE_VER).jar
184 EXTENSIONS_JAR=build/jar/extensions.jar
185 SMARTCN_JAR=$(LUCENE)/build/contrib/analyzers/smartcn/lucene-smartcn-$(LUCENE_VER).jar
186 STEMPEL_JAR=$(LUCENE)/build/contrib/analyzers/stempel/lucene-stempel-$(LUCENE_VER).jar
187 SPATIAL_JAR=$(LUCENE)/build/contrib/spatial/lucene-spatial-$(LUCENE_VER).jar
188 GROUPING_JAR=$(LUCENE)/build/contrib/grouping/lucene-grouping-$(LUCENE_VER).jar
189 JOIN_JAR=$(LUCENE)/build/contrib/join/lucene-join-$(LUCENE_VER).jar
191 ICUPKG:=$(shell which icupkg)
193 .PHONY: generate compile install default all clean realclean \
194 sources test jars distrib
199 mkdir -p $(LUCENE_SRC)
200 svn $(SVNOP) -r $(LUCENE_SVN_VER) $(LUCENE_SVN)/lucene $(LUCENE_SRC)/lucene
202 sources: $(LUCENE_SRC)
205 mkdir -p $(LUCENE)-orig
206 tar -C $(LUCENE) -cf - . | tar -C $(LUCENE)-orig -xvf -
208 from-orig: $(LUCENE)-orig
210 tar -C $(LUCENE)-orig -cf - . | tar -C $(LUCENE) -xvf -
214 $(MAKE) $(LUCENE_JAR)
216 $(LUCENE_JAR): $(LUCENE)
217 cd $(LUCENE); $(ANT) -Dversion=$(LUCENE_VER)
219 $(ANALYZERS_JAR): $(LUCENE_JAR)
220 cd $(LUCENE)/contrib/analyzers/common; $(ANT) -Dversion=$(LUCENE_VER)
222 $(MEMORY_JAR): $(LUCENE_JAR)
223 cd $(LUCENE)/contrib/memory; $(ANT) -Dversion=$(LUCENE_VER)
225 $(HIGHLIGHTER_JAR): $(LUCENE_JAR)
226 cd $(LUCENE)/contrib/highlighter; $(ANT) -Dversion=$(LUCENE_VER)
228 $(QUERIES_JAR): $(LUCENE_JAR)
229 cd $(LUCENE)/contrib/queries; $(ANT) -Dversion=$(LUCENE_VER)
231 $(EXTENSIONS_JAR): $(LUCENE_JAR)
232 $(ANT) -f extensions.xml -Dlucene.dir=$(LUCENE)
234 $(SMARTCN_JAR): $(LUCENE_JAR)
235 cd $(LUCENE)/contrib/analyzers/smartcn; $(ANT) -Dversion=$(LUCENE_VER)
237 $(STEMPEL_JAR): $(LUCENE_JAR)
238 cd $(LUCENE)/contrib/analyzers/stempel; $(ANT) -Dversion=$(LUCENE_VER)
240 $(SPATIAL_JAR): $(LUCENE_JAR)
241 cd $(LUCENE)/contrib/spatial; $(ANT) -Dversion=$(LUCENE_VER)
243 $(GROUPING_JAR): $(LUCENE_JAR)
244 cd $(LUCENE)/contrib/grouping; $(ANT) -Dversion=$(LUCENE_VER)
246 $(JOIN_JAR): $(LUCENE_JAR)
247 cd $(LUCENE)/contrib/join; $(ANT) -Dversion=$(LUCENE_VER)
256 RESOURCES=--resources $(LUCENE)/contrib/icu/src/resources
257 ENDIANNESS:=$(shell $(PYTHON) -c "import struct; print struct.pack('h', 1) == '\000\001' and 'b' or 'l'")
259 resources: $(LUCENE)/contrib/icu/src/resources/org/apache/lucene/analysis/icu/utr30.dat
261 $(LUCENE)/contrib/icu/src/resources/org/apache/lucene/analysis/icu/utr30.dat: $(LUCENE)/contrib/icu/src/resources/org/apache/lucene/analysis/icu/utr30.nrm
263 cd $(dir $<); $(ICUPKG) --type $(ENDIANNESS) --add $(notdir $<) new $(notdir $@)
270 @echo ICU not installed
274 GENERATE=$(JCC) $(foreach jar,$(JARS),--jar $(jar)) \
276 --package java.lang java.lang.System \
278 --package java.util java.util.Arrays \
281 java.text.SimpleDateFormat \
282 java.text.DecimalFormat \
284 --package java.util.regex \
285 --package java.io java.io.StringReader \
286 java.io.InputStreamReader \
287 java.io.FileInputStream \
288 --exclude org.apache.lucene.queryParser.Token \
289 --exclude org.apache.lucene.queryParser.TokenMgrError \
290 --exclude org.apache.lucene.queryParser.QueryParserTokenManager \
291 --exclude org.apache.lucene.queryParser.ParseException \
292 --exclude org.apache.lucene.search.regex.JakartaRegexpCapabilities \
293 --exclude org.apache.regexp.RegexpTunnel \
294 --exclude org.apache.lucene.analysis.cn.smart.AnalyzerProfile \
296 --mapping org.apache.lucene.document.Document 'get:(Ljava/lang/String;)Ljava/lang/String;' \
297 --mapping java.util.Properties 'getProperty:(Ljava/lang/String;)Ljava/lang/String;' \
298 --sequence java.util.AbstractList 'size:()I' 'get:(I)Ljava/lang/Object;' \
299 --rename org.apache.lucene.search.highlight.SpanScorer=HighlighterSpanScorer \
300 --version $(LUCENE_VER) \
301 --module python/collections.py \
302 --module python/ICUNormalizer2Filter.py \
303 --module python/ICUFoldingFilter.py \
304 --module python/ICUTransformFilter.py \
312 $(GENERATE) --build $(DEBUG_OPT)
315 $(GENERATE) --install $(DEBUG_OPT) $(INSTALL_OPT)
321 $(GENERATE) --wininst
323 all: sources jars resources compile
324 @echo build of $(PYLUCENE_LIB) complete
327 if test -f $(LUCENE)/build.xml; then cd $(LUCENE); $(ANT) clean; fi
328 rm -rf $(LUCENE)/build build
331 if test ! -d $(LUCENE)/.svn; then rm -rf $(LUCENE_SRC); else rm -rf $(LUCENE)/build; fi
332 rm -rf build samples/LuceneInAction/index
335 BUILD_TEST:=$(PYLUCENE)/build/test
337 ifeq ($(findstring CYGWIN,$(OS)),CYGWIN)
338 BUILD_TEST:=`cygpath -aw $(BUILD_TEST)`
340 ifeq ($(findstring MINGW,$(OS)),MINGW)
341 BUILD_TEST:=`$(PYTHON) -c "import os, sys; print os.path.normpath(sys.argv[1]).replace(chr(92), chr(92)*2)" $(BUILD_TEST)`
346 mkdir -p $(BUILD_TEST)
347 PYTHONPATH=$(BUILD_TEST) $(GENERATE) --install $(DEBUG_OPT) --install-dir $(BUILD_TEST)
349 samples/LuceneInAction/index:
350 cd samples/LuceneInAction; PYTHONPATH=$(BUILD_TEST) $(PYTHON) index.py
352 test: install-test samples/LuceneInAction/index
353 find test -name 'test_*.py' | PYTHONPATH=$(BUILD_TEST) xargs -t -n 1 $(PYTHON)
354 ls samples/LuceneInAction/*Test.py | PYTHONPATH=$(BUILD_TEST) xargs -t -n 1 $(PYTHON)
355 PYTHONPATH=$(BUILD_TEST) $(PYTHON) samples/LuceneInAction/AnalyzerDemo.py
356 PYTHONPATH=$(BUILD_TEST) $(PYTHON) samples/LuceneInAction/AnalyzerUtils.py
357 PYTHONPATH=$(BUILD_TEST) $(PYTHON) samples/LuceneInAction/BooksLikeThis.py
358 PYTHONPATH=$(BUILD_TEST) $(PYTHON) samples/LuceneInAction/Explainer.py samples/LuceneInAction/index programming
359 PYTHONPATH=$(BUILD_TEST) $(PYTHON) samples/LuceneInAction/HighlightIt.py
360 PYTHONPATH=$(BUILD_TEST) $(PYTHON) samples/LuceneInAction/SortingExample.py
363 ARCHIVE=pylucene-$(VERSION)-src.tar.gz
364 SITE=../site/build/site/en
368 svn export . distrib/pylucene-$(VERSION)
369 tar -cf - --exclude build $(LUCENE_SRC) | tar -C distrib/pylucene-$(VERSION) -xvf -
370 mkdir distrib/pylucene-$(VERSION)/doc
371 tar -C $(SITE) -cf - . | tar -C distrib/pylucene-$(VERSION)/doc -xvf -
372 cd distrib; tar -cvzf $(ARCHIVE) pylucene-$(VERSION)
373 cd distrib; gpg2 --armor --output $(ARCHIVE).asc --detach-sig $(ARCHIVE)
374 cd distrib; openssl md5 < $(ARCHIVE) > $(ARCHIVE).md5
377 cd distrib; scp -p $(ARCHIVE) $(ARCHIVE).asc $(ARCHIVE).md5 \
378 people.apache.org:public_html/staging_area
381 cd distrib; scp -p $(ARCHIVE) $(ARCHIVE).asc $(ARCHIVE).md5 \
382 people.apache.org:/www/www.apache.org/dist/lucene/pylucene