--- Makefile.orig 2022-08-04 18:46:46 UTC +++ Makefile @@ -43,8 +43,8 @@ WAV49 = -DWAV49 # CC = /usr/lang/acc # CCFLAGS = -c -O -CC = gcc -ansi -pedantic -CCFLAGS = -c -O2 -DNeedFunctionPrototypes=1 -Wall -Wno-comment +#CC = gcc -ansi -pedantic +CCFLAGS += -c -DNeedFunctionPrototypes=1 -Wall -Wno-comment LD = $(CC) @@ -59,6 +59,7 @@ LD = $(CC) ######### Includes needed by $(CC) # LDINC = -L/usr/gnu/lib/gcc-2.1/gcc-lib/sparc-sun-sunos4.1.2/2.1 +LDINC = -L$(LIB) ######### Library paths needed by $(LD) # LDLIB = -lgcc @@ -71,7 +72,7 @@ LD = $(CC) # Leave INSTALL_ROOT empty (or just don't execute "make install") to # not install gsm and toast outside of this directory. -INSTALL_ROOT = +INSTALL_ROOT = $(DESTDIR)$(PREFIX) # Where do you want to install the gsm library, header file, and manpages? # @@ -80,8 +81,8 @@ GSM_INSTALL_LIB = $(GSM_INSTALL_ROOT)/lib 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 +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? @@ -91,7 +92,7 @@ TOAST_INSTALL_BIN = $(TOAST_INSTALL_ROOT)/bin TOAST_INSTALL_ROOT = $(INSTALL_ROOT) 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 @@ -106,7 +107,7 @@ RANLIB = ranlib COMPRESSFLAGS = # RANLIB = true RANLIB = ranlib - +RM = rm -f # # You shouldn't have to configure below this line if you're porting. # @@ -129,17 +130,19 @@ INC = $(ROOT)/inc # DEBUG = -DNDEBUG ######### Remove -DNDEBUG to enable assertions. -CFLAGS = $(CCFLAGS) $(SASR) $(DEBUG) $(MULHACK) $(FAST) $(LTP_CUT) \ +CFLAGS += $(CCFLAGS) $(SASR) $(DEBUG) $(MULHACK) $(FAST) $(LTP_CUT) \ $(WAV49) $(CCINC) -I$(INC) ######### It's $(CC) $(CFLAGS) LFLAGS = $(LDFLAGS) $(LDINC) ######### It's $(LD) $(LFLAGS) +.SUFFIXES: .c .so .o # Targets -LIBGSM = $(LIB)/libgsm.a +LIBGSM = libgsm.a +SOLIBGSM = libgsm.so.1 TOAST = $(BIN)/toast UNTOAST = $(BIN)/untoast @@ -257,7 +260,8 @@ GSM_INSTALL_TARGETS = \ # Install targets GSM_INSTALL_TARGETS = \ - $(GSM_INSTALL_LIB)/libgsm.a \ + $(GSM_INSTALL_LIB)/$(LIBGSM) \ + $(GSM_INSTALL_LIB)/$(SOLIBGSM) \ $(GSM_INSTALL_INC)/gsm.h \ $(GSM_INSTALL_MAN)/gsm.3 \ $(GSM_INSTALL_MAN)/gsm_explode.3 \ @@ -272,14 +276,16 @@ TOAST_INSTALL_TARGETS = \ # Default rules - .c.o: $(CC) $(CFLAGS) $? @-mv `$(BASENAME) $@` $@ > /dev/null 2>&1 +.c.so: + ${CC} -fpic -DPIC ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET} + # Target rules -all: $(LIBGSM) $(TOAST) $(TCAT) $(UNTOAST) +all: $(LIB)/$(LIBGSM) $(LIB)/$(SOLIBGSM) $(TOAST) $(TCAT) $(UNTOAST) @-echo $(ROOT): Done. tst: $(TST)/lin2cod $(TST)/cod2lin $(TOAST) $(TST)/test-result @@ -299,26 +305,30 @@ install: toastinstall gsminstall # The basic API: libgsm -$(LIBGSM): $(LIB) $(GSM_OBJECTS) - -rm $(RMFLAGS) $(LIBGSM) - $(AR) $(ARFLAGS) $(LIBGSM) $(GSM_OBJECTS) - $(RANLIB) $(LIBGSM) +$(LIB)/$(SOLIBGSM): $(LIB) $(GSM_OBJECTS:S/o$/so/g) + $(CC) -o $@ -shared -Wl,-soname,$(SOLIBGSM) $(GSM_OBJECTS:S/o$/so/g) + (cd $(LIB); $(LN) -sf $(SOLIBGSM) `echo $(SOLIBGSM) | sed 's/\.so.*$$/.so/'`) +$(LIB)/$(LIBGSM): $(LIB) $(GSM_OBJECTS) + $(RM) $(RMFLAGS) $(LIB)/$(LIBGSM) + $(AR) $(ARFLAGS) $(LIB)/$(LIBGSM) $(GSM_OBJECTS) + $(RANLIB) $(LIB)/$(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) $(LIB)/$(LIBGSM) + $(LD) $(LFLAGS) -o $(TOAST) $(TOAST_OBJECTS) $(LIB)/$(LIBGSM) $(LDLIB) +$(TOAST): $(BIN) $(TOAST_OBJECTS) $(LIB)/$(LIBGSM) + $(LD) $(LFLAGS) -o $(TOAST) $(TOAST_OBJECTS) -lgsm $(LDLIB) $(UNTOAST): $(BIN) $(TOAST) - -rm $(RMFLAGS) $(UNTOAST) - $(LN) $(TOAST) $(UNTOAST) + $(RM) $(RMFLAGS) $(UNTOAST) + $(LN) -sf $(TOAST) $(UNTOAST) $(TCAT): $(BIN) $(TOAST) - -rm $(RMFLAGS) $(TCAT) - $(LN) $(TOAST) $(TCAT) + $(RM) $(RMFLAGS) $(TCAT) + $(LN) -sf $(TOAST) $(TCAT) - # The local bin and lib directories $(BIN): @@ -342,62 +352,59 @@ gsmuninstall: gsmuninstall: -if [ x"$(GSM_INSTALL_ROOT)" != x ] ; then \ - rm $(RMFLAGS) $(GSM_INSTALL_TARGETS) ; \ + $(RM)$(RMFLAGS) $(GSM_INSTALL_TARGETS) ; \ fi toastuninstall: -if [ x"$(TOAST_INSTALL_ROOT)" != x ] ; then \ - rm $(RMFLAGS) $(TOAST_INSTALL_TARGETS); \ + $(RM)$(RMFLAGS) $(TOAST_INSTALL_TARGETS); \ fi $(TOAST_INSTALL_BIN)/toast: $(TOAST) - -rm $(RMFLAGS) $@ - cp $(TOAST) $@ - chmod 755 $@ + $(RM) $@ + ${BSD_INSTALL_PROGRAM} $(TOAST) $@ $(TOAST_INSTALL_BIN)/untoast: $(TOAST_INSTALL_BIN)/toast - -rm $(RMFLAGS) $@ - $(LN) $? $@ + -$(RM) $@ + $(LN) -sf toast $@ $(TOAST_INSTALL_BIN)/tcat: $(TOAST_INSTALL_BIN)/toast - -rm $(RMFLAGS) $@ - $(LN) $? $@ + $(RM) $@ + $(LN) -sf toast $@ $(TOAST_INSTALL_MAN)/toast.1: $(MAN)/toast.1 - -rm $(RMFLAGS) $@ - cp $? $@ - chmod 444 $@ + $(RM) $@ + ${BSD_INSTALL_MAN} $? $@ $(GSM_INSTALL_MAN)/gsm.3: $(MAN)/gsm.3 - -rm $(RMFLAGS) $@ - cp $? $@ - chmod 444 $@ + $(RM) $@ + ${BSD_INSTALL_MAN} $? $@ $(GSM_INSTALL_MAN)/gsm_option.3: $(MAN)/gsm_option.3 - -rm $(RMFLAGS) $@ - cp $? $@ - chmod 444 $@ + $(RM) $@ + ${BSD_INSTALL_MAN} $? $@ + $(GSM_INSTALL_MAN)/gsm_explode.3: $(MAN)/gsm_explode.3 - -rm $(RMFLAGS) $@ - cp $? $@ - chmod 444 $@ + $(RM) $@ + ${BSD_INSTALL_MAN} $? $@ $(GSM_INSTALL_MAN)/gsm_print.3: $(MAN)/gsm_print.3 - -rm $(RMFLAGS) $@ - cp $? $@ - chmod 444 $@ + $(RM) $@ + ${BSD_INSTALL_MAN} $? $@ $(GSM_INSTALL_INC)/gsm.h: $(INC)/gsm.h - -rm $(RMFLAGS) $@ - cp $? $@ - chmod 444 $@ + $(RM) $@ + ${BSD_INSTALL_DATA} $? $@ -$(GSM_INSTALL_LIB)/libgsm.a: $(LIBGSM) - -rm $(RMFLAGS) $@ - cp $? $@ - chmod 444 $@ +$(GSM_INSTALL_LIB)/$(LIBGSM): $(LIB)/$(LIBGSM) + $(RM) $@ + ${BSD_INSTALL_DATA} $? $@ +$(GSM_INSTALL_LIB)/$(SOLIBGSM): $(LIB)/$(SOLIBGSM) + $(RM) $@ + ${BSD_INSTALL_LIB} $? $@ + (cd $(GSM_INSTALL_LIB); $(LN) -sf $(SOLIBGSM) `echo $(SOLIBGSM) | sed 's/\.so.*$$/.so/'`) # Distribution @@ -473,22 +480,22 @@ $(TST)/test-result: $(TST)/lin2cod $(TST)/cod2lin $(TO $(TST)/test-result: $(TST)/lin2cod $(TST)/cod2lin $(TOAST) $(TST)/run ( cd $(TST); ./run ) -$(TST)/lin2txt: $(TST)/lin2txt.o $(LIBGSM) +$(TST)/lin2txt: $(TST)/lin2txt.o $(LIB)/$(LIBGSM) $(LD) $(LFLAGS) -o $(TST)/lin2txt \ $(TST)/lin2txt.o $(LIBGSM) $(LDLIB) -$(TST)/lin2cod: $(TST)/lin2cod.o $(LIBGSM) +$(TST)/lin2cod: $(TST)/lin2cod.o $(LIB)/$(LIBGSM) $(LD) $(LFLAGS) -o $(TST)/lin2cod \ $(TST)/lin2cod.o $(LIBGSM) $(LDLIB) -$(TST)/gsm2cod: $(TST)/gsm2cod.o $(LIBGSM) +$(TST)/gsm2cod: $(TST)/gsm2cod.o $(LIB)/$(LIBGSM) $(LD) $(LFLAGS) -o $(TST)/gsm2cod \ $(TST)/gsm2cod.o $(LIBGSM) $(LDLIB) -$(TST)/cod2txt: $(TST)/cod2txt.o $(LIBGSM) +$(TST)/cod2txt: $(TST)/cod2txt.o $(LIB)/$(LIBGSM) $(LD) $(LFLAGS) -o $(TST)/cod2txt \ $(TST)/cod2txt.o $(LIBGSM) $(LDLIB) -$(TST)/cod2lin: $(TST)/cod2lin.o $(LIBGSM) +$(TST)/cod2lin: $(TST)/cod2lin.o $(LIB)/$(LIBGSM) $(LD) $(LFLAGS) -o $(TST)/cod2lin \ $(TST)/cod2lin.o $(LIBGSM) $(LDLIB)