--- gsm-1.0-pl22/Makefile.orig 2022-08-04 20:46:46.107815841 +0200 +++ gsm-1.0-pl22/Makefile 2022-09-24 10:52:16.384400274 +0200 @@ -44,7 +44,7 @@ WAV49 = -DWAV49 # CCFLAGS = -c -O CC = gcc -ansi -pedantic -CCFLAGS = -c -O2 -DNeedFunctionPrototypes=1 -Wall -Wno-comment +CCFLAGS = $(OPTFLAGS) -DNeedFunctionPrototypes=1 -Wall -Wno-comment LD = $(CC) @@ -64,6 +64,7 @@ LD = $(CC) # LDLIB = -lgcc ######### Additional libraries needed by $(LD) +PICFLAGS = -fPIC # Where do you want to install libraries, binaries, a header file # and the manual pages? @@ -78,10 +79,10 @@ INSTALL_ROOT = # Leave GSM_INSTALL_ROOT empty to not install the GSM library outside of # this directory. -GSM_INSTALL_ROOT = $(INSTALL_ROOT) +GSM_INSTALL_ROOT = $(INSTALL_ROOT)/usr GSM_INSTALL_LIB = $(GSM_INSTALL_ROOT)/lib -GSM_INSTALL_INC = $(GSM_INSTALL_ROOT)/inc -GSM_INSTALL_MAN = $(GSM_INSTALL_ROOT)/man/man3 +GSM_INSTALL_INC = $(GSM_INSTALL_ROOT)/include +GSM_INSTALL_MAN = $(GSM_INSTALL_ROOT)/share/man/man3 # Where do you want to install the toast binaries and their manpage? @@ -89,12 +90,13 @@ GSM_INSTALL_MAN = $(GSM_INSTALL_ROOT)/ma # Leave TOAST_INSTALL_ROOT empty to not install the toast binaries outside # of this directory. -TOAST_INSTALL_ROOT = $(INSTALL_ROOT) +TOAST_INSTALL_ROOT = $(INSTALL_ROOT)/usr TOAST_INSTALL_BIN = $(TOAST_INSTALL_ROOT)/bin -TOAST_INSTALL_MAN = $(TOAST_INSTALL_ROOT)/man/man1 +TOAST_INSTALL_MAN = $(TOAST_INSTALL_ROOT)/share/man/man1 # Other tools +MV = mv SHELL = /bin/sh LN = ln BASENAME = basename @@ -140,6 +142,9 @@ LFLAGS = $(LDFLAGS) $(LDINC) # Targets LIBGSM = $(LIB)/libgsm.a +LIBGSMSO= $(LIB)/libgsm.so +SOMAJOR = .1 +SOVER = .1.0.22 TOAST = $(BIN)/toast UNTOAST = $(BIN)/untoast @@ -222,6 +227,8 @@ GSM_OBJECTS = $(SRC)/add.o \ $(SRC)/short_term.o \ $(SRC)/table.o +GSM_SHOBJECTS = $(foreach OBJX,$(GSM_OBJECTS),$(patsubst $(SRC)/%,shared/%,$(OBJX))) + TOAST_OBJECTS = $(SRC)/toast.o \ $(SRC)/toast_lin.o \ $(SRC)/toast_ulaw.o \ @@ -258,6 +265,7 @@ STUFF = ChangeLog \ GSM_INSTALL_TARGETS = \ $(GSM_INSTALL_LIB)/libgsm.a \ + $(GSM_INSTALL_LIB)/libgsm.so$(SOVER) \ $(GSM_INSTALL_INC)/gsm.h \ $(GSM_INSTALL_MAN)/gsm.3 \ $(GSM_INSTALL_MAN)/gsm_explode.3 \ @@ -274,12 +282,11 @@ TOAST_INSTALL_TARGETS = \ # Default rules .c.o: - $(CC) $(CFLAGS) $? - @-mv `$(BASENAME) $@` $@ > /dev/null 2>&1 + $(CC) -c $(CFLAGS) $? -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 @@ -298,34 +305,39 @@ install: toastinstall gsminstall # The basic API: libgsm - -$(LIBGSM): $(LIB) $(GSM_OBJECTS) - -rm $(RMFLAGS) $(LIBGSM) +$(LIBGSM): lib.stamp $(GSM_OBJECTS) $(AR) $(ARFLAGS) $(LIBGSM) $(GSM_OBJECTS) $(RANLIB) $(LIBGSM) +shared.stamp: + mkdir -p shared && touch shared.stamp + +shared/%.o: $(SRC)/%.c shared.stamp + $(CC) -c $(CFLAGS) $(PICFLAGS) -o $@ $(addprefix $(SRC)/,$(patsubst %.o,%.c,$(@F))) + +$(LIBGSMSO): lib.stamp $(GSM_SHOBJECTS) + $(CC) -o $(LIB)/libgsm.so$(SOVER) -shared -Wl,-soname=libgsm.so$(SOMAJOR) $(GSM_SHOBJECTS) + # Toast, Untoast and Tcat -- the compress-like frontends to gsm. -$(TOAST): $(BIN) $(TOAST_OBJECTS) $(LIBGSM) +$(TOAST): bin.stamp $(TOAST_OBJECTS) $(LIBGSM) $(LD) $(LFLAGS) -o $(TOAST) $(TOAST_OBJECTS) $(LIBGSM) $(LDLIB) -$(UNTOAST): $(BIN) $(TOAST) - -rm $(RMFLAGS) $(UNTOAST) +$(UNTOAST): bin.stamp $(TOAST) $(LN) $(TOAST) $(UNTOAST) -$(TCAT): $(BIN) $(TOAST) - -rm $(RMFLAGS) $(TCAT) +$(TCAT): bin.stamp $(TOAST) $(LN) $(TOAST) $(TCAT) # The local bin and lib directories -$(BIN): - if [ ! -d $(BIN) ] ; then mkdir $(BIN) ; fi +bin.stamp: + if [ ! -d $(BIN) ] ; then mkdir $(BIN) ; fi && touch bin.stamp -$(LIB): - if [ ! -d $(LIB) ] ; then mkdir $(LIB) ; fi +lib.stamp: + if [ ! -d $(LIB) ] ; then mkdir $(LIB) ; fi && touch lib.stamp # Installation @@ -351,53 +363,47 @@ toastuninstall: fi $(TOAST_INSTALL_BIN)/toast: $(TOAST) - -rm $(RMFLAGS) $@ cp $(TOAST) $@ chmod 755 $@ $(TOAST_INSTALL_BIN)/untoast: $(TOAST_INSTALL_BIN)/toast - -rm $(RMFLAGS) $@ - $(LN) $? $@ + $(LN) -sf toast $@ $(TOAST_INSTALL_BIN)/tcat: $(TOAST_INSTALL_BIN)/toast - -rm $(RMFLAGS) $@ - $(LN) $? $@ + $(LN) -sf toast $@ $(TOAST_INSTALL_MAN)/toast.1: $(MAN)/toast.1 - -rm $(RMFLAGS) $@ cp $? $@ chmod 444 $@ $(GSM_INSTALL_MAN)/gsm.3: $(MAN)/gsm.3 - -rm $(RMFLAGS) $@ cp $? $@ chmod 444 $@ $(GSM_INSTALL_MAN)/gsm_option.3: $(MAN)/gsm_option.3 - -rm $(RMFLAGS) $@ cp $? $@ chmod 444 $@ $(GSM_INSTALL_MAN)/gsm_explode.3: $(MAN)/gsm_explode.3 - -rm $(RMFLAGS) $@ cp $? $@ chmod 444 $@ $(GSM_INSTALL_MAN)/gsm_print.3: $(MAN)/gsm_print.3 - -rm $(RMFLAGS) $@ cp $? $@ chmod 444 $@ $(GSM_INSTALL_INC)/gsm.h: $(INC)/gsm.h - -rm $(RMFLAGS) $@ cp $? $@ chmod 444 $@ $(GSM_INSTALL_LIB)/libgsm.a: $(LIBGSM) - -rm $(RMFLAGS) $@ cp $? $@ chmod 444 $@ - + +$(GSM_INSTALL_LIB)/libgsm.so$(SOVER): $(LIBGSMSO)$(SOVER) + install -m755 $? $@ + ln -sf libgsm.so$(SOVER) $(GSM_INSTALL_LIB)/libgsm.so$(SOMAJOR) + ln -sf libgsm.so$(SOVER) $(GSM_INSTALL_LIB)/libgsm.so # Distribution