Makefile 11 KB

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