Makefile 14 KB

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