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