--- Makefile.orig	2011-11-03 11:49:56.862331506 +0100
+++ Makefile	2011-11-03 11:53:52.750659225 +0100
@@ -140,6 +140,7 @@ LFLAGS	= $(LDFLAGS) $(LDINC)
 # Targets
 
 LIBGSM	= $(LIB)/libgsm.a
+LIBGSM_SO = $(LIB)/libgsm.so
 
 TOAST	= $(BIN)/toast
 UNTOAST	= $(BIN)/untoast
@@ -257,6 +258,7 @@ STUFF = 	ChangeLog			\
 # Install targets
 
 GSM_INSTALL_TARGETS =	\
+		$(GSM_INSTALL_LIB)/libgsm.so		\
 		$(GSM_INSTALL_LIB)/libgsm.a		\
 		$(GSM_INSTALL_INC)/gsm.h		\
 		$(GSM_INSTALL_MAN)/gsm.3		\
@@ -274,12 +276,12 @@ TOAST_INSTALL_TARGETS =	\
 # Default rules
 
 .c.o:
-		$(CC) $(CFLAGS) $?
+		$(CC) -fPIC -DPIC $(CFLAGS) $?
 		@-mv `$(BASENAME) $@` $@ > /dev/null 2>&1
 
 # Target rules
 
-all:		$(LIBGSM) $(TOAST) $(TCAT) $(UNTOAST)
+all:		$(LIBGSM) $(LIBGSM_SO) $(TOAST) $(TCAT) $(UNTOAST)
 		@-echo $(ROOT): Done.
 
 tst:		$(TST)/lin2cod $(TST)/cod2lin $(TOAST) $(TST)/test-result
@@ -304,6 +306,9 @@ $(LIBGSM):	$(LIB) $(GSM_OBJECTS)
 		$(AR) $(ARFLAGS) $(LIBGSM) $(GSM_OBJECTS)
 		$(RANLIB) $(LIBGSM)
 
+$(LIBGSM_SO):	$(LIB) $(GSM_OBJECTS)
+		-rm $(RMFLAGS) $(LIBGSM_SO)
+		$(LD) -shared $(LFLAGS) -o $(LIBGSM_SO) $(GSM_OBJECTS)
 
 # Toast, Untoast and Tcat -- the compress-like frontends to gsm.
 
@@ -398,6 +403,9 @@ $(GSM_INSTALL_LIB)/libgsm.a:	$(LIBGSM)
 		cp $? $@
 		chmod 444 $@
 
+$(GSM_INSTALL_LIB)/libgsm.so:	$(LIBGSM_SO)
+		-rm $@
+		install -m755 $? $@
 
 # Distribution
 
