3 @@ -8,10 +8,12 @@ SASR = -DSASR
4 ######### Define SASR if >> is a signed arithmetic shift (-1 >> 1 == -1)
6 # MULHACK = -DUSE_FLOAT_MUL
8 ######### Define this if your host multiplies floats faster than integers,
9 ######### e.g. on a SPARCstation.
13 ######### Define together with USE_FLOAT_MUL to enable the GSM library's
14 ######### approximation option for incorrect, but good-enough results.
16 @@ -22,8 +24,8 @@ LTP_CUT =
17 ######### both integer and floating point multiplications.
18 ######### This flag is still in the experimental stage.
24 ######### Define to enable the GSM library's option to pack GSM frames
25 ######### in the style used by the WAV #49 format. If you want to write
26 ######### a tool that produces .WAV files which contain GSM-encoded data,
27 @@ -44,7 +46,8 @@ WAV49 = -DWAV49
30 CC = gcc -ansi -pedantic
31 -CCFLAGS = -c -O2 -DNeedFunctionPrototypes=1
33 +CCFLAGS = -c $(COPTS) -DNeedFunctionPrototypes=1
37 @@ -78,10 +81,10 @@ INSTALL_ROOT =
38 # Leave GSM_INSTALL_ROOT empty to not install the GSM library outside of
41 -GSM_INSTALL_ROOT = $(INSTALL_ROOT)
42 +GSM_INSTALL_ROOT = $(INSTALL_ROOT)/usr
43 GSM_INSTALL_LIB = $(GSM_INSTALL_ROOT)/lib
44 -GSM_INSTALL_INC = $(GSM_INSTALL_ROOT)/inc
45 -GSM_INSTALL_MAN = $(GSM_INSTALL_ROOT)/man/man3
46 +GSM_INSTALL_INC = $(GSM_INSTALL_ROOT)/include
47 +GSM_INSTALL_MAN = $(GSM_INSTALL_ROOT)/share/man/man3
50 # Where do you want to install the toast binaries and their manpage?
51 @@ -89,14 +92,14 @@ GSM_INSTALL_MAN = $(GSM_INSTALL_ROOT)/ma
52 # Leave TOAST_INSTALL_ROOT empty to not install the toast binaries outside
55 -TOAST_INSTALL_ROOT = $(INSTALL_ROOT)
56 +TOAST_INSTALL_ROOT = $(INSTALL_ROOT)/usr
57 TOAST_INSTALL_BIN = $(TOAST_INSTALL_ROOT)/bin
58 -TOAST_INSTALL_MAN = $(TOAST_INSTALL_ROOT)/man/man1
59 +TOAST_INSTALL_MAN = $(TOAST_INSTALL_ROOT)/share/man/man1
69 @@ -126,7 +129,7 @@ INC = $(ROOT)/inc
75 ######### Remove -DNDEBUG to enable assertions.
77 CFLAGS = $(CCFLAGS) $(SASR) $(DEBUG) $(MULHACK) $(FAST) $(LTP_CUT) \
78 @@ -140,6 +143,7 @@ LFLAGS = $(LDFLAGS) $(LDINC)
81 LIBGSM = $(LIB)/libgsm.a
82 +LIBGSMSO= $(LIB)/libgsm.so
85 UNTOAST = $(BIN)/untoast
86 @@ -258,6 +262,9 @@ STUFF = ChangeLog \
88 GSM_INSTALL_TARGETS = \
89 $(GSM_INSTALL_LIB)/libgsm.a \
90 + $(GSM_INSTALL_LIB)/libgsm.so \
91 + $(GSM_INSTALL_LIB)/libgsm.so.1 \
92 + $(GSM_INSTALL_LIB)/libgsm.so.1.0.10 \
93 $(GSM_INSTALL_INC)/gsm.h \
94 $(GSM_INSTALL_MAN)/gsm.3 \
95 $(GSM_INSTALL_MAN)/gsm_explode.3 \
96 @@ -279,7 +286,7 @@ TOAST_INSTALL_TARGETS = \
100 -all: $(LIBGSM) $(TOAST) $(TCAT) $(UNTOAST)
101 +all: $(LIBGSM) $(LIBGSMSO) $(TOAST) $(TCAT) $(UNTOAST)
102 @-echo $(ROOT): Done.
104 tst: $(TST)/lin2cod $(TST)/cod2lin $(TOAST) $(TST)/test-result
105 @@ -299,6 +306,11 @@ install: toastinstall gsminstall
107 # The basic API: libgsm
109 +$(LIBGSMSO): $(LIB) $(GSM_OBJECTS)
110 + $(LD) -o $@.1.0.10 -shared -Xlinker -soname -Xlinker libgsm.so.1 $(GSM_OBJECTS) -lc
111 + ln -fs libgsm.so.1.0.10 lib/libgsm.so.1
112 + ln -fs libgsm.so.1.0.10 lib/libgsm.so
114 $(LIBGSM): $(LIB) $(GSM_OBJECTS)
115 -rm $(RMFLAGS) $(LIBGSM)
116 $(AR) $(ARFLAGS) $(LIBGSM) $(GSM_OBJECTS)
117 @@ -308,15 +320,15 @@ $(LIBGSM): $(LIB) $(GSM_OBJECTS)
118 # Toast, Untoast and Tcat -- the compress-like frontends to gsm.
120 $(TOAST): $(BIN) $(TOAST_OBJECTS) $(LIBGSM)
121 - $(LD) $(LFLAGS) -o $(TOAST) $(TOAST_OBJECTS) $(LIBGSM) $(LDLIB)
122 + $(LD) $(LFLAGS) -o $(TOAST) $(TOAST_OBJECTS) $(LIBGSMSO) $(LDLIB)
124 $(UNTOAST): $(BIN) $(TOAST)
125 -rm $(RMFLAGS) $(UNTOAST)
126 - $(LN) $(TOAST) $(UNTOAST)
127 + $(LN) toast $(UNTOAST)
129 $(TCAT): $(BIN) $(TOAST)
130 -rm $(RMFLAGS) $(TCAT)
131 - $(LN) $(TOAST) $(TCAT)
132 + $(LN) toast $(TCAT)
135 # The local bin and lib directories
136 @@ -351,53 +363,66 @@ toastuninstall:
139 $(TOAST_INSTALL_BIN)/toast: $(TOAST)
142 + mkdir -p $(TOAST_INSTALL_BIN)
146 $(TOAST_INSTALL_BIN)/untoast: $(TOAST_INSTALL_BIN)/toast
149 + mkdir -p $(TOAST_INSTALL_BIN)
152 $(TOAST_INSTALL_BIN)/tcat: $(TOAST_INSTALL_BIN)/toast
155 + mkdir -p $(TOAST_INSTALL_BIN)
158 $(TOAST_INSTALL_MAN)/toast.1: $(MAN)/toast.1
161 + mkdir -p $(TOAST_INSTALL_MAN)
165 $(GSM_INSTALL_MAN)/gsm.3: $(MAN)/gsm.3
168 + mkdir -p $(GSM_INSTALL_MAN)
172 $(GSM_INSTALL_MAN)/gsm_option.3: $(MAN)/gsm_option.3
175 + mkdir -p $(GSM_INSTALL_MAN)
179 $(GSM_INSTALL_MAN)/gsm_explode.3: $(MAN)/gsm_explode.3
182 + mkdir -p $(GSM_INSTALL_MAN)
186 $(GSM_INSTALL_MAN)/gsm_print.3: $(MAN)/gsm_print.3
189 + mkdir -p $(GSM_INSTALL_MAN)
193 $(GSM_INSTALL_INC)/gsm.h: $(INC)/gsm.h
196 + mkdir -p $(GSM_INSTALL_INC)
200 $(GSM_INSTALL_LIB)/libgsm.a: $(LIBGSM)
203 + mkdir -p $(GSM_INSTALL_LIB)
207 +$(GSM_INSTALL_LIB)/libgsm.so: $(LIBGSMSO)
208 + mkdir -p $(GSM_INSTALL_LIB)
211 +$(GSM_INSTALL_LIB)/libgsm.so.1: $(LIBGSMSO)
212 + mkdir -p $(GSM_INSTALL_LIB)
215 +$(GSM_INSTALL_LIB)/libgsm.so.1.0.10: $(LIBGSMSO)
216 + mkdir -p $(GSM_INSTALL_LIB)
223 @@ -426,7 +451,9 @@ semi-clean:
226 -rm $(RMFLAGS) $(LIBGSM) $(ADDTST)/add \
227 - $(TOAST) $(TCAT) $(UNTOAST) \
228 + $(LIBGSMSO) $(LIB)/libgsm.so.1.0.10 \
229 + $(LIB)libgsm.so.1 \
230 + $(TOAST) $(TCAT) $(UNTOAST) \
231 $(ROOT)/gsm-1.0.tar.Z
240 -/*efine SIGHANDLER_T int /* signal handlers are void */
241 -/*efine HAS_SYSV_SIGNAL 1 /* sigs not blocked/reset? */
242 +/*efine SIGHANDLER_T int *//* signal handlers are void */
243 +/*efine HAS_SYSV_SIGNAL 1 *//* sigs not blocked/reset? */
245 #define HAS_STDLIB_H 1 /* /usr/include/stdlib.h */
246 #define HAS_LIMITS_H 1 /* /usr/include/limits.h */
248 #define HAS_CHMOD 1 /* chmod syscall */
249 #define HAS_FCHOWN 1 /* fchown syscall */
250 #define HAS_CHOWN 1 /* chown syscall */
251 -/*efine HAS__FSETMODE 1 /* _fsetmode -- set file mode */
252 +/*efine HAS__FSETMODE 1 *//* _fsetmode -- set file mode */
254 #define HAS_STRING_H 1 /* /usr/include/string.h */
255 -/*efine HAS_STRINGS_H 1 /* /usr/include/strings.h */
256 +/*efine HAS_STRINGS_H 1 *//* /usr/include/strings.h */
258 #define HAS_UNISTD_H 1 /* /usr/include/unistd.h */
259 #define HAS_UTIME 1 /* POSIX utime(path, times) */
260 -/*efine HAS_UTIMES 1 /* use utimes() syscall instead */
261 +/*efine HAS_UTIMES 1 *//* use utimes() syscall instead */
262 #define HAS_UTIME_H 1 /* UTIME header file */
263 #define HAS_UTIMBUF 1 /* struct utimbuf */
264 -/*efine HAS_UTIMEUSEC 1 /* microseconds in utimbuf? */
265 +/*efine HAS_UTIMEUSEC 1 *//* microseconds in utimbuf? */
267 #endif /* CONFIG_H */
270 @@ -54,6 +54,10 @@ typedef gsm_byte gsm_frame[33]; /* 33
271 #define GSM_OPT_FRAME_INDEX 5
272 #define GSM_OPT_FRAME_CHAIN 6
278 extern gsm gsm_create GSM_P((void));
279 extern void gsm_destroy GSM_P((gsm));
281 @@ -66,6 +70,10 @@ extern int gsm_decode GSM_P((gsm, gsm_
282 extern int gsm_explode GSM_P((gsm, gsm_byte *, gsm_signal *));
283 extern void gsm_implode GSM_P((gsm, gsm_signal *, gsm_byte *));
298 +#include <pthread.h>
302 -#ifndef HAS_ERRNO_DECL
332 extern char * memcpy P((char *, char *, int));
335 @@ -49,7 +49,7 @@ void gsm_debug_longwords P4( (name, from
336 fprintf( stderr, "%s [%d .. %d]: ", name, from, to );
339 - fprintf(stderr, "%d ", ptr[ from ] );
340 + fprintf(stderr, "%ld ", ptr[ from ] );
342 if (nprinted++ >= 7) {
344 @@ -63,14 +63,14 @@ void gsm_debug_longword P2( (name, valu
348 - fprintf(stderr, "%s: %d\n", name, (long)value );
349 + fprintf(stderr, "%s: %ld\n", name, (long)value );
352 void gsm_debug_word P2( (name, value),
356 - fprintf(stderr, "%s: %d\n", name, (long)value);
357 + fprintf(stderr, "%s: %ld\n", name, (long)value);
363 @@ -251,8 +251,8 @@ static char * emalloc P1((len), size_t l
366 if (!(s = malloc(len))) {
367 - fprintf(stderr, "%s: failed to malloc %d bytes -- abort\n",
369 + fprintf(stderr, "%s: failed to malloc %ld bytes -- abort\n",
370 + progname, (long) len);
374 @@ -270,7 +270,7 @@ static char* normalname P3((name, want,
375 maxlen = strlen(name) + 1 + strlen(want) + strlen(cut);
376 p = strcpy(emalloc(maxlen), name);
378 - if (s = suffix(p, cut)) strcpy(s, want);
379 + if ((s = suffix(p, cut))) strcpy(s, want);
380 else if (*want && !suffix(p, want)) strcat(p, want);
383 @@ -386,7 +386,7 @@ static void update_times P0()
384 ut[0] = instat.st_atime;
385 ut[1] = instat.st_mtime;
387 - (void) utime(outname, ut);
388 + (void) utime(outname, (struct utimbuf *)ut);
392 @@ -416,7 +416,7 @@ static int okay_as_input P3((name,f,st),
394 if (st->st_nlink > 1 && !f_cat && !f_precious) {
396 - "%s: \"%s\" has %s other link%s -- unchanged.\n",
397 + "%s: \"%s\" has %d other link%s -- unchanged.\n",
398 progname,name,st->st_nlink - 1,"s" + (st->st_nlink<=2));
401 @@ -585,8 +585,8 @@ static int process_decode P0()
403 if (cc != sizeof(s)) {
404 if (cc >= 0) fprintf(stderr,
405 - "%s: incomplete frame (%d byte%s missing) from %s\n",
406 - progname, sizeof(s) - cc,
407 + "%s: incomplete frame (%ld byte%s missing) from %s\n",
408 + progname, (long) sizeof(s) - cc,
409 "s" + (sizeof(s) - cc == 1),
410 inname ? inname : "stdin" );
412 @@ -624,8 +624,6 @@ static int process_decode P0()
414 static int process P1((name), char * name)
421 @@ -779,7 +777,6 @@ int main P2((ac, av), int ac, char **av)
422 case 'h': help(); exit(0);
427 "Usage: %s [-fcpdhvuaslFC] [files...] (-h for help)\n",