76bad4
diff -up gsm-1.0-pl17/Makefile.mk gsm-1.0-pl17/Makefile
76bad4
--- gsm-1.0-pl17/Makefile.mk	2017-06-28 02:24:24.000000000 +0200
76bad4
+++ gsm-1.0-pl17/Makefile	2017-06-29 13:18:44.138719902 +0200
76bad4
@@ -44,13 +44,17 @@ WAV49	= -DWAV49
76bad4
 # CCFLAGS 	= -c -O
76bad4
 
76bad4
 CC		= gcc -ansi -pedantic
76bad4
-CCFLAGS 	= -c -O2 -DNeedFunctionPrototypes=1 -Wall -Wno-comment
76bad4
+CCFLAGS 	= -c $(RPM_OPT_FLAGS) -DNeedFunctionPrototypes=1 -Wall -Wno-comment -D_XOPEN_SOURCE=700 -D_REENTRANT -fPIC
76bad4
 
76bad4
 LD 		= $(CC)
76bad4
 
76bad4
 # LD		= gcc
76bad4
 # LDFLAGS 	=
76bad4
 
76bad4
+SO_MAJOR = 1
76bad4
+SO_MINOR = 0
76bad4
+SO_MICRO = 17
76bad4
+SO_VER = $(SO_MAJOR).$(SO_MINOR).$(SO_MICRO)
76bad4
 
76bad4
 # If your compiler needs additional flags/libraries, regardless of
76bad4
 # the source compiled, configure them here.
76bad4
@@ -81,7 +85,7 @@ INSTALL_ROOT	=
76bad4
 GSM_INSTALL_ROOT = $(INSTALL_ROOT)
76bad4
 GSM_INSTALL_LIB = $(GSM_INSTALL_ROOT)/lib
76bad4
 GSM_INSTALL_INC = $(GSM_INSTALL_ROOT)/inc
76bad4
-GSM_INSTALL_MAN = $(GSM_INSTALL_ROOT)/man/man3
76bad4
+GSM_INSTALL_MAN = $(GSM_INSTALL_ROOT)/share/man/man3
76bad4
 
76bad4
 
76bad4
 # Where do you want to install the toast binaries and their manpage?
76bad4
@@ -91,16 +95,16 @@ GSM_INSTALL_MAN = $(GSM_INSTALL_ROOT)/ma
76bad4
 
76bad4
 TOAST_INSTALL_ROOT	  = $(INSTALL_ROOT)
76bad4
 TOAST_INSTALL_BIN = $(TOAST_INSTALL_ROOT)/bin
76bad4
-TOAST_INSTALL_MAN = $(TOAST_INSTALL_ROOT)/man/man1
76bad4
+TOAST_INSTALL_MAN = $(TOAST_INSTALL_ROOT)/share/man/man1
76bad4
 
76bad4
 #  Other tools
76bad4
 
76bad4
 SHELL		= /bin/sh
76bad4
-LN		= ln
76bad4
+LN		= ln -s
76bad4
 BASENAME 	= basename
76bad4
 AR		= ar
76bad4
 ARFLAGS		= cr
76bad4
-RMFLAGS		=
76bad4
+RMFLAGS		= -f
76bad4
 FIND		= find
76bad4
 COMPRESS 	= compress
76bad4
 COMPRESSFLAGS 	= 
76bad4
@@ -140,6 +144,7 @@ LFLAGS	= $(LDFLAGS) $(LDINC)
76bad4
 # Targets
76bad4
 
76bad4
 LIBGSM	= $(LIB)/libgsm.a
76bad4
+LIBGSMSO = $(LIB)/libgsm.so
76bad4
 
76bad4
 TOAST	= $(BIN)/toast
76bad4
 UNTOAST	= $(BIN)/untoast
76bad4
@@ -257,7 +262,9 @@ STUFF = 	ChangeLog			\
76bad4
 # Install targets
76bad4
 
76bad4
 GSM_INSTALL_TARGETS =	\
76bad4
-		$(GSM_INSTALL_LIB)/libgsm.a		\
76bad4
+		$(GSM_INSTALL_LIB)/libgsm.so.$(SO_VER)	\
76bad4
+		$(GSM_INSTALL_LIB)/libgsm.so.$(SO_MAJOR)\
76bad4
+		$(GSM_INSTALL_LIB)/libgsm.so		\
76bad4
 		$(GSM_INSTALL_INC)/gsm.h		\
76bad4
 		$(GSM_INSTALL_MAN)/gsm.3		\
76bad4
 		$(GSM_INSTALL_MAN)/gsm_explode.3	\
76bad4
@@ -279,7 +286,7 @@ TOAST_INSTALL_TARGETS =	\
76bad4
 
76bad4
 # Target rules
76bad4
 
76bad4
-all:		$(LIBGSM) $(TOAST) $(TCAT) $(UNTOAST)
76bad4
+all:		$(LIBGSMSO) $(TOAST) $(TCAT) $(UNTOAST)
76bad4
 		@-echo $(ROOT): Done.
76bad4
 
76bad4
 tst:		$(TST)/lin2cod $(TST)/cod2lin $(TOAST) $(TST)/test-result
76bad4
@@ -299,24 +306,32 @@ install:	toastinstall gsminstall
76bad4
 
76bad4
 # The basic API: libgsm
76bad4
 
76bad4
+$(LIBGSMSO).$(SO_VER): $(LIB) $(GSM_OBJECTS)
76bad4
+		$(LD) $(LFLAGS) -o $@ -shared -Xlinker -soname -Xlinker libgsm.so.$(SO_MAJOR) $(GSM_OBJECTS) -lc
76bad4
+
76bad4
+$(LIBGSMSO).$(SO_MAJOR): $(LIBGSMSO).$(SO_VER)
76bad4
+		ln -fs libgsm.so.$(SO_VER) lib/libgsm.so.$(SO_MAJOR)
76bad4
+
76bad4
+$(LIBGSMSO): $(LIBGSMSO).$(SO_VER)
76bad4
+		ln -fs libgsm.so.$(SO_VER) lib/libgsm.so
76bad4
+
76bad4
 $(LIBGSM):	$(LIB) $(GSM_OBJECTS)
76bad4
 		-rm $(RMFLAGS) $(LIBGSM)
76bad4
 		$(AR) $(ARFLAGS) $(LIBGSM) $(GSM_OBJECTS)
76bad4
 		$(RANLIB) $(LIBGSM)
76bad4
 
76bad4
-
76bad4
 # Toast, Untoast and Tcat -- the compress-like frontends to gsm.
76bad4
 
76bad4
-$(TOAST):	$(BIN) $(TOAST_OBJECTS) $(LIBGSM)
76bad4
-		$(LD) $(LFLAGS) -o $(TOAST) $(TOAST_OBJECTS) $(LIBGSM) $(LDLIB)
76bad4
+$(TOAST):	$(BIN) $(TOAST_OBJECTS) $(LIBGSMSO)
76bad4
+		$(LD) $(LFLAGS) -o $(TOAST) $(TOAST_OBJECTS) $(LIBGSMSO) $(LDLIB)
76bad4
 
76bad4
 $(UNTOAST):	$(BIN) $(TOAST)
76bad4
 		-rm $(RMFLAGS) $(UNTOAST)
76bad4
-		$(LN) $(TOAST) $(UNTOAST)
76bad4
+		$(LN) toast $(UNTOAST)
76bad4
 
76bad4
 $(TCAT):	$(BIN) $(TOAST)
76bad4
 		-rm $(RMFLAGS) $(TCAT)
76bad4
-		$(LN) $(TOAST) $(TCAT)
76bad4
+		$(LN) toast $(TCAT)
76bad4
 
76bad4
 
76bad4
 # The local bin and lib directories
76bad4
@@ -352,8 +367,7 @@ toastuninstall:
76bad4
 
76bad4
 $(TOAST_INSTALL_BIN)/toast:	$(TOAST)
76bad4
 		-rm $@
76bad4
-		cp $(TOAST) $@
76bad4
-		chmod 755 $@
76bad4
+		install -pm755 $(TOAST) $@
76bad4
 
76bad4
 $(TOAST_INSTALL_BIN)/untoast:	$(TOAST_INSTALL_BIN)/toast
76bad4
 		-rm $@
76bad4
@@ -365,39 +379,43 @@ $(TOAST_INSTALL_BIN)/tcat:	$(TOAST_INSTA
76bad4
 
76bad4
 $(TOAST_INSTALL_MAN)/toast.1:	$(MAN)/toast.1
76bad4
 		-rm $@
76bad4
-		cp $? $@
76bad4
-		chmod 444 $@
76bad4
+		install -pm644 $? $@
76bad4
 
76bad4
 $(GSM_INSTALL_MAN)/gsm.3:	$(MAN)/gsm.3
76bad4
 		-rm $@
76bad4
-		cp $? $@
76bad4
-		chmod 444 $@
76bad4
+		install -pm644 $? $@
76bad4
 
76bad4
 $(GSM_INSTALL_MAN)/gsm_option.3:	$(MAN)/gsm_option.3
76bad4
 		-rm $@
76bad4
-		cp $? $@
76bad4
-		chmod 444 $@
76bad4
+		install -pm644 $? $@
76bad4
 
76bad4
 $(GSM_INSTALL_MAN)/gsm_explode.3:	$(MAN)/gsm_explode.3
76bad4
 		-rm $@
76bad4
-		cp $? $@
76bad4
-		chmod 444 $@
76bad4
+		install -pm644 $? $@
76bad4
 
76bad4
 $(GSM_INSTALL_MAN)/gsm_print.3:	$(MAN)/gsm_print.3
76bad4
 		-rm $@
76bad4
-		cp $? $@
76bad4
-		chmod 444 $@
76bad4
+		install -pm644 $? $@
76bad4
 
76bad4
 $(GSM_INSTALL_INC)/gsm.h:	$(INC)/gsm.h
76bad4
 		-rm $@
76bad4
-		cp $? $@
76bad4
-		chmod 444 $@
76bad4
+		install -pm644 $? $@
76bad4
 
76bad4
 $(GSM_INSTALL_LIB)/libgsm.a:	$(LIBGSM)
76bad4
 		-rm $@
76bad4
-		cp $? $@
76bad4
-		chmod 444 $@
76bad4
+		install -pm644 $? $@
76bad4
 
76bad4
+$(GSM_INSTALL_LIB)/libgsm.so.$(SO_VER):	$(LIBGSMSO).$(SO_VER)
76bad4
+		-rm $@
76bad4
+		install -pm755 $? $@
76bad4
+
76bad4
+$(GSM_INSTALL_LIB)/libgsm.so.$(SO_MAJOR):	$(LIBGSMSO).$(SO_MAJOR)
76bad4
+		-rm $@
76bad4
+		ln -s libgsm.so.$(SO_VER) $@
76bad4
+
76bad4
+$(GSM_INSTALL_LIB)/libgsm.so:	$(LIBGSMSO)
76bad4
+		-rm $@
76bad4
+		ln -s libgsm.so.$(SO_VER) $@
76bad4
 
76bad4
 # Distribution
76bad4