1 # Copyright 1992-1996 by Jutta Degener and Carsten Bormann, Technische
2 # Universitaet Berlin. See the accompanying file "COPYRIGHT" for
3 # details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
5 # Machine- or installation dependent flags you should configure to port
8 ######### Define SASR if >> is a signed arithmetic shift (-1 >> 1 == -1)
10 #MULHACK = -DUSE_FLOAT_MUL
11 ######### Define this if your host multiplies floats faster than integers,
12 ######### e.g. on a SPARCstation.
15 ######### Define together with USE_FLOAT_MUL to enable the GSM library's
16 ######### approximation option for incorrect, but good-enough results.
20 ######### Define to enable the GSM library's long-term correlation
21 ######### approximation option---faster, but worse; works for
22 ######### both integer and floating point multiplications.
23 ######### This flag is still in the experimental stage.
27 ######### Define to enable the GSM library's option to pack GSM frames
28 ######### in the style used by the WAV #49 format. If you want to write
29 ######### a tool that produces .WAV files which contain GSM-encoded data,
30 ######### define this, and read about the GSM_OPT_WAV49 option in the
31 ######### manual page on gsm_option(3).
35 ######### Define to enable MMXTM optimizations for x86 architecture CPU's
36 ######### which support MMX instructions. This should be newer pentiums,
37 ######### ppro's, etc, as well as the AMD K6 and K7. The compile will
38 ######### probably require gcc.
40 ifneq (${OSARCH},Darwin)
41 OPTIMIZE+=-march=$(PROC)
46 ######### Profiling flags. If you don't know what that means, leave it blank.
48 # Choose a compiler. The code works both with ANSI and K&R-C.
49 # Use -DNeedFunctionPrototypes to compile with, -UNeedFunctionPrototypes to
50 # compile without, function prototypes in the header files.
52 # You can use the -DSTUPID_COMPILER to circumvent some compilers'
53 # static limits regarding the number of subexpressions in a statement.
56 # CCFLAGS = -c -DSTUPID_COMPILER
61 CC = gcc $(OPTIMIZE) -fomit-frame-pointer
62 CCFLAGS += -c -DNeedFunctionPrototypes=1 -funroll-loops -fPIC
70 # If your compiler needs additional flags/libraries, regardless of
71 # the source compiled, configure them here.
73 # CCINC = -I/usr/gnu/lib/gcc-2.1/gcc-lib/sparc-sun-sunos4.1.2/2.1/include
74 ######### Includes needed by $(CC)
76 # LDINC = -L/usr/gnu/lib/gcc-2.1/gcc-lib/sparc-sun-sunos4.1.2/2.1
77 ######### Library paths needed by $(LD)
80 ######### Additional libraries needed by $(LD)
83 # Where do you want to install libraries, binaries, a header file
84 # and the manual pages?
86 # Leave INSTALL_ROOT empty (or just don't execute "make install") to
87 # not install gsm and toast outside of this directory.
91 # Where do you want to install the gsm library, header file, and manpages?
93 # Leave GSM_INSTALL_ROOT empty to not install the GSM library outside of
96 GSM_INSTALL_ROOT = $(INSTALL_ROOT)
97 GSM_INSTALL_LIB = $(GSM_INSTALL_ROOT)/lib
98 GSM_INSTALL_INC = $(GSM_INSTALL_ROOT)/inc
99 GSM_INSTALL_MAN = $(GSM_INSTALL_ROOT)/man/man3
102 # Where do you want to install the toast binaries and their manpage?
104 # Leave TOAST_INSTALL_ROOT empty to not install the toast binaries outside
107 TOAST_INSTALL_ROOT = $(INSTALL_ROOT)
108 TOAST_INSTALL_BIN = $(TOAST_INSTALL_ROOT)/bin
109 TOAST_INSTALL_MAN = $(TOAST_INSTALL_ROOT)/man/man1
126 # You shouldn't have to configure below this line if you're porting.
133 ADDTST = $(ROOT)/add-test
145 ######### Remove -DNDEBUG to enable assertions.
147 CFLAGS = $(PG) $(CCFLAGS) $(SASR) $(DEBUG) $(MULHACK) $(FAST) \
148 $(LTP_CUT) $(WAV49) $(K6OPT) $(CCINC) -I$(INC)
149 ######### It's $(CC) $(CFLAGS)
151 LFLAGS = $(PG) $(LDFLAGS) $(LDINC)
152 ######### It's $(LD) $(LFLAGS)
157 LIBGSM = $(LIB)/libgsm.a
158 LIBGSMSO= $(LIB)/libgsm.so
161 UNTOAST = $(BIN)/untoast
166 GSM_HEADERS = $(INC)/gsm.h
168 HEADERS = $(INC)/proto.h \
178 GSM_SOURCES = $(SRC)/add.c \
184 $(SRC)/preprocess.c \
186 $(SRC)/gsm_destroy.c \
187 $(SRC)/gsm_decode.c \
188 $(SRC)/gsm_encode.c \
189 $(SRC)/gsm_explode.c \
190 $(SRC)/gsm_implode.c \
191 $(SRC)/gsm_create.c \
193 $(SRC)/gsm_option.c \
194 $(SRC)/short_term.c \
196 ifeq (${OSARCH},Linux)
197 GSM_SOURCES+= $(SRC)/k6opt.s
200 TOAST_SOURCES = $(SRC)/toast.c \
202 $(SRC)/toast_ulaw.c \
203 $(SRC)/toast_alaw.c \
206 SOURCES = $(GSM_SOURCES) \
208 $(ADDTST)/add_test.c \
225 GSM_OBJECTS = $(SRC)/add.o \
231 $(SRC)/preprocess.o \
233 $(SRC)/gsm_destroy.o \
234 $(SRC)/gsm_decode.o \
235 $(SRC)/gsm_encode.o \
236 $(SRC)/gsm_explode.o \
237 $(SRC)/gsm_implode.o \
238 $(SRC)/gsm_create.o \
240 $(SRC)/gsm_option.o \
241 $(SRC)/short_term.o \
243 ifeq (${OSARCH},Linux)
244 GSM_OBJECTS+= $(SRC)/k6opt.o
247 TOAST_OBJECTS = $(SRC)/toast.o \
249 $(SRC)/toast_ulaw.o \
250 $(SRC)/toast_alaw.o \
253 OBJECTS = $(GSM_OBJECTS) $(TOAST_OBJECTS)
257 GSM_MANUALS = $(MAN)/gsm.3 \
258 $(MAN)/gsm_explode.3 \
259 $(MAN)/gsm_option.3 \
262 TOAST_MANUALS = $(MAN)/toast.1
264 MANUALS = $(GSM_MANUALS) $(TOAST_MANUALS) $(MAN)/bitter.1
266 # Other stuff in the distribution
274 $(ADDTST)/add_test.dta \
281 GSM_INSTALL_TARGETS = \
282 $(GSM_INSTALL_LIB)/libgsm.a \
283 $(GSM_INSTALL_INC)/gsm.h \
284 $(GSM_INSTALL_MAN)/gsm.3 \
285 $(GSM_INSTALL_MAN)/gsm_explode.3 \
286 $(GSM_INSTALL_MAN)/gsm_option.3 \
287 $(GSM_INSTALL_MAN)/gsm_print.3
289 TOAST_INSTALL_TARGETS = \
290 $(TOAST_INSTALL_BIN)/toast \
291 $(TOAST_INSTALL_BIN)/tcat \
292 $(TOAST_INSTALL_BIN)/untoast \
293 $(TOAST_INSTALL_MAN)/toast.1
300 @-mv `$(BASENAME) $@` $@ > /dev/null 2>&1
304 all: $(LIBGSM) $(LIBGSMSO) $(TOAST) $(TCAT) $(UNTOAST)
305 @-echo $(ROOT): Done.
307 tst: $(TST)/lin2cod $(TST)/cod2lin $(TOAST) $(TST)/test-result
310 addtst: $(ADDTST)/add $(ADDTST)/add_test.dta
311 $(ADDTST)/add < $(ADDTST)/add_test.dta > /dev/null
314 misc: $(TLS)/sweet $(TLS)/bitter $(TLS)/sour $(TLS)/ginger \
315 $(TST)/lin2txt $(TST)/cod2txt $(TST)/gsm2cod
318 install: toastinstall gsminstall
319 @-echo install: Done.
322 # The basic API: libgsm
324 $(LIBGSMSO): $(LIB) $(GSM_OBJECTS)
325 $(LD) -o $@.1.0.10 -shared -Xlinker -soname -Xlinker libgsm.so.1 $(GSM_OBJECTS) -lc
326 ln -fs libgsm.so.1.0.10 lib/libgsm.so.1
327 ln -fs libgsm.so.1.0.10 lib/libgsm.so
329 $(LIBGSM): $(LIB) $(GSM_OBJECTS)
330 -rm $(RMFLAGS) $(LIBGSM)
331 $(AR) $(ARFLAGS) $(LIBGSM) $(GSM_OBJECTS)
335 # Toast, Untoast and Tcat -- the compress-like frontends to gsm.
337 $(TOAST): $(BIN) $(TOAST_OBJECTS) $(LIBGSM)
338 $(LD) $(LFLAGS) -o $(TOAST) $(TOAST_OBJECTS) $(LIBGSMSO) $(LDLIB)
340 $(UNTOAST): $(BIN) $(TOAST)
341 -rm $(RMFLAGS) $(UNTOAST)
342 $(LN) toast $(UNTOAST)
344 $(TCAT): $(BIN) $(TOAST)
345 -rm $(RMFLAGS) $(TCAT)
349 # The local bin and lib directories
352 if [ ! -d $(BIN) ] ; then mkdir $(BIN) ; fi
355 if [ ! -d $(LIB) ] ; then mkdir $(LIB) ; fi
361 -if [ x"$(GSM_INSTALL_ROOT)" != x ] ; then \
362 $(MAKE) $(GSM_INSTALL_TARGETS) ; \
366 -if [ x"$(TOAST_INSTALL_ROOT)" != x ]; then \
367 $(MAKE) $(TOAST_INSTALL_TARGETS); \
371 -if [ x"$(GSM_INSTALL_ROOT)" != x ] ; then \
372 rm $(RMFLAGS) $(GSM_INSTALL_TARGETS) ; \
376 -if [ x"$(TOAST_INSTALL_ROOT)" != x ] ; then \
377 rm $(RMFLAGS) $(TOAST_INSTALL_TARGETS); \
380 $(TOAST_INSTALL_BIN)/toast: $(TOAST)
385 $(TOAST_INSTALL_BIN)/untoast: $(TOAST_INSTALL_BIN)/toast
389 $(TOAST_INSTALL_BIN)/tcat: $(TOAST_INSTALL_BIN)/toast
393 $(TOAST_INSTALL_MAN)/toast.1: $(MAN)/toast.1
398 $(GSM_INSTALL_MAN)/gsm.3: $(MAN)/gsm.3
403 $(GSM_INSTALL_MAN)/gsm_option.3: $(MAN)/gsm_option.3
408 $(GSM_INSTALL_MAN)/gsm_explode.3: $(MAN)/gsm_explode.3
413 $(GSM_INSTALL_MAN)/gsm_print.3: $(MAN)/gsm_print.3
418 $(GSM_INSTALL_INC)/gsm.h: $(INC)/gsm.h
423 $(GSM_INSTALL_LIB)/libgsm.a: $(LIBGSM)
434 gsm-1.0.tar.Z: $(STUFF) $(SOURCES) $(HEADERS) $(MANUALS)
436 tar cvf - `cat $(ROOT)/gsm-1.0/MANIFEST \
438 ) | $(COMPRESS) $(COMPRESSFLAGS) > $(ROOT)/gsm-1.0.tar.Z
442 uninstall: toastuninstall gsmuninstall
443 @-echo uninstall: Done.
446 -rm $(RMFLAGS) */*.o \
447 $(TST)/lin2cod $(TST)/lin2txt \
448 $(TST)/cod2lin $(TST)/cod2txt \
451 -$(FIND) . \( -name core -o -name foo \) \
452 -print | xargs rm $(RMFLAGS)
455 -rm $(RMFLAGS) $(LIBGSM) $(ADDTST)/add \
456 $(TOAST) $(TCAT) $(UNTOAST) \
457 $(ROOT)/gsm-1.0.tar.Z
460 # Two tools that helped me generate gsm_encode.c and gsm_decode.c,
461 # but aren't generally needed to port this.
463 $(TLS)/sweet: $(TLS)/sweet.o $(TLS)/taste.o
464 $(LD) $(LFLAGS) -o $(TLS)/sweet \
465 $(TLS)/sweet.o $(TLS)/taste.o $(LDLIB)
467 $(TLS)/bitter: $(TLS)/bitter.o $(TLS)/taste.o
468 $(LD) $(LFLAGS) -o $(TLS)/bitter \
469 $(TLS)/bitter.o $(TLS)/taste.o $(LDLIB)
471 # A version of the same family that Jeff Chilton used to implement
472 # the WAV #49 GSM format.
474 $(TLS)/ginger: $(TLS)/ginger.o $(TLS)/taste.o
475 $(LD) $(LFLAGS) -o $(TLS)/ginger \
476 $(TLS)/ginger.o $(TLS)/taste.o $(LDLIB)
478 $(TLS)/sour: $(TLS)/sour.o $(TLS)/taste.o
479 $(LD) $(LFLAGS) -o $(TLS)/sour \
480 $(TLS)/sour.o $(TLS)/taste.o $(LDLIB)
482 # Run $(ADDTST)/add < $(ADDTST)/add_test.dta to make sure the
483 # basic arithmetic functions work as intended.
485 $(ADDTST)/add: $(ADDTST)/add_test.o
486 $(LD) $(LFLAGS) -o $(ADDTST)/add $(ADDTST)/add_test.o $(LDLIB)
489 # Various conversion programs between linear, text, .gsm and the code
490 # format used by the tests we ran (.cod). We paid for the test data,
491 # so I guess we can't just provide them with this package. Still,
492 # if you happen to have them lying around, here's the code.
494 # You can use gsm2cod | cod2txt independently to look at what's
495 # coded inside the compressed frames, although this shouldn't be
496 # hard to roll on your own using the gsm_print() function from
500 $(TST)/test-result: $(TST)/lin2cod $(TST)/cod2lin $(TOAST) $(TST)/run
503 $(TST)/lin2txt: $(TST)/lin2txt.o $(LIBGSM)
504 $(LD) $(LFLAGS) -o $(TST)/lin2txt \
505 $(TST)/lin2txt.o $(LIBGSM) $(LDLIB)
507 $(TST)/lin2cod: $(TST)/lin2cod.o $(LIBGSM)
508 $(LD) $(LFLAGS) -o $(TST)/lin2cod \
509 $(TST)/lin2cod.o $(LIBGSM) $(LDLIB)
511 $(TST)/gsm2cod: $(TST)/gsm2cod.o $(LIBGSM)
512 $(LD) $(LFLAGS) -o $(TST)/gsm2cod \
513 $(TST)/gsm2cod.o $(LIBGSM) $(LDLIB)
515 $(TST)/cod2txt: $(TST)/cod2txt.o $(LIBGSM)
516 $(LD) $(LFLAGS) -o $(TST)/cod2txt \
517 $(TST)/cod2txt.o $(LIBGSM) $(LDLIB)
519 $(TST)/cod2lin: $(TST)/cod2lin.o $(LIBGSM)
520 $(LD) $(LFLAGS) -o $(TST)/cod2lin \
521 $(TST)/cod2lin.o $(LIBGSM) $(LDLIB)