--- a/GNUmakefile
+++ b/GNUmakefile
@@ -8,6 +8,8 @@
 EXEEXT = .exe
 endif
 
+MAJOR_VERSION := $(shell echo $(SNOWBALL_VERSION) | cut -d. -f1)
+
 c_src_dir = src_c
 
 JAVAC ?= javac
@@ -170,12 +172,12 @@
 JAVA_CLASSES = $(JAVA_SOURCES:.java=.class)
 JAVA_RUNTIME_CLASSES=$(JAVARUNTIME_SOURCES:.java=.class)
 
-CFLAGS=-O2 -W -Wall -Wmissing-prototypes -Wmissing-declarations
+CFLAGS=-fPIC -O2 -W -Wall -Wmissing-prototypes -Wmissing-declarations
 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
@@ -224,6 +226,11 @@
 
 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,-soname,$@.$(MAJOR_VERSION),-version-script,libstemmer/symbol.map -o $@.$(SNOWBALL_VERSION) $^
+	ln -s $@.$(SNOWBALL_VERSION) $@.$(MAJOR_VERSION)
+	ln -s $@.$(SNOWBALL_VERSION) $@
 
 examples/%.o: examples/%.c
 	$(CC) $(CFLAGS) $(INCLUDES) $(CPPFLAGS) -c -o $@ $<
--- /dev/null
+++ b/libstemmer/symbol.map
@@ -0,0 +1,6 @@
+SB_STEMMER_0 {
+    global:
+        sb_stemmer_*;
+    local:
+        *;
+};
