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 # Due to the gsm codec beeing broken when compiled with gcc version 4.2
41 # and optimization higher than -O2 we are checking for that version and
42 # set the optimization to -O2 in this case.
44 ifeq ($(shell $(CC) -v 2>&1 | awk '/^gcc version/ { split($$3, v, "."); printf "%s.%s\n", v[1], v[2]; }' ),4.2)
50 ######### Profiling flags. If you don't know what that means, leave it blank.
52 # Choose a compiler. The code works both with ANSI and K&R-C.
53 # Use -DNeedFunctionPrototypes to compile with, -UNeedFunctionPrototypes to
54 # compile without, function prototypes in the header files.
56 # You can use the -DSTUPID_COMPILER to circumvent some compilers'
57 # static limits regarding the number of subexpressions in a statement.
60 # CCFLAGS = -c -DSTUPID_COMPILER
65 CCFLAGS += -c -DNeedFunctionPrototypes=1 -funroll-loops $(OPTIMIZE)
71 # If your compiler needs additional flags/libraries, regardless of
72 # the source compiled, configure them here.
74 # CCINC = -I/usr/gnu/lib/gcc-2.1/gcc-lib/sparc-sun-sunos4.1.2/2.1/include
75 ######### Includes needed by $(CC)
77 # LDINC = -L/usr/gnu/lib/gcc-2.1/gcc-lib/sparc-sun-sunos4.1.2/2.1
78 ######### Library paths needed by $(LD)
81 ######### Additional libraries needed by $(LD)
84 # Where do you want to install libraries, binaries, a header file
85 # and the manual pages?
87 # Leave INSTALL_ROOT empty (or just don't execute "make install") to
88 # not install gsm and toast outside of this directory.
92 # Where do you want to install the gsm library, header file, and manpages?
94 # Leave GSM_INSTALL_ROOT empty to not install the GSM library outside of
97 GSM_INSTALL_ROOT = $(INSTALL_ROOT)
98 GSM_INSTALL_LIB = $(GSM_INSTALL_ROOT)/lib
99 GSM_INSTALL_INC = $(GSM_INSTALL_ROOT)/inc
100 GSM_INSTALL_MAN = $(GSM_INSTALL_ROOT)/man/man3
103 # Where do you want to install the toast binaries and their manpage?
105 # Leave TOAST_INSTALL_ROOT empty to not install the toast binaries outside
108 TOAST_INSTALL_ROOT = $(INSTALL_ROOT)
109 TOAST_INSTALL_BIN = $(TOAST_INSTALL_ROOT)/bin
110 TOAST_INSTALL_MAN = $(TOAST_INSTALL_ROOT)/man/man1
127 # You shouldn't have to configure below this line if you're porting.
134 ADDTST = $(ROOT)/add-test
146 ######### Remove -DNDEBUG to enable assertions.
148 _ASTCFLAGS += $(PG) $(CCFLAGS) $(SASR) $(DEBUG) $(MULHACK) $(FAST) \
149 $(LTP_CUT) $(WAV49) $(K6OPT) $(CCINC) -I$(INC)
150 ######### It's $(CC) $(CFLAGS)
152 LFLAGS = $(PG) $(LDFLAGS) $(LDINC)
153 ######### It's $(LD) $(LFLAGS)
158 LIBGSM = $(LIB)/libgsm.a
159 LIBGSMSO= $(LIB)/libgsm.so
162 UNTOAST = $(BIN)/untoast
167 GSM_HEADERS = $(INC)/gsm.h
169 HEADERS = $(INC)/proto.h \
179 GSM_SOURCES = $(SRC)/add.c \
185 $(SRC)/preprocess.c \
187 $(SRC)/gsm_destroy.c \
188 $(SRC)/gsm_decode.c \
189 $(SRC)/gsm_encode.c \
190 $(SRC)/gsm_explode.c \
191 $(SRC)/gsm_implode.c \
192 $(SRC)/gsm_create.c \
194 $(SRC)/gsm_option.c \
195 $(SRC)/short_term.c \
198 TOAST_SOURCES = $(SRC)/toast.c \
200 $(SRC)/toast_ulaw.c \
201 $(SRC)/toast_alaw.c \
204 SOURCES = $(GSM_SOURCES) \
206 $(ADDTST)/add_test.c \
223 GSM_OBJECTS = $(SRC)/add.o \
229 $(SRC)/preprocess.o \
231 $(SRC)/gsm_destroy.o \
232 $(SRC)/gsm_decode.o \
233 $(SRC)/gsm_encode.o \
234 $(SRC)/gsm_explode.o \
235 $(SRC)/gsm_implode.o \
236 $(SRC)/gsm_create.o \
238 $(SRC)/gsm_option.o \
239 $(SRC)/short_term.o \
242 TOAST_OBJECTS = $(SRC)/toast.o \
244 $(SRC)/toast_ulaw.o \
245 $(SRC)/toast_alaw.o \
248 OBJECTS = $(GSM_OBJECTS) $(TOAST_OBJECTS)
252 GSM_MANUALS = $(MAN)/gsm.3 \
253 $(MAN)/gsm_explode.3 \
254 $(MAN)/gsm_option.3 \
257 TOAST_MANUALS = $(MAN)/toast.1
259 MANUALS = $(GSM_MANUALS) $(TOAST_MANUALS) $(MAN)/bitter.1
261 # Other stuff in the distribution
269 $(ADDTST)/add_test.dta \
276 GSM_INSTALL_TARGETS = \
277 $(GSM_INSTALL_LIB)/libgsm.a \
278 $(GSM_INSTALL_INC)/gsm.h \
279 $(GSM_INSTALL_MAN)/gsm.3 \
280 $(GSM_INSTALL_MAN)/gsm_explode.3 \
281 $(GSM_INSTALL_MAN)/gsm_option.3 \
282 $(GSM_INSTALL_MAN)/gsm_print.3
284 TOAST_INSTALL_TARGETS = \
285 $(TOAST_INSTALL_BIN)/toast \
286 $(TOAST_INSTALL_BIN)/tcat \
287 $(TOAST_INSTALL_BIN)/untoast \
288 $(TOAST_INSTALL_MAN)/toast.1
293 include $(ASTTOPDIR)/Makefile.rules
297 all: $(LIBGSM) $(LIBGSMSO) $(TOAST) $(TCAT) $(UNTOAST)
298 @-echo $(ROOT): Done.
300 tst: $(TST)/lin2cod $(TST)/cod2lin $(TOAST) $(TST)/test-result
303 addtst: $(ADDTST)/add $(ADDTST)/add_test.dta
304 $(ADDTST)/add < $(ADDTST)/add_test.dta > /dev/null
307 misc: $(TLS)/sweet $(TLS)/bitter $(TLS)/sour $(TLS)/ginger \
308 $(TST)/lin2txt $(TST)/cod2txt $(TST)/gsm2cod
311 install: toastinstall gsminstall
312 @-echo install: Done.
315 # The basic API: libgsm
317 $(LIBGSMSO): $(LIB) $(GSM_OBJECTS)
318 $(LD) -o $@.1.0.10 -shared -Xlinker -soname -Xlinker libgsm.so.1 $(GSM_OBJECTS) -lc
319 ln -fs libgsm.so.1.0.10 lib/libgsm.so.1
320 ln -fs libgsm.so.1.0.10 lib/libgsm.so
322 $(LIBGSM): $(GSM_OBJECTS)
323 $(ECHO_PREFIX) echo " [AR] $^ -> $@"
324 $(CMD_PREFIX) $(AR) cr $@ $^
325 $(CMD_PREFIX) $(RANLIB) $@
328 # Toast, Untoast and Tcat -- the compress-like frontends to gsm.
330 $(TOAST): $(BIN) $(TOAST_OBJECTS) $(LIBGSM)
331 $(LD) $(LFLAGS) -o $(TOAST) $(TOAST_OBJECTS) $(LIBGSMSO) $(LDLIB)
333 $(UNTOAST): $(BIN) $(TOAST)
334 -rm $(RMFLAGS) $(UNTOAST)
335 $(LN) toast $(UNTOAST)
337 $(TCAT): $(BIN) $(TOAST)
338 -rm $(RMFLAGS) $(TCAT)
342 # The local bin and lib directories
345 if [ ! -d $(BIN) ] ; then mkdir $(BIN) ; fi
348 if [ ! -d $(LIB) ] ; then mkdir $(LIB) ; fi
354 -if [ x"$(GSM_INSTALL_ROOT)" != x ] ; then \
355 $(MAKE) $(GSM_INSTALL_TARGETS) ; \
359 -if [ x"$(TOAST_INSTALL_ROOT)" != x ]; then \
360 $(MAKE) $(TOAST_INSTALL_TARGETS); \
364 -if [ x"$(GSM_INSTALL_ROOT)" != x ] ; then \
365 rm $(RMFLAGS) $(GSM_INSTALL_TARGETS) ; \
369 -if [ x"$(TOAST_INSTALL_ROOT)" != x ] ; then \
370 rm $(RMFLAGS) $(TOAST_INSTALL_TARGETS); \
373 $(TOAST_INSTALL_BIN)/toast: $(TOAST)
378 $(TOAST_INSTALL_BIN)/untoast: $(TOAST_INSTALL_BIN)/toast
382 $(TOAST_INSTALL_BIN)/tcat: $(TOAST_INSTALL_BIN)/toast
386 $(TOAST_INSTALL_MAN)/toast.1: $(MAN)/toast.1
391 $(GSM_INSTALL_MAN)/gsm.3: $(MAN)/gsm.3
396 $(GSM_INSTALL_MAN)/gsm_option.3: $(MAN)/gsm_option.3
401 $(GSM_INSTALL_MAN)/gsm_explode.3: $(MAN)/gsm_explode.3
406 $(GSM_INSTALL_MAN)/gsm_print.3: $(MAN)/gsm_print.3
411 $(GSM_INSTALL_INC)/gsm.h: $(INC)/gsm.h
416 $(GSM_INSTALL_LIB)/libgsm.a: $(LIBGSM)
427 gsm-1.0.tar.Z: $(STUFF) $(SOURCES) $(HEADERS) $(MANUALS)
429 tar cvf - `cat $(ROOT)/gsm-1.0/MANIFEST \
431 ) | $(COMPRESS) $(COMPRESSFLAGS) > $(ROOT)/gsm-1.0.tar.Z
435 uninstall: toastuninstall gsmuninstall
436 @-echo uninstall: Done.
439 -rm $(RMFLAGS) */*.o \
440 $(TST)/lin2cod $(TST)/lin2txt \
441 $(TST)/cod2lin $(TST)/cod2txt \
444 -$(FIND) . \( -name core -o -name foo \) \
445 -print | xargs rm $(RMFLAGS)
448 -rm $(RMFLAGS) $(LIBGSM) $(ADDTST)/add \
449 $(TOAST) $(TCAT) $(UNTOAST) \
450 $(ROOT)/gsm-1.0.tar.Z
454 # Two tools that helped me generate gsm_encode.c and gsm_decode.c,
455 # but aren't generally needed to port this.
457 $(TLS)/sweet: $(TLS)/sweet.o $(TLS)/taste.o
458 $(LD) $(LFLAGS) -o $(TLS)/sweet \
459 $(TLS)/sweet.o $(TLS)/taste.o $(LDLIB)
461 $(TLS)/bitter: $(TLS)/bitter.o $(TLS)/taste.o
462 $(LD) $(LFLAGS) -o $(TLS)/bitter \
463 $(TLS)/bitter.o $(TLS)/taste.o $(LDLIB)
465 # A version of the same family that Jeff Chilton used to implement
466 # the WAV #49 GSM format.
468 $(TLS)/ginger: $(TLS)/ginger.o $(TLS)/taste.o
469 $(LD) $(LFLAGS) -o $(TLS)/ginger \
470 $(TLS)/ginger.o $(TLS)/taste.o $(LDLIB)
472 $(TLS)/sour: $(TLS)/sour.o $(TLS)/taste.o
473 $(LD) $(LFLAGS) -o $(TLS)/sour \
474 $(TLS)/sour.o $(TLS)/taste.o $(LDLIB)
476 # Run $(ADDTST)/add < $(ADDTST)/add_test.dta to make sure the
477 # basic arithmetic functions work as intended.
479 $(ADDTST)/add: $(ADDTST)/add_test.o
480 $(LD) $(LFLAGS) -o $(ADDTST)/add $(ADDTST)/add_test.o $(LDLIB)
483 # Various conversion programs between linear, text, .gsm and the code
484 # format used by the tests we ran (.cod). We paid for the test data,
485 # so I guess we can't just provide them with this package. Still,
486 # if you happen to have them lying around, here's the code.
488 # You can use gsm2cod | cod2txt independently to look at what's
489 # coded inside the compressed frames, although this shouldn't be
490 # hard to roll on your own using the gsm_print() function from
494 $(TST)/test-result: $(TST)/lin2cod $(TST)/cod2lin $(TOAST) $(TST)/run
497 $(TST)/lin2txt: $(TST)/lin2txt.o $(LIBGSM)
498 $(LD) $(LFLAGS) -o $(TST)/lin2txt \
499 $(TST)/lin2txt.o $(LIBGSM) $(LDLIB)
501 $(TST)/lin2cod: $(TST)/lin2cod.o $(LIBGSM)
502 $(LD) $(LFLAGS) -o $(TST)/lin2cod \
503 $(TST)/lin2cod.o $(LIBGSM) $(LDLIB)
505 $(TST)/gsm2cod: $(TST)/gsm2cod.o $(LIBGSM)
506 $(LD) $(LFLAGS) -o $(TST)/gsm2cod \
507 $(TST)/gsm2cod.o $(LIBGSM) $(LDLIB)
509 $(TST)/cod2txt: $(TST)/cod2txt.o $(LIBGSM)
510 $(LD) $(LFLAGS) -o $(TST)/cod2txt \
511 $(TST)/cod2txt.o $(LIBGSM) $(LDLIB)
513 $(TST)/cod2lin: $(TST)/cod2lin.o $(LIBGSM)
514 $(LD) $(LFLAGS) -o $(TST)/cod2lin \
515 $(TST)/cod2lin.o $(LIBGSM) $(LDLIB)