-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
426 lines (347 loc) · 15.6 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
# Makefile for building PyLucene
#
# Supported operating systems: Mac OS X, Linux and Windows.
# See INSTALL file for requirements.
# See jcc/INSTALL for information about --shared.
#
# Steps to build
# 1. Edit the sections below as documented
# 2. Edit the JARS variable to add optional contrib modules not defaulted
# 3. make
# 4. make install
#
# The install target installs the lucene python extension in python's
# site-packages directory.
#
VERSION=4.0-0
LUCENE_SVN_VER=HEAD
LUCENE_VER=4.0
LUCENE_SVN=http://svn.apache.org/repos/asf/lucene/dev/branches/branch_4x
PYLUCENE:=$(shell pwd)
LUCENE_SRC=lucene-java-$(LUCENE_VER)
LUCENE=$(LUCENE_SRC)/lucene
#
# You need to uncomment and edit the variables below in the section
# corresponding to your operating system.
#
# Windows drive-absolute paths need to be expressed cygwin style.
#
# PREFIX: where programs are normally installed on your system (Unix).
# PREFIX_PYTHON: where your version of python is installed.
# JCC: how jcc is invoked, depending on the python version:
# - python 2.7:
# $(PYTHON) -m jcc
# - python 2.6:
# $(PYTHON) -m jcc.__main__
# - python 2.5:
# $(PYTHON) -m jcc
# - python 2.4:
# $(PYTHON) $(PREFIX_PYTHON)/lib/python2.4/site-packages/jcc/__main__.py
# NUM_FILES is the number of wrapper files to generate. By default, jcc
# generates all C++ classes into one single file. This may exceed a compiler
# limit.
#
# Mac OS X 10.6 (64-bit Python 2.6, Java 1.6)
#PREFIX_PYTHON=/usr
#ANT=ant
#PYTHON=$(PREFIX_PYTHON)/bin/python
#JCC=$(PYTHON) -m jcc.__main__ --shared --arch x86_64
#NUM_FILES=8
# Mac OS X 10.6 (MacPorts 1.8.0 64-bit Python 2.7, Java 1.6)
#PREFIX_PYTHON=/opt/local
#ANT=ant
#PYTHON=$(PREFIX_PYTHON)/bin/python
#JCC=$(PYTHON) -m jcc --shared --arch x86_64
#NUM_FILES=8
# Mac OS X 10.6 (64-bit and 32-bit Python 2.6 together, Java 1.6)
#PREFIX_PYTHON=/usr
#ANT=ant
#PYTHON=$(PREFIX_PYTHON)/bin/python
#JCC=$(PYTHON) -m jcc.__main__ --shared --arch x86_64 --arch i386
#NUM_FILES=8
# Mac OS X 10.5 (32-bit Python 2.5, Java 1.5)
#PREFIX_PYTHON=/usr
#ANT=ant
#PYTHON=$(PREFIX_PYTHON)/bin/python
#JCC=$(PYTHON) -m jcc --shared
#NUM_FILES=8
# Mac OS X (Python 2.3.5, Java 1.5, setuptools 0.6c7, Intel Mac OS X 10.4)
#PREFIX_PYTHON=/usr
#ANT=ant
#PYTHON=$(PREFIX_PYTHON)/bin/python
#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
#NUM_FILES=8
# Mac OS X (Python 2.3.5, Java 1.5, setuptools 0.6c7, PPC Mac OS X 10.4)
#PREFIX_PYTHON=/usr
#ANT=ant
#PYTHON=$(PREFIX_PYTHON)/bin/python
#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
#NUM_FILES=8
# Linux (Ubuntu 11.10 64-bit, Python 2.7.2, OpenJDK 1.7, setuptools 0.6.16)
# Be sure to also set JDK['linux2'] in jcc's setup.py to the JAVA_HOME value
# used below for ANT (and rebuild jcc after changing it).
#PREFIX_PYTHON=/usr
#ANT=JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64 /usr/bin/ant
#PYTHON=$(PREFIX_PYTHON)/bin/python
#JCC=$(PYTHON) -m jcc --shared
#NUM_FILES=8
# Linux (Ubuntu 8.10 64-bit, Python 2.5.2, OpenJDK 1.6, setuptools 0.6c9)
PREFIX_PYTHON=/usr
ANT=ant
PYTHON=$(PREFIX_PYTHON)/bin/python
JCC=$(PYTHON) -m jcc --shared
NUM_FILES=8
# Linux (Ubuntu 6.06, Python 2.4, Java 1.5, no setuptools)
#PREFIX_PYTHON=/usr
#ANT=ant
#PYTHON=$(PREFIX_PYTHON)/bin/python
#JCC=$(PYTHON) $(PREFIX_PYTHON)/lib/python2.4/site-packages/jcc/__init__.py
#NUM_FILES=8
# FreeBSD
#PREFIX_PYTHON=/usr
#ANT=ant
#PYTHON=$(PREFIX_PYTHON)/bin/python
#JCC=$(PYTHON) -m jcc
#NUM_FILES=8
# Solaris (Solaris 11, Python 2.4 32-bit, Sun Studio 12, Java 1.6)
#PREFIX_PYTHON=/usr
#ANT=/usr/local/apache-ant-1.7.0/bin/ant
#PYTHON=$(PREFIX_PYTHON)/bin/python
#JCC=$(PYTHON) $(PREFIX_PYTHON)/lib/python2.4/site-packages/jcc/__init__.py
#NUM_FILES=8
# Windows (Win32, Python 2.5.1, Java 1.6, ant 1.7.0)
#PREFIX_PYTHON=/cygdrive/o/Python-2.5.2/PCbuild
#ANT=JAVA_HOME=o:\\Java\\jdk1.6.0_02 /cygdrive/o/java/apache-ant-1.7.0/bin/ant
#PYTHON=$(PREFIX_PYTHON)/python.exe
#JCC=$(PYTHON) -m jcc --shared
#NUM_FILES=8
# Windows (Win32, msys/MinGW, Python 2.6.4, Java 1.6, ant 1.7.1 (WinAnt))
#PREFIX_PYTHON=/c/Python26
#ANT=JAVA_HOME="c:\\Program Files\\Java\\jdk1.6.0_18" "/c/Program Files/WinAnt/bin/ant"
#PYTHON=$(PREFIX_PYTHON)/python.exe
#JCC=$(PYTHON) -m jcc.__main__ --shared --compiler mingw32
#NUM_FILES=8
# Windows (Win32, Python 2.7, Java 1.6, ant 1.8.1, Java not on PATH)
#PREFIX_PYTHON=/cygdrive/c/Python27
#ANT=JAVA_HOME=c:\\jdk1.6.0_22 /cygdrive/c/java/apache-ant-1.8.1/bin/ant
#PYTHON=$(PREFIX_PYTHON)/python.exe
#JCC=$(PYTHON) -m jcc --shared --find-jvm-dll
#NUM_FILES=8
JARS=$(LUCENE_JAR)
# comment/uncomment the desired/undesired optional contrib modules below
JARS+=$(ANALYZERS_JAR) # many language analyzers
JARS+=$(MEMORY_JAR) # single-document memory index
JARS+=$(HIGHLIGHTER_JAR) # needs memory contrib
JARS+=$(EXTENSIONS_JAR) # needs highlighter contrib
JARS+=$(QUERIES_JAR) # regex and other contrib queries
JARS+=$(QUERYPARSER_JAR) # query parser
JARS+=$(SANDBOX_JAR) # needed by query parser
#JARS+=$(SMARTCN_JAR) # smart chinese analyzer
#JARS+=$(SPATIAL_JAR) # spatial lucene
JARS+=$(GROUPING_JAR) # grouping module
JARS+=$(JOIN_JAR) # join module
JARS+=$(FACET_JAR) # facet module
JARS+=$(SUGGEST_JAR) # suggest/spell module
#
# No edits required below
#
SVNOP?=export
ifeq ($(DEBUG),1)
DEBUG_OPT=--debug
endif
DEFINES=-DPYLUCENE_VER="\"$(VERSION)\"" -DLUCENE_VER="\"$(LUCENE_VER)\""
LUCENE_JAR=$(LUCENE)/build/core/lucene-core-$(LUCENE_VER).jar
ANALYZERS_JAR=$(LUCENE)/build/analysis/common/lucene-analyzers-common-$(LUCENE_VER).jar
HIGHLIGHTER_JAR=$(LUCENE)/build/highlighter/lucene-highlighter-$(LUCENE_VER).jar
MEMORY_JAR=$(LUCENE)/build/memory/lucene-memory-$(LUCENE_VER).jar
EXTENSIONS_JAR=build/jar/extensions.jar
QUERIES_JAR=$(LUCENE)/build/queries/lucene-queries-$(LUCENE_VER).jar
QUERYPARSER_JAR=$(LUCENE)/build/queryparser/lucene-queryparser-$(LUCENE_VER).jar
SANDBOX_JAR=$(LUCENE)/build/sandbox/lucene-sandbox-$(LUCENE_VER).jar
SMARTCN_JAR=$(LUCENE)/build/analysis/smartcn/lucene-analyzers-smartcn-$(LUCENE_VER).jar
SPATIAL_JAR=$(LUCENE)/build/spatial/lucene-spatial-$(LUCENE_VER).jar
GROUPING_JAR=$(LUCENE)/build/grouping/lucene-grouping-$(LUCENE_VER).jar
JOIN_JAR=$(LUCENE)/build/join/lucene-join-$(LUCENE_VER).jar
FACET_JAR=$(LUCENE)/build/facet/lucene-facet-$(LUCENE_VER).jar
SUGGEST_JAR=$(LUCENE)/build/suggest/lucene-suggest-$(LUCENE_VER).jar
ICUPKG:=$(shell which icupkg)
.PHONY: generate compile install default all clean realclean \
sources ivy test jars distrib
default: all
$(LUCENE_SRC):
svn $(SVNOP) --depth files -r $(LUCENE_SVN_VER) $(LUCENE_SVN) $(LUCENE_SRC)
svn $(SVNOP) -r $(LUCENE_SVN_VER) $(LUCENE_SVN)/lucene $(LUCENE_SRC)/lucene
sources: $(LUCENE_SRC)
ivy:
cd $(LUCENE); ($(ANT) ivy-fail || $(ANT) ivy-bootstrap)
to-orig: sources
mkdir -p $(LUCENE)-orig
tar -C $(LUCENE) -cf - . | tar -C $(LUCENE)-orig -xvf -
from-orig: $(LUCENE)-orig
mkdir -p $(LUCENE)
tar -C $(LUCENE)-orig -cf - . | tar -C $(LUCENE) -xvf -
lucene:
rm -f $(LUCENE_JAR)
$(MAKE) $(LUCENE_JAR)
$(LUCENE_JAR): $(LUCENE)
cd $(LUCENE); $(ANT) -Dversion=$(LUCENE_VER)
$(ANALYZERS_JAR): $(LUCENE_JAR)
cd $(LUCENE)/analysis; $(ANT) -Dversion=$(LUCENE_VER) compile
$(MEMORY_JAR): $(LUCENE_JAR)
cd $(LUCENE)/memory; $(ANT) -Dversion=$(LUCENE_VER)
$(HIGHLIGHTER_JAR): $(LUCENE_JAR)
cd $(LUCENE)/highlighter; $(ANT) -Dversion=$(LUCENE_VER)
$(QUERIES_JAR): $(LUCENE_JAR)
cd $(LUCENE)/queries; $(ANT) -Dversion=$(LUCENE_VER)
$(QUERYPARSER_JAR): $(LUCENE_JAR)
cd $(LUCENE)/queryparser; $(ANT) -Dversion=$(LUCENE_VER)
$(SANDBOX_JAR): $(LUCENE_JAR)
cd $(LUCENE)/sandbox; $(ANT) -Dversion=$(LUCENE_VER)
$(EXTENSIONS_JAR): $(LUCENE_JAR)
$(ANT) -f extensions.xml -Dlucene.dir=$(LUCENE_SRC)
$(SMARTCN_JAR): $(LUCENE_JAR)
cd $(LUCENE)/analysis/smartcn; $(ANT) -Dversion=$(LUCENE_VER)
$(SPATIAL_JAR): $(LUCENE_JAR)
cd $(LUCENE)/spatial; $(ANT) -Dversion=$(LUCENE_VER)
$(GROUPING_JAR): $(LUCENE_JAR)
cd $(LUCENE)/grouping; $(ANT) -Dversion=$(LUCENE_VER)
$(JOIN_JAR): $(LUCENE_JAR)
cd $(LUCENE)/join; $(ANT) -Dversion=$(LUCENE_VER)
$(FACET_JAR): $(LUCENE_JAR)
cd $(LUCENE)/facet; $(ANT) -Dversion=$(LUCENE_VER)
$(SUGGEST_JAR): $(LUCENE_JAR)
cd $(LUCENE)/suggest; $(ANT) -Dversion=$(LUCENE_VER)
JCCFLAGS?=
jars: $(JARS)
ifneq ($(ICUPKG),)
ICURES= $(LUCENE)/analysis/icu/src/resources
RESOURCES=--resources $(ICURES)
ENDIANNESS:=$(shell $(PYTHON) -c "import struct; print struct.pack('h', 1) == '\000\001' and 'b' or 'l'")
resources: $(ICURES)/org/apache/lucene/analysis/icu/utr30.dat
$(ICURES)/org/apache/lucene/analysis/icu/utr30.dat: $(ICURES)/org/apache/lucene/analysis/icu/utr30.nrm
rm -f $@
cd $(dir $<); $(ICUPKG) --type $(ENDIANNESS) --add $(notdir $<) new $(notdir $@)
else
RESOURCES=
resources:
@echo ICU not installed
endif
GENERATE=$(JCC) $(foreach jar,$(JARS),--jar $(jar)) \
$(JCCFLAGS) \
--package java.lang java.lang.System \
java.lang.Runtime \
--package java.util java.util.Arrays \
java.util.HashMap \
java.util.HashSet \
java.lang.IllegalStateException \
java.lang.IndexOutOfBoundsException \
java.util.NoSuchElementException \
java.text.SimpleDateFormat \
java.text.DecimalFormat \
java.text.Collator \
--package java.util.regex \
--package java.io java.io.StringReader \
java.io.InputStreamReader \
java.io.FileInputStream \
--exclude org.apache.lucene.queryparser.classic.Token \
--exclude org.apache.lucene.queryparser.classic.TokenMgrError \
--exclude org.apache.lucene.queryparser.classic.QueryParserTokenManager \
--exclude org.apache.lucene.queryparser.classic.ParseException \
--exclude org.apache.lucene.queryparser.classic.CharStream \
--exclude org.apache.lucene.queryparser.classic.FastCharStream \
--exclude org.apache.lucene.queryparser.classic.QueryParserConstants \
--exclude org.apache.lucene.queryparser.surround.parser.Token \
--exclude org.apache.lucene.queryparser.surround.parser.CharStream \
--exclude org.apache.lucene.queryparser.surround.parser.QueryParserConstants \
--exclude org.apache.lucene.queryparser.surround.parser.TokenMgrError \
--exclude org.apache.lucene.queryparser.surround.parser.ParseException \
--exclude org.apache.lucene.queryparser.flexible.standard.parser.Token \
--exclude org.apache.lucene.queryparser.flexible.standard.parser.TokenMgrError \
--exclude org.apache.lucene.queryparser.flexible.standard.parser.ParseException \
--exclude org.apache.lucene.sandbox.queries.regex.JakartaRegexpCapabilities \
--exclude org.apache.regexp.RegexpTunnel \
--exclude org.apache.lucene.analysis.cn.smart.AnalyzerProfile \
--python lucene \
--mapping org.apache.lucene.document.Document 'get:(Ljava/lang/String;)Ljava/lang/String;' \
--mapping java.util.Properties 'getProperty:(Ljava/lang/String;)Ljava/lang/String;' \
--sequence java.util.AbstractList 'size:()I' 'get:(I)Ljava/lang/Object;' \
--rename org.apache.lucene.search.highlight.SpanScorer=HighlighterSpanScorer \
--rename org.apache.lucene.search.highlight.Scorer=HighlighterScorer \
--rename org.apache.lucene.search.spell.Dictionary=SpellDictionary \
--rename org.apache.lucene.search.suggest.fst.Sort=SuggestSort \
--rename org.apache.lucene.store.DataInput=StoreDataInput \
--rename org.apache.lucene.store.DataOutput=StoreDataOutput \
--rename org.tartarus.snowball.ext.DutchStemmer=DutchPorterStemmer \
--rename org.tartarus.snowball.ext.FrenchStemmer=FrenchPorterStemmer \
--rename org.tartarus.snowball.ext.GermanStemmer=GermanPorterStemmer \
--rename org.tartarus.snowball.ext.PortugueseStemmer=PortuguesePorterStemmer \
--rename org.apache.lucene.queryparser.surround.parser.QueryParser=SurroundQueryParser \
--rename org.apache.lucene.codecs.lucene40.values.Writer=ValuesWriter \
--rename org.apache.lucene.queryparser.xml.QueryBuilder=XMLQueryBuilder \
--rename org.apache.lucene.queryparser.surround.parser.FastCharStream=SurroundFastCharStream \
--rename org.apache.lucene.queryparser.flexible.standard.parser.CharStream=FlexibleParserCharStream \
--version $(LUCENE_VER) \
--module python/collections.py \
--module python/ICUNormalizer2Filter.py \
--module python/ICUFoldingFilter.py \
--module python/ICUTransformFilter.py \
$(RESOURCES) \
--files $(NUM_FILES)
generate: jars
$(GENERATE)
compile: jars
$(GENERATE) --build $(DEBUG_OPT)
install: jars
$(GENERATE) --install $(DEBUG_OPT) $(INSTALL_OPT)
bdist: jars
$(GENERATE) --bdist
wininst: jars
$(GENERATE) --wininst
all: sources ivy jars resources compile
@echo build of $(PYLUCENE_LIB) complete
clean:
if test -f $(LUCENE)/build.xml; then cd $(LUCENE); $(ANT) clean; fi
rm -rf $(LUCENE)/build build
realclean:
if test ! -d $(LUCENE)/.svn; then rm -rf $(LUCENE) lucene; else rm -rf $(LUCENE)/build; fi
rm -rf build samples/LuceneInAction/index samples/LuceneInAction/indexes
OS=$(shell uname)
BUILD_TEST:=$(PYLUCENE)/build/test
ifeq ($(findstring CYGWIN,$(OS)),CYGWIN)
BUILD_TEST:=`cygpath -aw $(BUILD_TEST)`
else
ifeq ($(findstring MINGW,$(OS)),MINGW)
BUILD_TEST:=`$(PYTHON) -c "import os, sys; print os.path.normpath(sys.argv[1]).replace(chr(92), chr(92)*2)" $(BUILD_TEST)`
endif
endif
install-test:
mkdir -p $(BUILD_TEST)
PYTHONPATH=$(BUILD_TEST) $(GENERATE) --install $(DEBUG_OPT) --install-dir $(BUILD_TEST)
samples/LuceneInAction/index:
cd samples/LuceneInAction; PYTHONPATH=$(BUILD_TEST) $(PYTHON) index.py
test: install-test samples/LuceneInAction/index
find test -name 'test_*.py' | PYTHONPATH=$(BUILD_TEST) xargs -t -n 1 $(PYTHON)
ls samples/LuceneInAction/*Test.py | PYTHONPATH=$(BUILD_TEST) xargs -t -n 1 $(PYTHON)
PYTHONPATH=$(BUILD_TEST) $(PYTHON) samples/LuceneInAction/AnalyzerDemo.py
PYTHONPATH=$(BUILD_TEST) $(PYTHON) samples/LuceneInAction/AnalyzerUtils.py
PYTHONPATH=$(BUILD_TEST) $(PYTHON) samples/LuceneInAction/BooksLikeThis.py
PYTHONPATH=$(BUILD_TEST) $(PYTHON) samples/LuceneInAction/Explainer.py samples/LuceneInAction/index programming
PYTHONPATH=$(BUILD_TEST) $(PYTHON) samples/LuceneInAction/HighlightIt.py
PYTHONPATH=$(BUILD_TEST) $(PYTHON) samples/LuceneInAction/SortingExample.py
PYTHONPATH=$(BUILD_TEST) $(PYTHON) samples/LuceneInAction/SynonymAnalyzerViewer.py
ARCHIVE=pylucene-$(VERSION)-src.tar.gz
distrib:
mkdir -p distrib
svn export . distrib/pylucene-$(VERSION)
tar -cf - --exclude build $(LUCENE_SRC) | tar -C distrib/pylucene-$(VERSION) -xvf -
cd distrib; tar -cvzf $(ARCHIVE) pylucene-$(VERSION)
cd distrib; gpg2 --armor --output $(ARCHIVE).asc --detach-sig $(ARCHIVE)
cd distrib; openssl md5 < $(ARCHIVE) > $(ARCHIVE).md5
stage:
cd distrib; scp -p $(ARCHIVE) $(ARCHIVE).asc $(ARCHIVE).md5 \
people.apache.org:public_html/staging_area
release:
cd distrib; scp -p $(ARCHIVE) $(ARCHIVE).asc $(ARCHIVE).md5 \
people.apache.org:/www/www.apache.org/dist/lucene/pylucene
print-%:
@echo $* = $($*)