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 ifeq (, $(findstring $(OSARCH) , Darwin SunOS ))
41 ifeq (, $(findstring $(PROC) , x86_64 amd64 ultrasparc sparc64 arm ppc ppc64 ia64 s390))
42 ifeq (, $(findstring $(shell uname -m) , ppc ppc64 alpha armv4l ))
43 OPTIMIZE+=-march=$(PROC)
48 #The problem with sparc is the best stuff is in newer versions of gcc (post 3.0) only.
49 #This works for even old (2.96) versions of gcc and provides a small boost either way.
50 #A ultrasparc cpu is really v9 but the stock debian stable 3.0 gcc doesn't support it.
51 #So we go lowest common available by gcc and go a step down, still a step up from
52 #the default as we now have a better instruction set to work with. - Belgarath
53 ifeq (${PROC},ultrasparc)
54 OPTIMIZE+=-mcpu=v8 -mtune=$(PROC) -O3
59 ######### Profiling flags. If you don't know what that means, leave it blank.
61 # Choose a compiler. The code works both with ANSI and K&R-C.
62 # Use -DNeedFunctionPrototypes to compile with, -UNeedFunctionPrototypes to
63 # compile without, function prototypes in the header files.
65 # You can use the -DSTUPID_COMPILER to circumvent some compilers'
66 # static limits regarding the number of subexpressions in a statement.
69 # CCFLAGS = -c -DSTUPID_COMPILER
75 CCFLAGS += -c -DNeedFunctionPrototypes=1 -funroll-loops $(OPTIMIZE)
84 # If your compiler needs additional flags/libraries, regardless of
85 # the source compiled, configure them here.
87 # CCINC = -I/usr/gnu/lib/gcc-2.1/gcc-lib/sparc-sun-sunos4.1.2/2.1/include
88 ######### Includes needed by $(CC)
90 # LDINC = -L/usr/gnu/lib/gcc-2.1/gcc-lib/sparc-sun-sunos4.1.2/2.1
91 ######### Library paths needed by $(LD)
94 ######### Additional libraries needed by $(LD)
97 # Where do you want to install libraries, binaries, a header file
98 # and the manual pages?
100 # Leave INSTALL_ROOT empty (or just don't execute "make install") to
101 # not install gsm and toast outside of this directory.
105 # Where do you want to install the gsm library, header file, and manpages?
107 # Leave GSM_INSTALL_ROOT empty to not install the GSM library outside of
110 GSM_INSTALL_ROOT = $(INSTALL_ROOT)
111 GSM_INSTALL_LIB = $(GSM_INSTALL_ROOT)/lib
112 GSM_INSTALL_INC = $(GSM_INSTALL_ROOT)/inc
113 GSM_INSTALL_MAN = $(GSM_INSTALL_ROOT)/man/man3
116 # Where do you want to install the toast binaries and their manpage?
118 # Leave TOAST_INSTALL_ROOT empty to not install the toast binaries outside
121 TOAST_INSTALL_ROOT = $(INSTALL_ROOT)
122 TOAST_INSTALL_BIN = $(TOAST_INSTALL_ROOT)/bin
123 TOAST_INSTALL_MAN = $(TOAST_INSTALL_ROOT)/man/man1
140 # You shouldn't have to configure below this line if you're porting.
147 ADDTST = $(ROOT)/add-test
159 ######### Remove -DNDEBUG to enable assertions.
161 CFLAGS += $(PG) $(CCFLAGS) $(SASR) $(DEBUG) $(MULHACK) $(FAST) \
162 $(LTP_CUT) $(WAV49) $(K6OPT) $(CCINC) -I$(INC)
163 ######### It's $(CC) $(CFLAGS)
165 LFLAGS = $(PG) $(LDFLAGS) $(LDINC)
166 ######### It's $(LD) $(LFLAGS)
171 LIBGSM = $(LIB)/libgsm.a
172 LIBGSMSO= $(LIB)/libgsm.so
175 UNTOAST = $(BIN)/untoast
180 GSM_HEADERS = $(INC)/gsm.h
182 HEADERS = $(INC)/proto.h \
192 GSM_SOURCES = $(SRC)/add.c \
198 $(SRC)/preprocess.c \
200 $(SRC)/gsm_destroy.c \
201 $(SRC)/gsm_decode.c \
202 $(SRC)/gsm_encode.c \
203 $(SRC)/gsm_explode.c \
204 $(SRC)/gsm_implode.c \
205 $(SRC)/gsm_create.c \
207 $(SRC)/gsm_option.c \
208 $(SRC)/short_term.c \
211 # add k6-specific code only if not on a non-k6 hardware or proc.
212 # XXX Keep a space after each findstring argument
213 # XXX should merge with GSM_OBJECTS
214 ifeq (${OSARCH},Linux)
215 ifeq (,$(findstring $(shell uname -m) , x86_64 amd64 ppc ppc64 alpha armv4l sparc64 parisc ))
216 ifeq (,$(findstring ${PROC} , arm ia64 ))
217 GSM_SOURCES+= $(SRC)/k6opt.s
222 TOAST_SOURCES = $(SRC)/toast.c \
224 $(SRC)/toast_ulaw.c \
225 $(SRC)/toast_alaw.c \
228 SOURCES = $(GSM_SOURCES) \
230 $(ADDTST)/add_test.c \
247 GSM_OBJECTS = $(SRC)/add.o \
253 $(SRC)/preprocess.o \
255 $(SRC)/gsm_destroy.o \
256 $(SRC)/gsm_decode.o \
257 $(SRC)/gsm_encode.o \
258 $(SRC)/gsm_explode.o \
259 $(SRC)/gsm_implode.o \
260 $(SRC)/gsm_create.o \
262 $(SRC)/gsm_option.o \
263 $(SRC)/short_term.o \
266 ifeq (${OSARCH},Linux)
267 ifeq (,$(findstring $(shell uname -m) , x86_64 amd64 ppc ppc64 alpha armv4l sparc64 parisc ))
268 ifeq (,$(findstring ${PROC} , arm ia64 ))
269 GSM_OBJECTS+= $(SRC)/k6opt.o
274 TOAST_OBJECTS = $(SRC)/toast.o \
276 $(SRC)/toast_ulaw.o \
277 $(SRC)/toast_alaw.o \
280 OBJECTS = $(GSM_OBJECTS) $(TOAST_OBJECTS)
284 GSM_MANUALS = $(MAN)/gsm.3 \
285 $(MAN)/gsm_explode.3 \
286 $(MAN)/gsm_option.3 \
289 TOAST_MANUALS = $(MAN)/toast.1
291 MANUALS = $(GSM_MANUALS) $(TOAST_MANUALS) $(MAN)/bitter.1
293 # Other stuff in the distribution
301 $(ADDTST)/add_test.dta \
308 GSM_INSTALL_TARGETS = \
309 $(GSM_INSTALL_LIB)/libgsm.a \
310 $(GSM_INSTALL_INC)/gsm.h \
311 $(GSM_INSTALL_MAN)/gsm.3 \
312 $(GSM_INSTALL_MAN)/gsm_explode.3 \
313 $(GSM_INSTALL_MAN)/gsm_option.3 \
314 $(GSM_INSTALL_MAN)/gsm_print.3
316 TOAST_INSTALL_TARGETS = \
317 $(TOAST_INSTALL_BIN)/toast \
318 $(TOAST_INSTALL_BIN)/tcat \
319 $(TOAST_INSTALL_BIN)/untoast \
320 $(TOAST_INSTALL_MAN)/toast.1
326 $(CC) $(CFLAGS:-Werror=) $?
327 @-mv `$(BASENAME) $@` $@ > /dev/null 2>&1
331 all: $(LIBGSM) $(LIBGSMSO) $(TOAST) $(TCAT) $(UNTOAST)
332 @-echo $(ROOT): Done.
334 tst: $(TST)/lin2cod $(TST)/cod2lin $(TOAST) $(TST)/test-result
337 addtst: $(ADDTST)/add $(ADDTST)/add_test.dta
338 $(ADDTST)/add < $(ADDTST)/add_test.dta > /dev/null
341 misc: $(TLS)/sweet $(TLS)/bitter $(TLS)/sour $(TLS)/ginger \
342 $(TST)/lin2txt $(TST)/cod2txt $(TST)/gsm2cod
345 install: toastinstall gsminstall
346 @-echo install: Done.
349 # The basic API: libgsm
351 $(LIBGSMSO): $(LIB) $(GSM_OBJECTS)
352 $(LD) -o $@.1.0.10 -shared -Xlinker -soname -Xlinker libgsm.so.1 $(GSM_OBJECTS) -lc
353 ln -fs libgsm.so.1.0.10 lib/libgsm.so.1
354 ln -fs libgsm.so.1.0.10 lib/libgsm.so
356 $(LIBGSM): $(LIB) $(GSM_OBJECTS)
357 -rm $(RMFLAGS) $(LIBGSM)
358 $(AR) $(ARFLAGS) $(LIBGSM) $(GSM_OBJECTS)
362 # Toast, Untoast and Tcat -- the compress-like frontends to gsm.
364 $(TOAST): $(BIN) $(TOAST_OBJECTS) $(LIBGSM)
365 $(LD) $(LFLAGS) -o $(TOAST) $(TOAST_OBJECTS) $(LIBGSMSO) $(LDLIB)
367 $(UNTOAST): $(BIN) $(TOAST)
368 -rm $(RMFLAGS) $(UNTOAST)
369 $(LN) toast $(UNTOAST)
371 $(TCAT): $(BIN) $(TOAST)
372 -rm $(RMFLAGS) $(TCAT)
376 # The local bin and lib directories
379 if [ ! -d $(BIN) ] ; then mkdir $(BIN) ; fi
382 if [ ! -d $(LIB) ] ; then mkdir $(LIB) ; fi
388 -if [ x"$(GSM_INSTALL_ROOT)" != x ] ; then \
389 $(MAKE) $(GSM_INSTALL_TARGETS) ; \
393 -if [ x"$(TOAST_INSTALL_ROOT)" != x ]; then \
394 $(MAKE) $(TOAST_INSTALL_TARGETS); \
398 -if [ x"$(GSM_INSTALL_ROOT)" != x ] ; then \
399 rm $(RMFLAGS) $(GSM_INSTALL_TARGETS) ; \
403 -if [ x"$(TOAST_INSTALL_ROOT)" != x ] ; then \
404 rm $(RMFLAGS) $(TOAST_INSTALL_TARGETS); \
407 $(TOAST_INSTALL_BIN)/toast: $(TOAST)
412 $(TOAST_INSTALL_BIN)/untoast: $(TOAST_INSTALL_BIN)/toast
416 $(TOAST_INSTALL_BIN)/tcat: $(TOAST_INSTALL_BIN)/toast
420 $(TOAST_INSTALL_MAN)/toast.1: $(MAN)/toast.1
425 $(GSM_INSTALL_MAN)/gsm.3: $(MAN)/gsm.3
430 $(GSM_INSTALL_MAN)/gsm_option.3: $(MAN)/gsm_option.3
435 $(GSM_INSTALL_MAN)/gsm_explode.3: $(MAN)/gsm_explode.3
440 $(GSM_INSTALL_MAN)/gsm_print.3: $(MAN)/gsm_print.3
445 $(GSM_INSTALL_INC)/gsm.h: $(INC)/gsm.h
450 $(GSM_INSTALL_LIB)/libgsm.a: $(LIBGSM)
461 gsm-1.0.tar.Z: $(STUFF) $(SOURCES) $(HEADERS) $(MANUALS)
463 tar cvf - `cat $(ROOT)/gsm-1.0/MANIFEST \
465 ) | $(COMPRESS) $(COMPRESSFLAGS) > $(ROOT)/gsm-1.0.tar.Z
469 uninstall: toastuninstall gsmuninstall
470 @-echo uninstall: Done.
473 -rm $(RMFLAGS) */*.o \
474 $(TST)/lin2cod $(TST)/lin2txt \
475 $(TST)/cod2lin $(TST)/cod2txt \
478 -$(FIND) . \( -name core -o -name foo \) \
479 -print | xargs rm $(RMFLAGS)
482 -rm $(RMFLAGS) $(LIBGSM) $(ADDTST)/add \
483 $(TOAST) $(TCAT) $(UNTOAST) \
484 $(ROOT)/gsm-1.0.tar.Z
487 # Two tools that helped me generate gsm_encode.c and gsm_decode.c,
488 # but aren't generally needed to port this.
490 $(TLS)/sweet: $(TLS)/sweet.o $(TLS)/taste.o
491 $(LD) $(LFLAGS) -o $(TLS)/sweet \
492 $(TLS)/sweet.o $(TLS)/taste.o $(LDLIB)
494 $(TLS)/bitter: $(TLS)/bitter.o $(TLS)/taste.o
495 $(LD) $(LFLAGS) -o $(TLS)/bitter \
496 $(TLS)/bitter.o $(TLS)/taste.o $(LDLIB)
498 # A version of the same family that Jeff Chilton used to implement
499 # the WAV #49 GSM format.
501 $(TLS)/ginger: $(TLS)/ginger.o $(TLS)/taste.o
502 $(LD) $(LFLAGS) -o $(TLS)/ginger \
503 $(TLS)/ginger.o $(TLS)/taste.o $(LDLIB)
505 $(TLS)/sour: $(TLS)/sour.o $(TLS)/taste.o
506 $(LD) $(LFLAGS) -o $(TLS)/sour \
507 $(TLS)/sour.o $(TLS)/taste.o $(LDLIB)
509 # Run $(ADDTST)/add < $(ADDTST)/add_test.dta to make sure the
510 # basic arithmetic functions work as intended.
512 $(ADDTST)/add: $(ADDTST)/add_test.o
513 $(LD) $(LFLAGS) -o $(ADDTST)/add $(ADDTST)/add_test.o $(LDLIB)
516 # Various conversion programs between linear, text, .gsm and the code
517 # format used by the tests we ran (.cod). We paid for the test data,
518 # so I guess we can't just provide them with this package. Still,
519 # if you happen to have them lying around, here's the code.
521 # You can use gsm2cod | cod2txt independently to look at what's
522 # coded inside the compressed frames, although this shouldn't be
523 # hard to roll on your own using the gsm_print() function from
527 $(TST)/test-result: $(TST)/lin2cod $(TST)/cod2lin $(TOAST) $(TST)/run
530 $(TST)/lin2txt: $(TST)/lin2txt.o $(LIBGSM)
531 $(LD) $(LFLAGS) -o $(TST)/lin2txt \
532 $(TST)/lin2txt.o $(LIBGSM) $(LDLIB)
534 $(TST)/lin2cod: $(TST)/lin2cod.o $(LIBGSM)
535 $(LD) $(LFLAGS) -o $(TST)/lin2cod \
536 $(TST)/lin2cod.o $(LIBGSM) $(LDLIB)
538 $(TST)/gsm2cod: $(TST)/gsm2cod.o $(LIBGSM)
539 $(LD) $(LFLAGS) -o $(TST)/gsm2cod \
540 $(TST)/gsm2cod.o $(LIBGSM) $(LDLIB)
542 $(TST)/cod2txt: $(TST)/cod2txt.o $(LIBGSM)
543 $(LD) $(LFLAGS) -o $(TST)/cod2txt \
544 $(TST)/cod2txt.o $(LIBGSM) $(LDLIB)
546 $(TST)/cod2lin: $(TST)/cod2lin.o $(LIBGSM)
547 $(LD) $(LFLAGS) -o $(TST)/cod2lin \
548 $(TST)/cod2lin.o $(LIBGSM) $(LDLIB)