File: shared-library.diff

package info (click to toggle)
snowball 3.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,708 kB
  • sloc: ansic: 15,641; ada: 849; python: 531; cs: 485; pascal: 473; java: 473; javascript: 411; perl: 312; sh: 40; makefile: 17
file content (145 lines) | stat: -rw-r--r-- 6,133 bytes parent folder | download
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
From: Stefano Rivera <stefanor@debian.org>
Date: Sun, 24 Jan 2021 19:07:24 -0700
Subject: Build libstemmer as a shared library.

Forwarded: https://github.com/snowballstem/snowball/pull/42
---
 GNUmakefile | 42 ++++++++++++++++++++++++++++--------------
 1 file changed, 28 insertions(+), 14 deletions(-)

diff --git a/GNUmakefile b/GNUmakefile
index 8c50ec5..c9754be 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -65,6 +65,8 @@ ICONV = iconv
 STEMMING_DATA ?= ../snowball-data
 STEMMING_DATA_ABS := $(abspath $(STEMMING_DATA))
 
+STEMWORDS=LD_LIBRARY_PATH=.:$(LD_LIBRARY_PATH) ./stemwords$(EXEEXT)
+
 # Keep one in $(THIN_FACTOR) entries from gzipped vocabularies.
 THIN_FACTOR ?= 3
 
@@ -195,7 +197,7 @@ CPPFLAGS?=
 
 INCLUDES=-Iinclude
 
-all: snowball$(EXEEXT) libstemmer.a stemwords$(EXEEXT) $(C_OTHER_SOURCES) $(C_OTHER_HEADERS) $(C_OTHER_OBJECTS)
+all: snowball$(EXEEXT) libstemmer.a libstemmer.so stemwords$(EXEEXT) $(C_OTHER_SOURCES) $(C_OTHER_HEADERS) $(C_OTHER_OBJECTS)
 
 algorithms.mk: libstemmer/mkalgorithms.pl libstemmer/modules.txt
 	libstemmer/mkalgorithms.pl algorithms.mk libstemmer/modules.txt
@@ -203,7 +205,7 @@ algorithms.mk: libstemmer/mkalgorithms.pl libstemmer/modules.txt
 clean:
 	rm -f $(COMPILER_OBJECTS) $(RUNTIME_OBJECTS) \
 	      $(LIBSTEMMER_OBJECTS) $(LIBSTEMMER_UTF8_OBJECTS) $(STEMWORDS_OBJECTS) snowball$(EXEEXT) \
-	      libstemmer.a stemwords$(EXEEXT) \
+	      libstemmer.a libstemmer.so stemwords$(EXEEXT) \
               libstemmer/modules.h \
               libstemmer/modules_utf8.h \
 	      $(C_LIB_SOURCES) $(C_LIB_HEADERS) $(C_LIB_OBJECTS) \
@@ -219,7 +221,7 @@ clean:
               libstemmer/mkinc.mak libstemmer/mkinc_utf8.mak \
               libstemmer/libstemmer.c libstemmer/libstemmer_utf8.c \
 	      algorithms.mk
-	rm -rf ada/obj dist
+	rm -rf ada/obj dist .shared
 	-rmdir $(c_src_dir)
 	-rmdir $(python_output_dir)
 	-rmdir $(js_output_dir)
@@ -257,17 +259,25 @@ libstemmer/libstemmer.o: libstemmer/modules.h $(C_LIB_HEADERS)
 libstemmer.a: libstemmer/libstemmer.o $(RUNTIME_OBJECTS) $(C_LIB_OBJECTS)
 	$(AR) -cru $@ $^
 
+libstemmer.so: libstemmer/libstemmer.o $(RUNTIME_OBJECTS) $(C_LIB_OBJECTS)
+	$(CC) $(CFLAGS) -shared $(LDFLAGS) \
+	      -Wl,--version-script=debian/libstemmer.ver,-soname,libstemmer.so.0d \
+	      -o $@.0d.0.0 ${^:%=.shared/%}
+	ln -s $@.0d.0.0 $@.0d
+	ln -s $@.0d.0.0 $@
+	$(AR) -crs ${@:.so=.a} $^
+
 examples/%.o: examples/%.c
 	$(CC) $(CFLAGS) $(INCLUDES) $(CPPFLAGS) -c -o $@ $<
 
-stemwords$(EXEEXT): $(STEMWORDS_OBJECTS) libstemmer.a
-	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
+stemwords$(EXEEXT): $(STEMWORDS_OBJECTS) libstemmer.so
+	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(STEMWORDS_OBJECTS) -L. -lstemmer
 
 tests/%.o: tests/%.c
 	$(CC) $(CFLAGS) $(INCLUDES) $(CPPFLAGS) -c -o $@ $<
 
-stemtest$(EXEEXT): $(STEMTEST_OBJECTS) libstemmer.a
-	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
+stemtest$(EXEEXT): $(STEMTEST_OBJECTS) libstemmer.so
+	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(STEMTEST_OBJECTS) -L. -lstemmer
 
 csharp_stemwords$(EXEEXT): $(CSHARP_STEMWORDS_SOURCES) $(CSHARP_RUNTIME_SOURCES) $(CSHARP_SOURCES)
 	$(MCS) -unsafe -target:exe -out:$@ $(CSHARP_STEMWORDS_SOURCES) $(CSHARP_RUNTIME_SOURCES) $(CSHARP_SOURCES)
@@ -295,7 +305,6 @@ $(c_src_dir)/stem_ISO_8859_2_%.c $(c_src_dir)/stem_ISO_8859_2_%.h: algorithms/%.
 	./snowball charsets/ISO-8859-2.sbl $< -o "$(c_src_dir)/stem_ISO_8859_2_$*" -eprefix $*_ISO_8859_2_ -r ../runtime
 
 $(c_src_dir)/stem_%.o: $(c_src_dir)/stem_%.c $(c_src_dir)/stem_%.h
-	$(CC) $(CFLAGS) $(INCLUDES) $(CPPFLAGS) -c -o $@ $<
 
 $(java_src_dir)/%Stemmer.java: algorithms/%.sbl snowball$(EXEEXT)
 	@mkdir -p $(java_src_dir)
@@ -509,7 +518,7 @@ dist_libstemmer_js: $(JS_SOURCES) $(COMMON_FILES)
 check: check_stemtest check_utf8 check_iso_8859_1 check_iso_8859_2 check_koi8r
 
 check_stemtest: stemtest$(EXEEXT)
-	./stemtest
+	LD_LIBRARY_PATH=.:$(LD_LIBRARY_PATH) ./stemtest
 
 check_utf8: $(libstemmer_algorithms:%=check_utf8_%)
 
@@ -522,9 +531,9 @@ check_koi8r: $(KOI8_R_algorithms:%=check_koi8r_%)
 check_utf8_%: $(STEMMING_DATA)/% stemwords$(EXEEXT)
 	@echo "Checking output of $* stemmer with UTF-8"
 	@if test -f '$</voc.txt.gz' ; then \
-	  gzip -dc '$</voc.txt.gz'|./stemwords$(EXEEXT) -c UTF_8 -l $* -o tmp.txt; \
+	  gzip -dc '$</voc.txt.gz'|$(STEMWORDS) -c UTF_8 -l $* -o tmp.txt; \
 	else \
-	  ./stemwords$(EXEEXT) -c UTF_8 -l $* -i $</voc.txt -o tmp.txt; \
+	  $(STEMWORDS) -c UTF_8 -l $* -i $</voc.txt -o tmp.txt; \
 	fi
 	@if test -f '$</output.txt.gz' ; then \
 	  gzip -dc '$</output.txt.gz'|$(DIFF) -u - tmp.txt; \
@@ -536,7 +545,7 @@ check_utf8_%: $(STEMMING_DATA)/% stemwords$(EXEEXT)
 check_iso_8859_1_%: $(STEMMING_DATA)/% stemwords$(EXEEXT)
 	@echo "Checking output of $* stemmer with ISO_8859_1"
 	@$(ICONV) -f UTF-8 -t ISO-8859-1 '$</voc.txt' |\
-	    ./stemwords -c ISO_8859_1 -l $* -o tmp.txt
+	    $(STEMWORDS) -c ISO_8859_1 -l $* -o tmp.txt
 	@$(ICONV) -f UTF-8 -t ISO-8859-1 '$</output.txt' |\
 	    $(DIFF) -u - tmp.txt
 	@rm tmp.txt
@@ -544,7 +553,7 @@ check_iso_8859_1_%: $(STEMMING_DATA)/% stemwords$(EXEEXT)
 check_iso_8859_2_%: $(STEMMING_DATA)/% stemwords$(EXEEXT)
 	@echo "Checking output of $* stemmer with ISO_8859_2"
 	@$(ICONV) -f UTF-8 -t ISO-8859-2 '$</voc.txt' |\
-	    ./stemwords -c ISO_8859_2 -l $* -o tmp.txt
+	    $(STEMWORDS) -c ISO_8859_2 -l $* -o tmp.txt
 	@$(ICONV) -f UTF-8 -t ISO-8859-2 '$</output.txt' |\
 	    $(DIFF) -u - tmp.txt
 	@rm tmp.txt
@@ -552,7 +561,7 @@ check_iso_8859_2_%: $(STEMMING_DATA)/% stemwords$(EXEEXT)
 check_koi8r_%: $(STEMMING_DATA)/% stemwords$(EXEEXT)
 	@echo "Checking output of $* stemmer with KOI8R"
 	@$(ICONV) -f UTF-8 -t KOI8-R '$</voc.txt' |\
-	    ./stemwords -c KOI8_R -l $* -o tmp.txt
+	    $(STEMWORDS) -c KOI8_R -l $* -o tmp.txt
 	@$(ICONV) -f UTF-8 -t KOI8-R '$</output.txt' |\
 	    $(DIFF) -u - tmp.txt
 	@rm tmp.txt
@@ -797,4 +806,9 @@ ada/bin/generate:
 ada/bin/stemwords: $(ADA_SOURCES)
 	cd ada && $(gprbuild) -Pstemwords -p
 
+%.o: %.c
+	@mkdir -p $(shell dirname ${@:%=.shared/%})
+	$(CC) $(CFLAGS) $(CPPFLAGS) -c -fPIC -o ${@:%=.shared/%} $<
+	$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
+
 .SUFFIXES: .class .java