a072e6d2dd9e9f6f3d59f9467ec9f4e441222187
[asterisk/asterisk.git] / codecs / gsm / Makefile
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
7 SASR    = -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
19 LTP_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
25 WAV49   = -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 #K6OPT  = -DK6OPT
34 #K6OPT  =
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. 
39
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.
43
44 ifeq ($(shell $(CC) -v 2>&1 | awk '/^gcc version/ { split($$3, v, "."); printf "%s.%s\n", v[1], v[2]; }' ),4.2)
45 OPTIMIZE=-O2
46 endif
47
48 PG =
49 #PG = -g -pg
50 ######### Profiling flags.  If you don't know what that means, leave it blank.
51  
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.
55 #
56 # You can use the -DSTUPID_COMPILER to circumvent some compilers'
57 # static limits regarding the number of subexpressions in a statement.
58
59 # CC            = cc
60 # CCFLAGS       = -c -DSTUPID_COMPILER
61
62 # CC            = /usr/lang/acc
63 # CCFLAGS       = -c -O
64
65 CCFLAGS         += -c -DNeedFunctionPrototypes=1 -funroll-loops $(OPTIMIZE)
66
67 # LD            = gcc
68 # LDFLAGS       =
69
70
71 # If your compiler needs additional flags/libraries, regardless of
72 # the source compiled, configure them here.
73
74 # CCINC = -I/usr/gnu/lib/gcc-2.1/gcc-lib/sparc-sun-sunos4.1.2/2.1/include
75 ######### Includes needed by $(CC)
76
77 # LDINC = -L/usr/gnu/lib/gcc-2.1/gcc-lib/sparc-sun-sunos4.1.2/2.1
78 ######### Library paths needed by $(LD)
79
80 # LDLIB = -lgcc
81 ######### Additional libraries needed by $(LD)
82
83
84 # Where do you want to install libraries, binaries, a header file
85 # and the manual pages?
86 #
87 # Leave INSTALL_ROOT empty (or just don't execute "make install") to
88 # not install gsm and toast outside of this directory.
89
90 INSTALL_ROOT    =
91
92 # Where do you want to install the gsm library, header file, and manpages?
93 #
94 # Leave GSM_INSTALL_ROOT empty to not install the GSM library outside of
95 # this directory.
96
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
101
102
103 # Where do you want to install the toast binaries and their manpage?
104 #
105 # Leave TOAST_INSTALL_ROOT empty to not install the toast binaries outside
106 # of this directory.
107
108 TOAST_INSTALL_ROOT        = $(INSTALL_ROOT)
109 TOAST_INSTALL_BIN = $(TOAST_INSTALL_ROOT)/bin
110 TOAST_INSTALL_MAN = $(TOAST_INSTALL_ROOT)/man/man1
111
112 #  Other tools
113
114 SHELL           = /bin/sh
115 LN              = ln
116 BASENAME        = basename
117 AR              = ar
118 ARFLAGS         = cr
119 RMFLAGS         = -f
120 FIND            = find
121 COMPRESS        = compress
122 COMPRESSFLAGS   = 
123 # RANLIB        = true
124 RANLIB          = ranlib
125
126 #
127 #    You shouldn't have to configure below this line if you're porting.
128
129
130
131 # Local Directories
132
133 ROOT    = .
134 ADDTST  = $(ROOT)/add-test
135 TST     = $(ROOT)/tst
136 MAN     = $(ROOT)/man
137 BIN     = $(ROOT)/bin
138 SRC     = $(ROOT)/src
139 LIB     = $(ROOT)/lib
140 TLS     = $(ROOT)/tls
141 INC     = $(ROOT)/inc
142
143 # Flags
144
145 DEBUG   = -DNDEBUG
146 ######### Remove -DNDEBUG to enable assertions.
147
148 _ASTCFLAGS += $(PG) $(CCFLAGS) $(SASR) $(DEBUG) $(MULHACK) $(FAST) \
149         $(LTP_CUT) $(WAV49) $(K6OPT) $(CCINC) -I$(INC)
150 ######### It's $(CC) $(CFLAGS)
151
152 LFLAGS  = $(PG) $(LDFLAGS) $(LDINC)
153 ######### It's $(LD) $(LFLAGS)
154
155
156 # Targets
157
158 LIBGSM  = $(LIB)/libgsm.a
159 LIBGSMSO= $(LIB)/libgsm.so
160
161 TOAST   = $(BIN)/toast
162 UNTOAST = $(BIN)/untoast
163 TCAT    = $(BIN)/tcat
164
165 # Headers
166
167 GSM_HEADERS =   $(INC)/gsm.h
168
169 HEADERS =       $(INC)/proto.h          \
170                 $(INC)/unproto.h        \
171                 $(INC)/config.h         \
172                 $(INC)/private.h        \
173                 $(INC)/gsm.h            \
174                 $(INC)/toast.h          \
175                 $(TLS)/taste.h
176
177 # Sources
178
179 GSM_SOURCES =   $(SRC)/add.c            \
180                 $(SRC)/code.c           \
181                 $(SRC)/debug.c          \
182                 $(SRC)/decode.c         \
183                 $(SRC)/long_term.c      \
184                 $(SRC)/lpc.c            \
185                 $(SRC)/preprocess.c     \
186                 $(SRC)/rpe.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     \
193                 $(SRC)/gsm_print.c      \
194                 $(SRC)/gsm_option.c     \
195                 $(SRC)/short_term.c     \
196                 $(SRC)/table.c
197
198 TOAST_SOURCES = $(SRC)/toast.c          \
199                 $(SRC)/toast_lin.c      \
200                 $(SRC)/toast_ulaw.c     \
201                 $(SRC)/toast_alaw.c     \
202                 $(SRC)/toast_audio.c
203
204 SOURCES =       $(GSM_SOURCES)          \
205                 $(TOAST_SOURCES)        \
206                 $(ADDTST)/add_test.c    \
207                 $(TLS)/sour.c           \
208                 $(TLS)/ginger.c         \
209                 $(TLS)/sour1.dta        \
210                 $(TLS)/sour2.dta        \
211                 $(TLS)/bitter.c         \
212                 $(TLS)/bitter.dta       \
213                 $(TLS)/taste.c          \
214                 $(TLS)/sweet.c          \
215                 $(TST)/cod2lin.c        \
216                 $(TST)/cod2txt.c        \
217                 $(TST)/gsm2cod.c        \
218                 $(TST)/lin2cod.c        \
219                 $(TST)/lin2txt.c
220
221 # Object files
222
223 GSM_OBJECTS =   $(SRC)/add.o            \
224                 $(SRC)/code.o           \
225                 $(SRC)/debug.o          \
226                 $(SRC)/decode.o         \
227                 $(SRC)/long_term.o      \
228                 $(SRC)/lpc.o            \
229                 $(SRC)/preprocess.o     \
230                 $(SRC)/rpe.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     \
237                 $(SRC)/gsm_print.o      \
238                 $(SRC)/gsm_option.o     \
239                 $(SRC)/short_term.o     \
240                 $(SRC)/table.o
241
242 TOAST_OBJECTS = $(SRC)/toast.o          \
243                 $(SRC)/toast_lin.o      \
244                 $(SRC)/toast_ulaw.o     \
245                 $(SRC)/toast_alaw.o     \
246                 $(SRC)/toast_audio.o
247
248 OBJECTS =        $(GSM_OBJECTS) $(TOAST_OBJECTS)
249
250 # Manuals
251
252 GSM_MANUALS =   $(MAN)/gsm.3            \
253                 $(MAN)/gsm_explode.3    \
254                 $(MAN)/gsm_option.3     \
255                 $(MAN)/gsm_print.3
256
257 TOAST_MANUALS = $(MAN)/toast.1
258
259 MANUALS =       $(GSM_MANUALS) $(TOAST_MANUALS) $(MAN)/bitter.1
260
261 # Other stuff in the distribution
262
263 STUFF =         ChangeLog                       \
264                 INSTALL                 \
265                 MACHINES                \
266                 MANIFEST                \
267                 Makefile                \
268                 README                  \
269                 $(ADDTST)/add_test.dta  \
270                 $(TLS)/bitter.dta       \
271                 $(TST)/run
272
273
274 # Install targets
275
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
283
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
289
290
291 # Default rules
292
293 include $(ASTTOPDIR)/Makefile.rules
294
295 # Target rules
296
297 all:            $(LIBGSM) $(LIBGSMSO) $(TOAST) $(TCAT) $(UNTOAST)
298                 @-echo $(ROOT): Done.
299
300 tst:            $(TST)/lin2cod $(TST)/cod2lin $(TOAST) $(TST)/test-result
301                 @-echo tst: Done.
302
303 addtst:         $(ADDTST)/add $(ADDTST)/add_test.dta
304                 $(ADDTST)/add < $(ADDTST)/add_test.dta > /dev/null
305                 @-echo addtst: Done.
306
307 misc:           $(TLS)/sweet $(TLS)/bitter $(TLS)/sour $(TLS)/ginger    \
308                         $(TST)/lin2txt $(TST)/cod2txt $(TST)/gsm2cod
309                 @-echo misc: Done.
310
311 install:        toastinstall gsminstall
312                 @-echo install: Done.
313
314
315 # The basic API: libgsm
316
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
321
322 $(LIBGSM): $(GSM_OBJECTS)
323         $(ECHO_PREFIX) echo "   [AR] $^ -> $@"
324         $(CMD_PREFIX) $(AR) cr $@ $^
325         $(CMD_PREFIX) $(RANLIB) $@
326
327
328 # Toast, Untoast and Tcat -- the compress-like frontends to gsm.
329
330 $(TOAST):       $(BIN) $(TOAST_OBJECTS) $(LIBGSM)
331                 $(LD) $(LFLAGS) -o $(TOAST) $(TOAST_OBJECTS) $(LIBGSMSO) $(LDLIB)
332
333 $(UNTOAST):     $(BIN) $(TOAST)
334                 -rm $(RMFLAGS) $(UNTOAST)
335                 $(LN) toast $(UNTOAST)
336
337 $(TCAT):        $(BIN) $(TOAST)
338                 -rm $(RMFLAGS) $(TCAT)
339                 $(LN) toast $(TCAT)
340
341
342 # The local bin and lib directories
343
344 $(BIN):
345                 if [ ! -d $(BIN) ] ; then mkdir $(BIN) ; fi
346
347 $(LIB):
348                 if [ ! -d $(LIB) ] ; then mkdir $(LIB) ; fi
349
350
351 # Installation
352
353 gsminstall:
354                 -if [ x"$(GSM_INSTALL_ROOT)" != x ] ; then      \
355                         $(MAKE) $(GSM_INSTALL_TARGETS) ;        \
356                 fi
357
358 toastinstall:
359                 -if [ x"$(TOAST_INSTALL_ROOT)" != x ]; then     \
360                         $(MAKE) $(TOAST_INSTALL_TARGETS);       \
361                 fi
362
363 gsmuninstall:
364                 -if [ x"$(GSM_INSTALL_ROOT)" != x ] ; then      \
365                         rm $(RMFLAGS) $(GSM_INSTALL_TARGETS) ;  \
366                 fi
367
368 toastuninstall:
369                 -if [ x"$(TOAST_INSTALL_ROOT)" != x ] ; then    \
370                         rm $(RMFLAGS) $(TOAST_INSTALL_TARGETS); \
371                 fi
372
373 $(TOAST_INSTALL_BIN)/toast:     $(TOAST)
374                 -rm $@
375                 cp $(TOAST) $@
376                 chmod 755 $@
377
378 $(TOAST_INSTALL_BIN)/untoast:   $(TOAST_INSTALL_BIN)/toast
379                 -rm $@
380                 ln $? $@
381
382 $(TOAST_INSTALL_BIN)/tcat:      $(TOAST_INSTALL_BIN)/toast
383                 -rm $@
384                 ln $? $@
385
386 $(TOAST_INSTALL_MAN)/toast.1:   $(MAN)/toast.1
387                 -rm $@
388                 cp $? $@
389                 chmod 444 $@
390
391 $(GSM_INSTALL_MAN)/gsm.3:       $(MAN)/gsm.3
392                 -rm $@
393                 cp $? $@
394                 chmod 444 $@
395
396 $(GSM_INSTALL_MAN)/gsm_option.3:        $(MAN)/gsm_option.3
397                 -rm $@
398                 cp $? $@
399                 chmod 444 $@
400
401 $(GSM_INSTALL_MAN)/gsm_explode.3:       $(MAN)/gsm_explode.3
402                 -rm $@
403                 cp $? $@
404                 chmod 444 $@
405
406 $(GSM_INSTALL_MAN)/gsm_print.3: $(MAN)/gsm_print.3
407                 -rm $@
408                 cp $? $@
409                 chmod 444 $@
410
411 $(GSM_INSTALL_INC)/gsm.h:       $(INC)/gsm.h
412                 -rm $@
413                 cp $? $@
414                 chmod 444 $@
415
416 $(GSM_INSTALL_LIB)/libgsm.a:    $(LIBGSM)
417                 -rm $@
418                 cp $? $@
419                 chmod 444 $@
420
421
422 # Distribution
423
424 dist:           gsm-1.0.tar.Z
425                 @echo dist: Done.
426
427 gsm-1.0.tar.Z:  $(STUFF) $(SOURCES) $(HEADERS) $(MANUALS)
428                 (       cd $(ROOT)/..;                          \
429                         tar cvf - `cat $(ROOT)/gsm-1.0/MANIFEST \
430                                 | sed '/^#/d'`                  \
431                 ) | $(COMPRESS) $(COMPRESSFLAGS) > $(ROOT)/gsm-1.0.tar.Z
432
433 # Clean
434
435 uninstall:      toastuninstall gsmuninstall
436                 @-echo uninstall: Done.
437
438 semi-clean:
439                 -rm $(RMFLAGS)  */*.o                   \
440                         $(TST)/lin2cod $(TST)/lin2txt   \
441                         $(TST)/cod2lin $(TST)/cod2txt   \
442                         $(TST)/gsm2cod                  \
443                         $(TST)/*.*.*
444                 -$(FIND) . \( -name core -o -name foo \) \
445                         -print | xargs rm $(RMFLAGS)
446
447 clean:  semi-clean
448                 -rm $(RMFLAGS) $(LIBGSM) $(ADDTST)/add          \
449                         $(TOAST) $(TCAT) $(UNTOAST)     \
450                         $(ROOT)/gsm-1.0.tar.Z
451                 rm -rf lib
452                 rm -f .*.d *.i */*.i
453
454 # Two tools that helped me generate gsm_encode.c and gsm_decode.c,
455 # but aren't generally needed to port this.
456
457 $(TLS)/sweet:   $(TLS)/sweet.o $(TLS)/taste.o
458                 $(LD) $(LFLAGS) -o $(TLS)/sweet \
459                         $(TLS)/sweet.o $(TLS)/taste.o $(LDLIB)
460
461 $(TLS)/bitter:  $(TLS)/bitter.o $(TLS)/taste.o
462                 $(LD) $(LFLAGS) -o $(TLS)/bitter \
463                         $(TLS)/bitter.o $(TLS)/taste.o $(LDLIB)
464
465 # A version of the same family that Jeff Chilton used to implement
466 # the WAV #49 GSM format.
467
468 $(TLS)/ginger:  $(TLS)/ginger.o $(TLS)/taste.o
469                 $(LD) $(LFLAGS) -o $(TLS)/ginger \
470                         $(TLS)/ginger.o $(TLS)/taste.o $(LDLIB)
471
472 $(TLS)/sour:    $(TLS)/sour.o $(TLS)/taste.o
473                 $(LD) $(LFLAGS) -o $(TLS)/sour \
474                         $(TLS)/sour.o $(TLS)/taste.o $(LDLIB)
475
476 # Run $(ADDTST)/add < $(ADDTST)/add_test.dta to make sure the
477 # basic arithmetic functions work as intended.
478
479 $(ADDTST)/add:  $(ADDTST)/add_test.o
480                 $(LD) $(LFLAGS) -o $(ADDTST)/add $(ADDTST)/add_test.o $(LDLIB)
481
482
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.
487
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
491 # the API.
492
493
494 $(TST)/test-result:     $(TST)/lin2cod $(TST)/cod2lin $(TOAST) $(TST)/run
495                         ( cd $(TST); ./run ) 
496
497 $(TST)/lin2txt:         $(TST)/lin2txt.o $(LIBGSM)
498                         $(LD) $(LFLAGS) -o $(TST)/lin2txt \
499                                 $(TST)/lin2txt.o $(LIBGSM) $(LDLIB)
500
501 $(TST)/lin2cod:         $(TST)/lin2cod.o $(LIBGSM)
502                         $(LD) $(LFLAGS) -o $(TST)/lin2cod \
503                                 $(TST)/lin2cod.o $(LIBGSM) $(LDLIB)
504
505 $(TST)/gsm2cod:         $(TST)/gsm2cod.o $(LIBGSM)
506                         $(LD) $(LFLAGS) -o $(TST)/gsm2cod \
507                                 $(TST)/gsm2cod.o $(LIBGSM) $(LDLIB)
508
509 $(TST)/cod2txt:         $(TST)/cod2txt.o $(LIBGSM)
510                         $(LD) $(LFLAGS) -o $(TST)/cod2txt \
511                                 $(TST)/cod2txt.o $(LIBGSM) $(LDLIB)
512
513 $(TST)/cod2lin:         $(TST)/cod2lin.o $(LIBGSM)
514                         $(LD) $(LFLAGS) -o $(TST)/cod2lin \
515                                 $(TST)/cod2lin.o $(LIBGSM) $(LDLIB)