Makefile 13 KB

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