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.
4
5# Machine- or installation dependent flags you should configure to port
6
7SASR	= -DSASR
8######### Define SASR if >> is a signed arithmetic shift (-1 >> 1 == -1)
9
10# MULHACK = -DUSE_FLOAT_MUL
11######### Define this if your host multiplies floats faster than integers,
12######### e.g. on a SPARCstation.
13
14# FAST	= -DFAST
15######### Define together with USE_FLOAT_MUL to enable the GSM library's
16######### approximation option for incorrect, but good-enough results.
17
18# LTP_CUT	= -DLTP_CUT
19LTP_CUT	=
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.
24
25WAV49	= -DWAV49
26# WAV49	=
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).
32
33# Choose a compiler.  The code works both with ANSI and K&R-C.
34# Use -DNeedFunctionPrototypes to compile with, -UNeedFunctionPrototypes to
35# compile without, function prototypes in the header files.
36#
37# You can use the -DSTUPID_COMPILER to circumvent some compilers'
38# static limits regarding the number of subexpressions in a statement.
39
40# CC		= cc
41# CCFLAGS 	= -c -DSTUPID_COMPILER
42
43# CC		= /usr/lang/acc
44# CCFLAGS 	= -c -O
45
46CC		= gcc -ansi -pedantic
47CCFLAGS 	= -c -O2 -DNeedFunctionPrototypes=1 -Wall -Wno-comment
48
49LD 		= $(CC)
50
51# LD		= gcc
52# LDFLAGS 	=
53
54
55# If your compiler needs additional flags/libraries, regardless of
56# the source compiled, configure them here.
57
58# CCINC	= -I/usr/gnu/lib/gcc-2.1/gcc-lib/sparc-sun-sunos4.1.2/2.1/include
59######### Includes needed by $(CC)
60
61# LDINC	= -L/usr/gnu/lib/gcc-2.1/gcc-lib/sparc-sun-sunos4.1.2/2.1
62######### Library paths needed by $(LD)
63
64# LDLIB	= -lgcc
65######### Additional libraries needed by $(LD)
66
67
68# Where do you want to install libraries, binaries, a header file
69# and the manual pages?
70#
71# Leave INSTALL_ROOT empty (or just don't execute "make install") to
72# not install gsm and toast outside of this directory.
73
74INSTALL_ROOT	=
75
76# Where do you want to install the gsm library, header file, and manpages?
77#
78# Leave GSM_INSTALL_ROOT empty to not install the GSM library outside of
79# this directory.
80
81GSM_INSTALL_ROOT = $(INSTALL_ROOT)
82GSM_INSTALL_LIB = $(GSM_INSTALL_ROOT)/lib
83GSM_INSTALL_INC = $(GSM_INSTALL_ROOT)/inc
84GSM_INSTALL_MAN = $(GSM_INSTALL_ROOT)/man/man3
85
86
87# Where do you want to install the toast binaries and their manpage?
88#
89# Leave TOAST_INSTALL_ROOT empty to not install the toast binaries outside
90# of this directory.
91
92TOAST_INSTALL_ROOT	  = $(INSTALL_ROOT)
93TOAST_INSTALL_BIN = $(TOAST_INSTALL_ROOT)/bin
94TOAST_INSTALL_MAN = $(TOAST_INSTALL_ROOT)/man/man1
95
96#  Other tools
97
98SHELL		= /bin/sh
99LN		= ln
100BASENAME 	= basename
101AR		= ar
102ARFLAGS		= cr
103RMFLAGS		=
104FIND		= find
105COMPRESS 	= gzip
106COMPRESSFLAGS 	=
107# RANLIB 	= true
108RANLIB	 	= ranlib
109
110#
111#    You shouldn't have to configure below this line if you're porting.
112#
113
114
115# Local Directories
116
117ROOT	= .
118ADDTST	= $(ROOT)/add-test
119TST	= $(ROOT)/tst
120MAN	= $(ROOT)/man
121BIN	= $(ROOT)/bin
122SRC	= $(ROOT)/src
123LIB	= $(ROOT)/lib
124TLS	= $(ROOT)/tls
125INC	= $(ROOT)/inc
126
127# Flags
128
129# DEBUG	= -DNDEBUG
130######### Remove -DNDEBUG to enable assertions.
131
132CFLAGS	= $(CCFLAGS) $(SASR) $(DEBUG) $(MULHACK) $(FAST) $(LTP_CUT) \
133	$(WAV49) $(CCINC) -I$(INC)
134######### It's $(CC) $(CFLAGS)
135
136LFLAGS	= $(LDFLAGS) $(LDINC)
137######### It's $(LD) $(LFLAGS)
138
139
140# Targets
141
142LIBGSM	= $(LIB)/libgsm.a
143
144TOAST	= $(BIN)/toast
145UNTOAST	= $(BIN)/untoast
146TCAT	= $(BIN)/tcat
147
148# Headers
149
150GSM_HEADERS =	$(INC)/gsm.h
151
152HEADERS	=	$(INC)/proto.h		\
153		$(INC)/unproto.h	\
154		$(INC)/config.h		\
155		$(INC)/private.h	\
156		$(INC)/gsm.h		\
157		$(INC)/toast.h		\
158		$(TLS)/taste.h
159
160# Sources
161
162GSM_SOURCES =	$(SRC)/add.c		\
163		$(SRC)/code.c		\
164		$(SRC)/debug.c		\
165		$(SRC)/decode.c		\
166		$(SRC)/long_term.c	\
167		$(SRC)/lpc.c		\
168		$(SRC)/preprocess.c	\
169		$(SRC)/rpe.c		\
170		$(SRC)/gsm_destroy.c	\
171		$(SRC)/gsm_decode.c	\
172		$(SRC)/gsm_encode.c	\
173		$(SRC)/gsm_explode.c	\
174		$(SRC)/gsm_implode.c	\
175		$(SRC)/gsm_create.c	\
176		$(SRC)/gsm_print.c	\
177		$(SRC)/gsm_option.c	\
178		$(SRC)/short_term.c	\
179		$(SRC)/table.c
180
181TOAST_SOURCES = $(SRC)/toast.c 		\
182		$(SRC)/toast_lin.c	\
183		$(SRC)/toast_ulaw.c	\
184		$(SRC)/toast_alaw.c	\
185		$(SRC)/toast_audio.c
186
187SOURCES	=	$(GSM_SOURCES)		\
188		$(TOAST_SOURCES)	\
189		$(ADDTST)/add_test.c	\
190		$(TLS)/sour.c		\
191		$(TLS)/ginger.c		\
192		$(TLS)/sour1.dta	\
193		$(TLS)/sour2.dta	\
194		$(TLS)/bitter.c		\
195		$(TLS)/bitter.dta	\
196		$(TLS)/taste.c		\
197		$(TLS)/sweet.c		\
198		$(TST)/cod2lin.c	\
199		$(TST)/cod2txt.c	\
200		$(TST)/gsm2cod.c	\
201		$(TST)/lin2cod.c	\
202		$(TST)/lin2txt.c
203
204# Object files
205
206GSM_OBJECTS =	$(SRC)/add.o		\
207		$(SRC)/code.o		\
208		$(SRC)/debug.o		\
209		$(SRC)/decode.o		\
210		$(SRC)/long_term.o	\
211		$(SRC)/lpc.o		\
212		$(SRC)/preprocess.o	\
213		$(SRC)/rpe.o		\
214		$(SRC)/gsm_destroy.o	\
215		$(SRC)/gsm_decode.o	\
216		$(SRC)/gsm_encode.o	\
217		$(SRC)/gsm_explode.o	\
218		$(SRC)/gsm_implode.o	\
219		$(SRC)/gsm_create.o	\
220		$(SRC)/gsm_print.o	\
221		$(SRC)/gsm_option.o	\
222		$(SRC)/short_term.o	\
223		$(SRC)/table.o
224
225TOAST_OBJECTS =	$(SRC)/toast.o 		\
226		$(SRC)/toast_lin.o	\
227		$(SRC)/toast_ulaw.o	\
228		$(SRC)/toast_alaw.o	\
229		$(SRC)/toast_audio.o
230
231OBJECTS =	 $(GSM_OBJECTS) $(TOAST_OBJECTS)
232
233# Manuals
234
235GSM_MANUALS =	$(MAN)/gsm.3		\
236		$(MAN)/gsm_explode.3	\
237		$(MAN)/gsm_option.3	\
238		$(MAN)/gsm_print.3
239
240TOAST_MANUALS =	$(MAN)/toast.1
241
242MANUALS	= 	$(GSM_MANUALS) $(TOAST_MANUALS) $(MAN)/bitter.1
243
244# Other stuff in the distribution
245
246STUFF = 	ChangeLog			\
247		INSTALL			\
248		MACHINES		\
249		MANIFEST		\
250		Makefile		\
251		README			\
252		$(ADDTST)/add_test.dta	\
253		$(TLS)/bitter.dta	\
254		$(TST)/run
255
256
257# Install targets
258
259GSM_INSTALL_TARGETS =	\
260		$(GSM_INSTALL_LIB)/libgsm.a		\
261		$(GSM_INSTALL_INC)/gsm.h		\
262		$(GSM_INSTALL_MAN)/gsm.3		\
263		$(GSM_INSTALL_MAN)/gsm_explode.3	\
264		$(GSM_INSTALL_MAN)/gsm_option.3		\
265		$(GSM_INSTALL_MAN)/gsm_print.3
266
267TOAST_INSTALL_TARGETS =	\
268		$(TOAST_INSTALL_BIN)/toast		\
269		$(TOAST_INSTALL_BIN)/tcat		\
270		$(TOAST_INSTALL_BIN)/untoast		\
271		$(TOAST_INSTALL_MAN)/toast.1
272
273
274# Default rules
275
276.c.o:
277		$(CC) $(CFLAGS) $?
278		@-mv `$(BASENAME) $@` $@ > /dev/null 2>&1
279
280# Target rules
281
282all:		$(LIBGSM) $(TOAST) $(TCAT) $(UNTOAST)
283		@-echo $(ROOT): Done.
284
285tst:		$(TST)/lin2cod $(TST)/cod2lin $(TOAST) $(TST)/test-result
286		@-echo tst: Done.
287
288addtst:		$(ADDTST)/add $(ADDTST)/add_test.dta
289		$(ADDTST)/add < $(ADDTST)/add_test.dta > /dev/null
290		@-echo addtst: Done.
291
292misc:		$(TLS)/sweet $(TLS)/bitter $(TLS)/sour $(TLS)/ginger 	\
293			$(TST)/lin2txt $(TST)/cod2txt $(TST)/gsm2cod
294		@-echo misc: Done.
295
296install:	toastinstall gsminstall
297		@-echo install: Done.
298
299
300# The basic API: libgsm
301
302$(LIBGSM):	$(LIB) $(GSM_OBJECTS)
303		-rm $(RMFLAGS) $(LIBGSM)
304		$(AR) $(ARFLAGS) $(LIBGSM) $(GSM_OBJECTS)
305		$(RANLIB) $(LIBGSM)
306
307
308# Toast, Untoast and Tcat -- the compress-like frontends to gsm.
309
310$(TOAST):	$(BIN) $(TOAST_OBJECTS) $(LIBGSM)
311		$(LD) $(LFLAGS) -o $(TOAST) $(TOAST_OBJECTS) $(LIBGSM) $(LDLIB)
312
313$(UNTOAST):	$(BIN) $(TOAST)
314		-rm $(RMFLAGS) $(UNTOAST)
315		$(LN) $(TOAST) $(UNTOAST)
316
317$(TCAT):	$(BIN) $(TOAST)
318		-rm $(RMFLAGS) $(TCAT)
319		$(LN) $(TOAST) $(TCAT)
320
321
322# The local bin and lib directories
323
324$(BIN):
325		if [ ! -d $(BIN) ] ; then mkdir $(BIN) ; fi
326
327$(LIB):
328		if [ ! -d $(LIB) ] ; then mkdir $(LIB) ; fi
329
330
331# Installation
332
333gsminstall:
334		-if [ x"$(GSM_INSTALL_ROOT)" != x ] ; then	\
335			make $(GSM_INSTALL_TARGETS) ;	\
336		fi
337
338toastinstall:
339		-if [ x"$(TOAST_INSTALL_ROOT)" != x ]; then	\
340			make $(TOAST_INSTALL_TARGETS);	\
341		fi
342
343gsmuninstall:
344		-if [ x"$(GSM_INSTALL_ROOT)" != x ] ; then	\
345			rm $(RMFLAGS) $(GSM_INSTALL_TARGETS) ;	\
346		fi
347
348toastuninstall:
349		-if [ x"$(TOAST_INSTALL_ROOT)" != x ] ; then 	\
350			rm $(RMFLAGS) $(TOAST_INSTALL_TARGETS);	\
351		fi
352
353$(TOAST_INSTALL_BIN)/toast:	$(TOAST)
354		-rm $@
355		cp $(TOAST) $@
356		chmod 755 $@
357
358$(TOAST_INSTALL_BIN)/untoast:	$(TOAST_INSTALL_BIN)/toast
359		-rm $@
360		ln $? $@
361
362$(TOAST_INSTALL_BIN)/tcat:	$(TOAST_INSTALL_BIN)/toast
363		-rm $@
364		ln $? $@
365
366$(TOAST_INSTALL_MAN)/toast.1:	$(MAN)/toast.1
367		-rm $@
368		cp $? $@
369		chmod 444 $@
370
371$(GSM_INSTALL_MAN)/gsm.3:	$(MAN)/gsm.3
372		-rm $@
373		cp $? $@
374		chmod 444 $@
375
376$(GSM_INSTALL_MAN)/gsm_option.3:	$(MAN)/gsm_option.3
377		-rm $@
378		cp $? $@
379		chmod 444 $@
380
381$(GSM_INSTALL_MAN)/gsm_explode.3:	$(MAN)/gsm_explode.3
382		-rm $@
383		cp $? $@
384		chmod 444 $@
385
386$(GSM_INSTALL_MAN)/gsm_print.3:	$(MAN)/gsm_print.3
387		-rm $@
388		cp $? $@
389		chmod 444 $@
390
391$(GSM_INSTALL_INC)/gsm.h:	$(INC)/gsm.h
392		-rm $@
393		cp $? $@
394		chmod 444 $@
395
396$(GSM_INSTALL_LIB)/libgsm.a:	$(LIBGSM)
397		-rm $@
398		cp $? $@
399		chmod 444 $@
400
401
402# Distribution
403
404dist:		gsm-1.0.tar.gz
405		@echo dist: Done.
406
407gsm-1.0.tar.gz:	$(STUFF) $(SOURCES) $(HEADERS) $(MANUALS)
408		(	cd $(ROOT)/..;				\
409			tar cvf - `cat $(ROOT)/gsm-1.0/MANIFEST	\
410				| sed '/^#/d'`			\
411		) | $(COMPRESS) $(COMPRESSFLAGS) > $(ROOT)/gsm-1.0.tar.gz
412
413# Clean
414
415uninstall:	toastuninstall gsmuninstall
416		@-echo uninstall: Done.
417
418semi-clean:
419		-rm $(RMFLAGS)  */*.o			\
420			$(TST)/lin2cod $(TST)/lin2txt	\
421			$(TST)/cod2lin $(TST)/cod2txt	\
422			$(TST)/gsm2cod 			\
423			$(TST)/*.*.*
424		-$(FIND) . \( -name core -o -name foo \) \
425			-print | xargs rm $(RMFLAGS)
426
427clean:	semi-clean
428		-rm $(RMFLAGS) $(LIBGSM) $(ADDTST)/add		\
429			$(TOAST) $(TCAT) $(UNTOAST)	\
430			$(ROOT)/gsm-1.0.tar.Z
431
432
433# Two tools that helped me generate gsm_encode.c and gsm_decode.c,
434# but aren't generally needed to port this.
435
436$(TLS)/sweet:	$(TLS)/sweet.o $(TLS)/taste.o
437		$(LD) $(LFLAGS) -o $(TLS)/sweet \
438			$(TLS)/sweet.o $(TLS)/taste.o $(LDLIB)
439
440$(TLS)/bitter:	$(TLS)/bitter.o $(TLS)/taste.o
441		$(LD) $(LFLAGS) -o $(TLS)/bitter \
442			$(TLS)/bitter.o $(TLS)/taste.o $(LDLIB)
443
444# A version of the same family that Jeff Chilton used to implement
445# the WAV #49 GSM format.
446
447$(TLS)/ginger:	$(TLS)/ginger.o $(TLS)/taste.o
448		$(LD) $(LFLAGS) -o $(TLS)/ginger \
449			$(TLS)/ginger.o $(TLS)/taste.o $(LDLIB)
450
451$(TLS)/sour:	$(TLS)/sour.o $(TLS)/taste.o
452		$(LD) $(LFLAGS) -o $(TLS)/sour \
453			$(TLS)/sour.o $(TLS)/taste.o $(LDLIB)
454
455# Run $(ADDTST)/add < $(ADDTST)/add_test.dta to make sure the
456# basic arithmetic functions work as intended.
457
458$(ADDTST)/add:	$(ADDTST)/add_test.o
459		$(LD) $(LFLAGS) -o $(ADDTST)/add $(ADDTST)/add_test.o $(LDLIB)
460
461
462# Various conversion programs between linear, text, .gsm and the code
463# format used by the tests we ran (.cod).  We paid for the test data,
464# so I guess we can't just provide them with this package.  Still,
465# if you happen to have them lying around, here's the code.
466#
467# You can use gsm2cod | cod2txt independently to look at what's
468# coded inside the compressed frames, although this shouldn't be
469# hard to roll on your own using the gsm_print() function from
470# the API.
471
472
473$(TST)/test-result:	$(TST)/lin2cod $(TST)/cod2lin $(TOAST) $(TST)/run
474			( cd $(TST); ./run )
475
476$(TST)/lin2txt:		$(TST)/lin2txt.o $(LIBGSM)
477			$(LD) $(LFLAGS) -o $(TST)/lin2txt \
478				$(TST)/lin2txt.o $(LIBGSM) $(LDLIB)
479
480$(TST)/lin2cod:		$(TST)/lin2cod.o $(LIBGSM)
481			$(LD) $(LFLAGS) -o $(TST)/lin2cod \
482				$(TST)/lin2cod.o $(LIBGSM) $(LDLIB)
483
484$(TST)/gsm2cod:		$(TST)/gsm2cod.o $(LIBGSM)
485			$(LD) $(LFLAGS) -o $(TST)/gsm2cod \
486				$(TST)/gsm2cod.o $(LIBGSM) $(LDLIB)
487
488$(TST)/cod2txt:		$(TST)/cod2txt.o $(LIBGSM)
489			$(LD) $(LFLAGS) -o $(TST)/cod2txt \
490				$(TST)/cod2txt.o $(LIBGSM) $(LDLIB)
491
492$(TST)/cod2lin:		$(TST)/cod2lin.o $(LIBGSM)
493			$(LD) $(LFLAGS) -o $(TST)/cod2lin \
494				$(TST)/cod2lin.o $(LIBGSM) $(LDLIB)
495