void-packages/srcpkgs/libgsm/patches/gsm-1.0.13-shared.patch

190 lines
4.5 KiB
Diff

--- a/Makefile
+++ b/Makefile
@@ -44,10 +44,11 @@ WAV49 = -DWAV49
# CCFLAGS = -c -O
CC = gcc -ansi -pedantic
-CCFLAGS = -c -O2 -DNeedFunctionPrototypes=1 -Wall -Wno-comment
+CCFLAGS = -O2 -DNeedFunctionPrototypes=1 -Wall -Wno-comment
LD = $(CC)
+VERSION = 1.0.13
# LD = gcc
# LDFLAGS =
@@ -96,7 +97,7 @@ TOAST_INSTALL_MAN = $(TOAST_INSTALL_ROOT
# Other tools
SHELL = /bin/sh
-LN = ln
+LN = ln -s
BASENAME = basename
AR = ar
ARFLAGS = cr
@@ -133,13 +134,14 @@ CFLAGS = $(CCFLAGS) $(SASR) $(DEBUG) $(M
$(WAV49) $(CCINC) -I$(INC)
######### It's $(CC) $(CFLAGS)
-LFLAGS = $(LDFLAGS) $(LDINC)
+LFLAGS = $(CFLAGS) $(LDFLAGS) $(LDINC)
######### It's $(LD) $(LFLAGS)
# Targets
LIBGSM = $(LIB)/libgsm.a
+LIBGSMSO= $(LIB)/libgsm.so
TOAST = $(BIN)/toast
UNTOAST = $(BIN)/untoast
@@ -203,24 +205,43 @@ SOURCES = $(GSM_SOURCES) \
# Object files
-GSM_OBJECTS = $(SRC)/add.o \
- $(SRC)/code.o \
- $(SRC)/debug.o \
- $(SRC)/decode.o \
- $(SRC)/long_term.o \
- $(SRC)/lpc.o \
- $(SRC)/preprocess.o \
- $(SRC)/rpe.o \
- $(SRC)/gsm_destroy.o \
- $(SRC)/gsm_decode.o \
- $(SRC)/gsm_encode.o \
- $(SRC)/gsm_explode.o \
- $(SRC)/gsm_implode.o \
- $(SRC)/gsm_create.o \
- $(SRC)/gsm_print.o \
- $(SRC)/gsm_option.o \
- $(SRC)/short_term.o \
- $(SRC)/table.o
+STATIC_GSM_OBJECTS = $(SRC)/add.o \
+ $(SRC)/code.o \
+ $(SRC)/debug.o \
+ $(SRC)/decode.o \
+ $(SRC)/long_term.o \
+ $(SRC)/lpc.o \
+ $(SRC)/preprocess.o \
+ $(SRC)/rpe.o \
+ $(SRC)/gsm_destroy.o \
+ $(SRC)/gsm_decode.o \
+ $(SRC)/gsm_encode.o \
+ $(SRC)/gsm_explode.o \
+ $(SRC)/gsm_implode.o \
+ $(SRC)/gsm_create.o \
+ $(SRC)/gsm_print.o \
+ $(SRC)/gsm_option.o \
+ $(SRC)/short_term.o \
+ $(SRC)/table.o
+
+SHARED_GSM_OBJECTS = $(SRC)/add.lo \
+ $(SRC)/code.lo \
+ $(SRC)/debug.lo \
+ $(SRC)/decode.lo \
+ $(SRC)/long_term.lo \
+ $(SRC)/lpc.lo \
+ $(SRC)/preprocess.lo \
+ $(SRC)/rpe.lo \
+ $(SRC)/gsm_destroy.lo \
+ $(SRC)/gsm_decode.lo \
+ $(SRC)/gsm_encode.lo \
+ $(SRC)/gsm_explode.lo \
+ $(SRC)/gsm_implode.lo \
+ $(SRC)/gsm_create.lo \
+ $(SRC)/gsm_print.lo \
+ $(SRC)/gsm_option.lo \
+ $(SRC)/short_term.lo \
+ $(SRC)/table.lo
TOAST_OBJECTS = $(SRC)/toast.o \
$(SRC)/toast_lin.o \
@@ -228,7 +249,7 @@ TOAST_OBJECTS = $(SRC)/toast.o \
$(SRC)/toast_alaw.o \
$(SRC)/toast_audio.o
-OBJECTS = $(GSM_OBJECTS) $(TOAST_OBJECTS)
+OBJECTS = $(STATIC_GSM_OBJECTS) $(SHARED_GSM_OBJECTS) $(TOAST_OBJECTS)
# Manuals
@@ -274,12 +295,15 @@ TOAST_INSTALL_TARGETS = \
# Default rules
.c.o:
- $(CC) $(CFLAGS) $?
+ $(CC) -c $(CFLAGS) $?
@-mv `$(BASENAME) $@` $@ > /dev/null 2>&1
+%.lo: %.c
+ $(CC) $(CFLAGS) -fPIC -c $< -o $@
+
# 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 +323,29 @@ install: toastinstall gsminstall
# The basic API: libgsm
-$(LIBGSM): $(LIB) $(GSM_OBJECTS)
+$(LIBGSMSO): $(LIB) $(SHARED_GSM_OBJECTS)
+ $(LD) $(LFLAGS) -o $@.$(VERSION) -shared -Xlinker -soname -Xlinker libgsm.so.1 $(SHARED_GSM_OBJECTS) -lc
+ ln -fs libgsm.so.$(VERSION) lib/libgsm.so.1
+ ln -fs libgsm.so.$(VERSION) lib/libgsm.so
+
+$(LIBGSM): $(LIB) $(STATIC_GSM_OBJECTS)
-rm $(RMFLAGS) $(LIBGSM)
- $(AR) $(ARFLAGS) $(LIBGSM) $(GSM_OBJECTS)
+ $(AR) $(ARFLAGS) $(LIBGSM) $(STATIC_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)
+ $(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
@@ -357,11 +386,11 @@ $(TOAST_INSTALL_BIN)/toast: $(TOAST)
$(TOAST_INSTALL_BIN)/untoast: $(TOAST_INSTALL_BIN)/toast
-rm $(RMFLAGS) $@
- $(LN) $? $@
+ $(LN) -r $? $@
$(TOAST_INSTALL_BIN)/tcat: $(TOAST_INSTALL_BIN)/toast
-rm $(RMFLAGS) $@
- $(LN) $? $@
+ $(LN) -r $? $@
$(TOAST_INSTALL_MAN)/toast.1: $(MAN)/toast.1
-rm $(RMFLAGS) $@
@@ -426,7 +455,9 @@ semi-clean:
clean: semi-clean
-rm $(RMFLAGS) $(LIBGSM) $(ADDTST)/add \
- $(TOAST) $(TCAT) $(UNTOAST) \
+ $(LIBGSMSO) $(LIB)/libgsm.so.$(VERSION) \
+ $(LIB)libgsm.so.1 \
+ $(TOAST) $(TCAT) $(UNTOAST) \
$(ROOT)/gsm-1.0.tar.gz