--- Makefile	1996-07-02 16:36:06.000000000 +0200
+++ Makefile.oden	2004-09-11 17:39:00.308986936 +0200
@@ -30,6 +30,10 @@
 ######### define this, and read about the GSM_OPT_WAV49 option in the
 ######### manual page on gsm_option(3).
 
+PG =
+#PG = -g -pg
+######### Profiling flags.  If you don't know what that means, leave it blank
+
 # Choose a compiler.  The code works both with ANSI and K&R-C.
 # Use -DNeedFunctionPrototypes to compile with, -UNeedFunctionPrototypes to
 # compile without, function prototypes in the header files.
@@ -44,7 +48,7 @@
 # CCFLAGS 	= -c -O
 
 CC		= gcc -ansi -pedantic
-CCFLAGS 	= -c -O2 -DNeedFunctionPrototypes=1
+CCFLAGS 	= -c $(RPM_OPT_FLAGS) -fPIC -D_REENTRANT -DNeedFunctionPrototypes=1
 
 LD 		= $(CC)
 
@@ -64,43 +68,27 @@
 # LDLIB	= -lgcc
 ######### Additional libraries needed by $(LD)
 
-
-# Where do you want to install libraries, binaries, a header file
-# and the manual pages?
-#
-# Leave INSTALL_ROOT empty (or just don't execute "make install") to
-# not install gsm and toast outside of this directory.
-
-INSTALL_ROOT	=
-
 # Where do you want to install the gsm library, header file, and manpages?
 #
-# Leave GSM_INSTALL_ROOT empty to not install the GSM library outside of
+# Leave DESTDIR empty to not install the GSM library outside of
 # this directory.
 
-GSM_INSTALL_ROOT = $(INSTALL_ROOT)
-GSM_INSTALL_LIB = $(GSM_INSTALL_ROOT)/lib
-GSM_INSTALL_INC = $(GSM_INSTALL_ROOT)/inc
-GSM_INSTALL_MAN = $(GSM_INSTALL_ROOT)/man/man3
+DESTDIR = 
 
-
-# Where do you want to install the toast binaries and their manpage?
-#
-# Leave TOAST_INSTALL_ROOT empty to not install the toast binaries outside
-# of this directory.
-
-TOAST_INSTALL_ROOT	  = $(INSTALL_ROOT)
-TOAST_INSTALL_BIN = $(TOAST_INSTALL_ROOT)/bin
-TOAST_INSTALL_MAN = $(TOAST_INSTALL_ROOT)/man/man1
+prefix = /usr
+libdir = $(prefix)/lib
+includedir = $(prefix)/include
+datadir = $(prefix)/share
+mandir = $(datadir)/man
 
 #  Other tools
 
 SHELL		= /bin/sh
-LN		= ln
+LN		= ln -s
 BASENAME 	= basename
 AR		= ar
 ARFLAGS		= cr
-RMFLAGS		=
+RMFLAGS		= -f
 FIND		= find
 COMPRESS 	= compress
 COMPRESSFLAGS 	= 
@@ -129,17 +117,18 @@
 # DEBUG	= -DNDEBUG
 ######### Remove -DNDEBUG to enable assertions.
 
-CFLAGS	= $(CCFLAGS) $(SASR) $(DEBUG) $(MULHACK) $(FAST) $(LTP_CUT) \
+CFLAGS	= $(PG) $(CCFLAGS) $(SASR) $(DEBUG) $(MULHACK) $(FAST) $(LTP_CUT) \
 	$(WAV49) $(CCINC) -I$(INC)
 ######### It's $(CC) $(CFLAGS)
 
-LFLAGS	= $(LDFLAGS) $(LDINC)
+LFLAGS	= $(PG) $(LDFLAGS) $(LDINC)
 ######### It's $(LD) $(LFLAGS)
 
 
 # Targets
 
 LIBGSM	= $(LIB)/libgsm.a
+LIBGSMSO = $(LIB)/libgsm.so
 
 TOAST	= $(BIN)/toast
 UNTOAST	= $(BIN)/untoast
@@ -257,18 +246,19 @@
 # Install targets
 
 GSM_INSTALL_TARGETS =	\
-		$(GSM_INSTALL_LIB)/libgsm.a		\
-		$(GSM_INSTALL_INC)/gsm.h		\
-		$(GSM_INSTALL_MAN)/gsm.3		\
-		$(GSM_INSTALL_MAN)/gsm_explode.3	\
-		$(GSM_INSTALL_MAN)/gsm_option.3		\
-		$(GSM_INSTALL_MAN)/gsm_print.3
+		$(DESTDIR)$(libdir)/libgsm.a		\
+		$(DESTDIR)$(libdir)/libgsm.so		\
+		$(DESTDIR)$(includedir)/gsm/gsm.h	\
+		$(DESTDIR)$(mandir)/man3/gsm.3		\
+		$(DESTDIR)$(mandir)/man3/gsm_explode.3	\
+		$(DESTDIR)$(mandir)/man3/gsm_option.3	\
+		$(DESTDIR)$(mandir)/man3/gsm_print.3
 
 TOAST_INSTALL_TARGETS =	\
-		$(TOAST_INSTALL_BIN)/toast		\
-		$(TOAST_INSTALL_BIN)/tcat		\
-		$(TOAST_INSTALL_BIN)/untoast		\
-		$(TOAST_INSTALL_MAN)/toast.1
+		$(DESTDIR)$(bindir)/toast		\
+		$(DESTDIR)$(bindir)/tcat		\
+		$(DESTDIR)$(bindir)/untoast		\
+		$(DESTDIR)$(mandir)/man1/toast.1
 
 
 # Default rules
@@ -279,7 +269,7 @@
 
 # Target rules
 
-all:		$(LIBGSM) $(TOAST) $(TCAT) $(UNTOAST)
+all:		$(LIBGSM) $(LIBGSMSO) $(TOAST) $(TCAT) $(UNTOAST)
 		@-echo $(ROOT): Done.
 
 tst:		$(TST)/lin2cod $(TST)/cod2lin $(TOAST) $(TST)/test-result
@@ -299,24 +289,28 @@
 
 # The basic API: libgsm
 
+$(LIBGSMSO): $(LIB) $(GSM_OBJECTS)
+			$(LD) -o $@.1.0.10 -shared -Xlinker -soname -Xlinker libgsm.so.1 $(GSM_OBJECTS) -lc
+			ln -fs libgsm.so.1.0.10 lib/libgsm.so.1
+			ln -fs libgsm.so.1.0.10 lib/libgsm.so
+
 $(LIBGSM):	$(LIB) $(GSM_OBJECTS)
 		-rm $(RMFLAGS) $(LIBGSM)
 		$(AR) $(ARFLAGS) $(LIBGSM) $(GSM_OBJECTS)
 		$(RANLIB) $(LIBGSM)
 
-
 # Toast, Untoast and Tcat -- the compress-like frontends to gsm.
 
-$(TOAST):	$(BIN) $(TOAST_OBJECTS) $(LIBGSM)
-		$(LD) $(LFLAGS) -o $(TOAST) $(TOAST_OBJECTS) $(LIBGSM) $(LDLIB)
+$(TOAST):	$(BIN) $(TOAST_OBJECTS) $(LIBGSMSO)
+		$(LD) $(LFLAGS) -o $(TOAST) $(TOAST_OBJECTS) $(LIBGSMSO) $(LDLIB)
 
 $(UNTOAST):	$(BIN) $(TOAST)
 		-rm $(RMFLAGS) $(UNTOAST)
-		$(LN) $(TOAST) $(UNTOAST)
+		$(LN) toast $(UNTOAST)
 
 $(TCAT):	$(BIN) $(TOAST)
 		-rm $(RMFLAGS) $(TCAT)
-		$(LN) $(TOAST) $(TCAT)
+		$(LN) toast $(TCAT)
 
 
 # The local bin and lib directories
@@ -331,72 +325,71 @@
 # Installation
 
 gsminstall:
-		-if [ x"$(GSM_INSTALL_ROOT)" != x ] ; then	\
-			make $(GSM_INSTALL_TARGETS) ;	\
-		fi
+		make $(GSM_INSTALL_TARGETS)
 
 toastinstall:
-		-if [ x"$(TOAST_INSTALL_ROOT)" != x ]; then	\
-			make $(TOAST_INSTALL_TARGETS);	\
-		fi
+		make $(TOAST_INSTALL_TARGETS)
 
 gsmuninstall:
-		-if [ x"$(GSM_INSTALL_ROOT)" != x ] ; then	\
-			rm $(RMFLAGS) $(GSM_INSTALL_TARGETS) ;	\
-		fi
+		rm $(RMFLAGS) $(GSM_INSTALL_TARGETS)
 
 toastuninstall:
-		-if [ x"$(TOAST_INSTALL_ROOT)" != x ] ; then 	\
-			rm $(RMFLAGS) $(TOAST_INSTALL_TARGETS);	\
-		fi
-
-$(TOAST_INSTALL_BIN)/toast:	$(TOAST)
-		-rm $@
-		cp $(TOAST) $@
-		chmod 755 $@
-
-$(TOAST_INSTALL_BIN)/untoast:	$(TOAST_INSTALL_BIN)/toast
-		-rm $@
-		ln $? $@
-
-$(TOAST_INSTALL_BIN)/tcat:	$(TOAST_INSTALL_BIN)/toast
-		-rm $@
-		ln $? $@
-
-$(TOAST_INSTALL_MAN)/toast.1:	$(MAN)/toast.1
-		-rm $@
-		cp $? $@
-		chmod 444 $@
-
-$(GSM_INSTALL_MAN)/gsm.3:	$(MAN)/gsm.3
-		-rm $@
-		cp $? $@
-		chmod 444 $@
-
-$(GSM_INSTALL_MAN)/gsm_option.3:	$(MAN)/gsm_option.3
-		-rm $@
-		cp $? $@
-		chmod 444 $@
-
-$(GSM_INSTALL_MAN)/gsm_explode.3:	$(MAN)/gsm_explode.3
-		-rm $@
-		cp $? $@
-		chmod 444 $@
-
-$(GSM_INSTALL_MAN)/gsm_print.3:	$(MAN)/gsm_print.3
-		-rm $@
-		cp $? $@
-		chmod 444 $@
-
-$(GSM_INSTALL_INC)/gsm.h:	$(INC)/gsm.h
-		-rm $@
-		cp $? $@
-		chmod 444 $@
-
-$(GSM_INSTALL_LIB)/libgsm.a:	$(LIBGSM)
-		-rm $@
-		cp $? $@
-		chmod 444 $@
+		rm $(RMFLAGS) $(TOAST_INSTALL_TARGETS)
+
+$(DESTDIR)$(bindir)/toast:	$(TOAST)
+		-rm $(RMFLAGS) $@
+		-mkdir -p $(DESTDIR)$(bindir)
+		install -m0755 $(TOAST) $@
+
+$(DESTDIR)$(bindir)/untoast:	$(DESTDIR)$(bindir)/toast
+		-rm $(RMFLAGS) $@
+		-mkdir -p $(DESTDIR)$(bindir)
+		ln -sf $(TOAST) $@
+
+$(DESTDIR)$(bindir)/tcat:	$(DESTDIR)$(bindir)/toast
+		-rm $(RMFLAGS) $@
+		-mkdir -p $(DESTDIR)$(bindir)
+		ln -sf $(TOAST) $@
+
+$(DESTDIR)$(mandir)/man1/toast.1:	$(MAN)/toast.1
+		-rm $(RMFLAGS) $@
+		-mkdir -p $(DESTDIR)$(mandir)/man1/
+		install -m0444 $? $@
+
+$(DESTDIR)$(mandir)/man3/gsm.3:	$(MAN)/gsm.3
+		-rm $(RMFLAGS) $@
+		-mkdir -p $(DESTDIR)$(mandir)/man3/
+		install -m0444 $? $@
+
+$(DESTDIR)$(mandir)/man3/gsm_option.3:	$(MAN)/gsm_option.3
+		-rm $(RMFLAGS) $@
+		-mkdir -p $(DESTDIR)$(mandir)/man3/
+		install -m0444 $? $@
+
+$(DESTDIR)$(mandir)/man3/gsm_explode.3:	$(MAN)/gsm_explode.3
+		-rm $(RMFLAGS) $@
+		-mkdir -p $(DESTDIR)$(mandir)/man3/
+		install -m0444 $? $@
+
+$(DESTDIR)$(mandir)/man3/gsm_print.3:	$(MAN)/gsm_print.3
+		-rm $(RMFLAGS) $@
+		-mkdir -p $(DESTDIR)$(mandir)/man3/
+		install -m0444 $? $@
+
+$(DESTDIR)$(includedir)/gsm/gsm.h:	$(INC)/gsm.h
+		-rm $(RMFLAGS) $@
+		-mkdir -p $(DESTDIR)$(includedir)/gsm/
+		install -m0444 $? $@
+
+$(DESTDIR)$(libdir)/libgsm.a:	$(LIBGSM)
+		-rm $(RMFLAGS) $@
+		-mkdir -p $(DESTDIR)$(libdir)
+		install -m0444 $? $@
+
+$(DESTDIR)$(libdir)/libgsm.so:	$(LIBGSMSO)
+		-rm $(RMFLAGS) $@
+		-mkdir -p $(DESTDIR)$(libdir)
+		cp -av $?* $(DESTDIR)$(libdir)/
 
 
 # Distribution
