Makefile 12 KB

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