git » snowball.git » main » tree

[main] / dynamiclib.diff

 GNUmakefile           | 15 +++++++--------
 libstemmer/symbol.map |  6 ++++++
 2 files changed, 13 insertions(+), 8 deletions(-)

diff --git c/GNUmakefile i/GNUmakefile
index 98eb1fa..86e4855 100644
--- c/GNUmakefile
+++ i/GNUmakefile
@@ -170,20 +170,19 @@ C_OTHER_OBJECTS = $(C_OTHER_SOURCES:.c=.o)
 JAVA_CLASSES = $(JAVA_SOURCES:.java=.class)
 JAVA_RUNTIME_CLASSES=$(JAVARUNTIME_SOURCES:.java=.class)
 
-CFLAGS=-O2 -W -Wall -Wmissing-prototypes -Wmissing-declarations
-CPPFLAGS=
+CFLAGS+=-fPIC -W -Wall -Wmissing-prototypes -Wmissing-declarations
 
 INCLUDES=-Iinclude
 
-all: snowball$(EXEEXT) libstemmer.a stemwords$(EXEEXT) $(C_OTHER_SOURCES) $(C_OTHER_HEADERS) $(C_OTHER_OBJECTS)
+all: snowball$(EXEEXT) libstemmer.so.0 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
 
 clean:
 	rm -f $(COMPILER_OBJECTS) $(RUNTIME_OBJECTS) \
 	      $(LIBSTEMMER_OBJECTS) $(LIBSTEMMER_UTF8_OBJECTS) $(STEMWORDS_OBJECTS) snowball$(EXEEXT) \
-	      libstemmer.a stemwords$(EXEEXT) \
+	      libstemmer.so.0 stemwords$(EXEEXT) \
               libstemmer/modules.h \
               libstemmer/modules_utf8.h \
 	      $(C_LIB_SOURCES) $(C_LIB_HEADERS) $(C_LIB_OBJECTS) \
@@ -222,19 +221,19 @@ libstemmer/modules_utf8.h libstemmer/mkinc_utf8.mak: libstemmer/mkmodules.pl lib
 
 libstemmer/libstemmer.o: libstemmer/modules.h $(C_LIB_HEADERS)
 
-libstemmer.a: libstemmer/libstemmer.o $(RUNTIME_OBJECTS) $(C_LIB_OBJECTS)
-	$(AR) -cru $@ $^
+libstemmer.so.0: libstemmer/libstemmer.o $(RUNTIME_OBJECTS) $(C_LIB_OBJECTS)
+	$(CC) $(CFLAGS) -shared $(LDFLAGS) -Wl,-soname,$@,-version-script,libstemmer/symbol.map -o $@ $^
 
 examples/%.o: examples/%.c
 	$(CC) $(CFLAGS) $(INCLUDES) $(CPPFLAGS) -c -o $@ $<
 
-stemwords$(EXEEXT): $(STEMWORDS_OBJECTS) libstemmer.a
+stemwords$(EXEEXT): $(STEMWORDS_OBJECTS) libstemmer.so.0
 	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
 
 tests/%.o: tests/%.c
 	$(CC) $(CFLAGS) $(INCLUDES) $(CPPFLAGS) -c -o $@ $<
 
-stemtest$(EXEEXT): $(STEMTEST_OBJECTS) libstemmer.a
+stemtest$(EXEEXT): $(STEMTEST_OBJECTS) libstemmer.so.0
 	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
 
 csharp_stemwords$(EXEEXT): $(CSHARP_STEMWORDS_SOURCES) $(CSHARP_RUNTIME_SOURCES) $(CSHARP_SOURCES)
diff --git c/libstemmer/symbol.map i/libstemmer/symbol.map
new file mode 100644
index 0000000..7a3d423
--- /dev/null
+++ i/libstemmer/symbol.map
@@ -0,0 +1,6 @@
+SB_STEMMER_0 {
+    global:
+        sb_stemmer_*;
+    local:
+        *;
+};