--- a/src/Makefile
+++ b/src/Makefile
@@ -1,4 +1,5 @@
-LIBRARIES = libb64.a
+LIBRARIES = libb64.a libb64.so
+SOVERSION ?= 0

 # Build flags (uncomment one)
 #############################
@@ -27,11 +28,20 @@
 libb64.a: cencode.o cdecode.o
 	$(AR) $(ARFLAGS) $@ $^

+libb64.so.$(SOVERSION): cencode.So cdecode.So
+	$(CC) $(CFLAGS) $(LDFLAGS) -shared -Wl,-soname,$@ -o $@ $^
+
+%.So: %.c
+	$(CC) -fPIC -c $(CFLAGS) $(CPPFLAGS) $< -o $@
+
+%.so: %.so.$(SOVERSION)
+	ln -fs $< $@
+
 strip:
 	strip $(BINARIES) *.exe

 clean:
-	rm -f *.exe* *.o $(TARGETS) *.bak *~
+	rm -f *.exe* *.o $(TARGETS) *.bak *~ *.So *.so*

 distclean: clean
 	rm -f depend