home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 13 / AACD13.ISO / AACD / Sound / LAME / src / Makefile < prev    next >
Makefile  |  2000-08-17  |  15KB  |  506 lines

  1. # Makefile for LAME 3.xx
  2. #
  3. # LAME is reported to work under:  
  4. # Linux (i86), NetBSD 1.3.2 (StrongARM), FreeBSD (i86)
  5. # Compaq Alpha(OSF, Linux, Tru64 Unix), Sun Solaris, SGI IRIX,
  6. # OS2 Warp, Macintosh PPC, BeOS, Amiga and even VC++ 
  7.  
  8. # these variables are available on command line:
  9. #
  10. #   make NOUNIXCMD=YES            - don't use unix commands
  11. #   make UNAME=xxxxx ARCH=xxxxx   - specify a type of host
  12. #   make PGM=lame_exp             - specify a name of an executable file
  13. #
  14. # if you have mingw32-gcc, try:
  15. #   make NOUNIXCMD=YES UNAME=MSDOS
  16. #
  17.  
  18.  
  19. ifeq ($(NOUNIXCMD),YES)
  20.   UNAME ?= UNKNOWN
  21.   ARCH ?= UNKNOWN_ARCH
  22. else
  23.   UNAME = $(shell uname)
  24.   ARCH = $(shell uname -m)
  25. endif
  26.  
  27. # generic defaults. OS specific options go in versious sections below
  28. PGM ?= lame
  29. CC = gcc
  30. CC_OPTS =  -O
  31. GTK = 
  32. GTKLIBS = 
  33. SNDLIB = -DLAMESNDFILE
  34. LIBSNDFILE =  
  35. LIBS = -lm 
  36. MAKEDEP = -M
  37. BRHIST_SWITCH = 
  38. LIBTERMCAP = 
  39. RM = rm -f
  40. AR = ar
  41. RANLIB = ranlib
  42.  
  43.  
  44. ##########################################################################
  45. # -DHAVEMPGLIB compiles the mpglib *decoding* library into libmp3lame
  46. ##########################################################################
  47. CPP_OPTS += -DHAVEMPGLIB 
  48.  
  49. ##########################################################################
  50. # floating point option:
  51. # -DFLOAT8_is_float         most floating point variables are 4 byte
  52. # -DFLOAT8_is_double        most floating point variables are 8 byte (default)
  53. # NOTE: RH: 7/00:  if FLOAT8=float, it breaks resampling and VBR code 
  54. ##########################################################################
  55. #CPP_OPTS += -DFLOAT8_is_double
  56.  
  57.  
  58.  
  59. ##########################################################################
  60. # Define these in the OS specific sections below to compile in support
  61. # for the Ogg Vorbis audio format (both decoding and encoding)
  62. # VORBIS = -DHAVEVORBIS  -I ../vorbis/include
  63. # VORBIS_LIB = -L ../vorbis/lib -lvorbis
  64. ##########################################################################
  65.  
  66. ##########################################################################
  67. # Define these in the OS specific sections below to compile in code 
  68. # for the optional VBR bitrate histogram.  
  69. # Requires ncurses, but libtermcap also works.  
  70. # If you have any trouble, just dont define these
  71. #
  72. # BRHIST_SWITCH = -DBRHIST
  73. # LIBTERMCAP = -lncurses
  74. # LIBTERMCAP = -ltermcap
  75. #
  76. # or, to try and simulate TERMCAP (ANSI), use:
  77. # BRHIST_SWITCH = -DBRHIST -DNOTERMCAP
  78. #
  79. ##########################################################################
  80.  
  81.  
  82. ##########################################################################
  83. # Define these in the OS specific sections below to compile in code for:
  84. #
  85. # SNDLIB =                no file i/o 
  86. # SNDLIB = -DLAMESNDFILE  to use internal LAME soundfile routines 
  87. # SNDLIB = -DLIBSNDFILE   to use Erik de Castro Lopo's libsndfile 
  88. # http://www.zip.com.au/~erikd/libsndfile/
  89. #
  90. # Note: at present, libsndfile does not support input from stdin.  
  91. #
  92. # for example:
  93. #  SNDLIB = -DLIBSNDFILE
  94. #  LIBSNDFILE=-lsndfile 
  95. #  if libsndfile is in a custom location, try:
  96. #  LIBSNDFILE=-L $(LIBSNDHOME) -lsndfile  -I $(LIBSNDHOME)
  97. ##########################################################################
  98.  
  99.  
  100. ##########################################################################
  101. # Define these in the OS specific sections below to compile in code for
  102. # the GTK mp3 frame analyzer
  103. #
  104. # Requires  -DHAVEMPGLIB
  105. # and SNDLIB = -DLAME or -DLIBSNDFILE
  106. #
  107. # GTK = -DHAVEGTK `gtk-config --cflags`
  108. # GTKLIBS = `gtk-config --libs` 
  109. #
  110. ##########################################################################
  111.  
  112.  
  113.  
  114.  
  115. ##########################################################################
  116. # LINUX   
  117. ##########################################################################
  118. ifeq ($(UNAME),Linux)
  119. #  remove these lines if you dont have GTK, or dont want the GTK frame analyzer
  120.    GTK = -DHAVEGTK `gtk-config --cflags`
  121.    GTKLIBS = `gtk-config --libs` 
  122. # Comment out next 2 lines if you want to remove VBR histogram capability
  123.    BRHIST_SWITCH = -DBRHIST
  124.    LIBTERMCAP = -lncurses
  125. #  uncomment to use LIBSNDFILE
  126. #   SNDLIB = -DLIBSNDFILE
  127. #   LIBSNDFILE=-lsndfile 
  128.  
  129. # uncomment to compile in Vorbis support
  130. #   VORBIS = -DHAVEVORBIS -I/home/mt/mp3/vorbis/include
  131. #   VORBIS_LIB = -L/home/mt/mp3/vorbis/lib -lvorbis
  132.  
  133.  
  134. # suggested for gcc-2.7.x
  135.    CC_OPTS =  -O3 -fomit-frame-pointer -funroll-loops -ffast-math  -finline-functions -Wall
  136. #  CC_OPTS =  -O9 -fomit-frame-pointer -fno-strength-reduce -mpentiumpro -ffast-math -finline-functions -funroll-loops -Wall -malign-double -g -march=pentiumpro -mfancy-math-387 -pipe 
  137.  
  138. #  for debugging:
  139. #   CC_OPTS =  -UNDEBUG -O -Wall -g -DABORTFP
  140.  
  141. #  for lots of debugging:
  142. #   CC_OPTS =  -DDEBUG -UNDEBUG  -O -Wall -g -DABORTFP 
  143.  
  144.  
  145. #  special noise calculation
  146. #   FEATURES = -DRH_NOISE_CALC
  147. # these options for gcc-2.95.2 to produce fast code
  148. #   CC_OPTS = $(FEATURES)\
  149. #    -Wall -O9 -fomit-frame-pointer -march=pentium \
  150. #    -finline-functions -fexpensive-optimizations \
  151. #    -funroll-loops -funroll-all-loops -pipe -fschedule-insns2 \
  152. #    -fstrength-reduce \
  153. #    -malign-double -mfancy-math-387 -ffast-math 
  154.  
  155.  
  156. ##########################################################################
  157. # LINUX on Digital/Compaq Alpha CPUs
  158. ##########################################################################
  159. ifeq ($(ARCH),alpha)
  160.  
  161. ################################################################
  162. #### Check if 'ccc' is in our path
  163. ####   if not, use 'gcc'
  164. ################################################################
  165. ifeq ($(shell which ccc 2>/dev/null | grep -c ccc),0)
  166.  
  167. # double is faster than float on Alpha
  168. CC_OPTS =       -O4 -Wall -fomit-frame-pointer -ffast-math -funroll-loops \
  169.                 -mfp-regs -fschedule-insns -fschedule-insns2 \
  170.                 -finline-functions \
  171. #                -DFLOAT=double
  172. # add "-mcpu=21164a -Wa,-m21164a" to optimize for 21164a (ev56) CPU
  173.  
  174. ################################################################
  175. #### else, use 'ccc'
  176. ################################################################
  177. else
  178.  
  179. # Compaq's C Compiler
  180. CC = ccc
  181.  
  182. ################################################################
  183. #### set 'CC_OPTS = -arch host -tune host' to generate/tune instructions for 
  184. this machine
  185. ####     'CC_OPTS += -migrate -fast -inline speed -unroll 0' tweak to run as 
  186. fast as possible :)
  187. ####     'CC_OPTS += -w0 -Wall' set warning and linking flags
  188. ################################################################
  189. CC_OPTS = -arch host -tune host
  190. CC_OPTS += -migrate -fast -inline speed -unroll 0
  191. CC_OPTS += -w0 -Wall
  192.  
  193.  
  194. ################################################################
  195. #### to debug, uncomment
  196. ################################################################
  197. # For Debugging
  198. #CC_OPTS += -g3
  199.  
  200. ################################################################
  201. #### define __DECALPHA__ (i was getting re-declaration warnings
  202. ####   in machine.h
  203. ################################################################
  204. # Define DEC Alpha
  205. CPP_OPTS += -D__DECALPHA__
  206.  
  207. # standard Linux libm
  208. #LIBS    =    -lm
  209. # optimized libffm (free fast math library)
  210. #LIBS    =    -lffm
  211. # Compaq's fast math library
  212. LIBS    =       -lcpml
  213. endif  #  gcc or ccc?
  214. endif  #  alpha 
  215. endif  #  linux
  216.  
  217.  
  218.  
  219. ##########################################################################
  220. # FreeBSD
  221. ##########################################################################
  222. ifeq ($(UNAME),FreeBSD)
  223. #  remove if you do not have GTK or do not want the GTK frame analyzer
  224.    GTK = -DHAVEGTK `gtk12-config --cflags`
  225.    GTKLIBS = `gtk12-config --libs` 
  226. # Comment out next 2 lines if you want to remove VBR histogram capability
  227.    BRHIST_SWITCH = -DBRHIST
  228.    LIBTERMCAP = -lncurses
  229.  
  230. endif
  231.  
  232. ##########################################################################
  233. # OpenBSD
  234. ##########################################################################
  235. ifeq ($(UNAME),OpenBSD)
  236. #  remove if you do not have GTK or do not want the GTK frame analyzer
  237.    GTK = -DHAVEGTK `gtk12-config --cflags`
  238.    GTKLIBS = `gtk12-config --libs` 
  239. # Comment out next 2 lines if you want to remove VBR histogram capability
  240.    BRHIST_SWITCH = -DBRHIST
  241.    LIBTERMCAP = -lncurses
  242. endif
  243.  
  244.  
  245. ##########################################################################
  246. # SunOS
  247. ##########################################################################
  248. ifeq ($(UNAME),SunOS) 
  249.    CC = cc
  250.    CC_OPTS = -O -xCC      
  251.    MAKEDEP = -xM
  252. endif
  253.  
  254.  
  255. ##########################################################################
  256. # SGI
  257. ##########################################################################
  258. ifeq ($(UNAME),IRIX64) 
  259.    CC = cc
  260.    CC_OPTS = -O3 -woff all 
  261.  
  262. #optonal:
  263. #   GTK = -DHAVEGTK `gtk-config --cflags`
  264. #   GTKLIBS = `gtk-config --libs`
  265. #   BRHIST_SWITCH = -DBRHIST
  266. #   LIBTERMCAP = -lncurses
  267.  
  268. endif
  269. ifeq ($(UNAME),IRIX) 
  270.    CC = cc
  271.    CC_OPTS = -O3 -woff all 
  272. endif
  273.  
  274.  
  275.  
  276. ##########################################################################
  277. # Compaq Alpha running Dec Unix (OSF)
  278. ##########################################################################
  279. ifeq ($(UNAME),OSF1)
  280.    CC = cc
  281.    CC_OPTS = -fast -O3 -std -g3 -non_shared
  282. endif
  283.  
  284. ##########################################################################
  285. # BeOS
  286. ##########################################################################
  287. ifeq ($(UNAME),BeOS)
  288.    CC = $(BE_C_COMPILER)
  289.    LIBS =
  290. ifeq ($(ARCH),BePC)
  291.    CC_OPTS = -O9 -fomit-frame-pointer -march=pentium \
  292.    -mcpu=pentium -ffast-math -funroll-loops \
  293.    -fprofile-arcs -fbranch-probabilities
  294. else
  295.    CC_OPTS = -opt all
  296.    MAKEDEP = -make
  297. endif
  298. endif
  299.  
  300. ###########################################################################
  301. # MOSXS (Rhapsody PPC)
  302. ###########################################################################
  303. ifeq ($(UNAME),Rhapsody)
  304.    CC = cc
  305.    LIBS =
  306.    CC_OPTS = -O9 -ffast-math -funroll-loops -fomit-frame-pointer
  307.    MAKEDEP = -make 
  308.    
  309. endif
  310. ##########################################################################
  311. # OS/2
  312. ##########################################################################
  313. # Properly installed EMX runtime & development package is a prerequisite.
  314. # tools I used: make 3.76.1, uname 1.12, sed 2.05, PD-ksh 5.2.13
  315. #
  316. ##########################################################################
  317. ifeq ($(UNAME),OS/2)
  318.    SHELL=sh    
  319.    CC = gcc
  320.    CC_OPTS = -O3
  321.    PGM ?= lame.exe
  322.    LIBS =
  323.  
  324. # I use the following for slightly better performance on my Pentium-II
  325. # using pgcc-2.91.66:
  326. #   CC_OPTS = -O6 -ffast-math -funroll-loops -mpentiumpro -march=pentiumpro
  327.  
  328. # Comment out next 2 lines if you want to remove VBR histogram capability
  329.    BRHIST_SWITCH = -DBRHIST
  330.    LIBTERMCAP = -ltermcap
  331.  
  332. # Uncomment & inspect the 2 GTK lines to use MP3x GTK frame analyzer.
  333. # Properly installed XFree86/devlibs & GTK+ is a prerequisite.
  334. # The following works for me using Xfree86/OS2 3.3.5 and GTK+ 1.2.3:
  335. #   GTK = -DHAVEGTK -IC:/XFree86/include/gtk12 -Zmt -D__ST_MT_ERRNO__ -IC:/XFree86/include/glib12 -IC:/XFree86/include
  336. #   GTKLIBS = -LC:/XFree86/lib -Zmtd -Zsysv-signals -Zbin-files -lgtk12 -lgdk12 -lgmodule -lglib12 -lXext -lX11 -lshm -lbsd -lsocket -lm
  337. endif
  338.  
  339. ###########################################################################
  340. # MSDOS/Windows
  341. ###########################################################################
  342. ifeq ($(UNAME),MSDOS)
  343.   RM =
  344.   PGM ?= lame.exe
  345. endif
  346.  
  347. ###########################################################################
  348. # AmigaOS
  349. ###########################################################################
  350. # Type 'Make ARCH=PPC' for PowerUP and 'Make ARCH=WOS' for WarpOS
  351. #
  352. ###########################################################################
  353. ifeq ($(UNAME),AmigaOS)
  354.     CC = gcc -noixemul
  355.     CC_OPTS = -O3 -ffast-math -funroll-loops -m68020-60 -m68881
  356.     BRHIST_SWITCH = -DBRHIST -DNOTERMCAP
  357.     MAKEDEP = -MM
  358.     ifeq ($(ARCH),WOS)
  359.         CC = ppc-amigaos-gcc -warpup
  360.         CC_OPTS = -O3 -ffast-math -fomit-frame-pointer -funroll-loops \
  361.         -mmultiple -mcpu=603e
  362.         AR = ppc-amigaos-ar
  363.         RANLIB = ppc-amigaos-ranlib
  364.         LIBS =
  365.     endif
  366.     ifeq ($(ARCH),PPC)
  367.         CC = ppc-amigaos-gcc
  368.         CC_OPTS = -O3 -ffast-math -fomit-frame-pointer -funroll-loops \
  369.         -mmultiple -mcpu=603e
  370.         AR = ppc-amigaos-ar
  371.         RANLIB = ppc-amigaos-ranlib
  372.         LIBS =
  373.     endif
  374. endif
  375.  
  376. # 10/99 added -D__NO_MATH_INLINES to fix a bug in *all* versions of
  377. # gcc 2.8+ as of 10/99.  
  378.  
  379. CC_SWITCHES = -DNDEBUG -D__NO_MATH_INLINES $(CC_OPTS) $(SNDLIB) $(GTK) \
  380. $(BRHIST_SWITCH) $(VORBIS) 
  381. c_sources_s = \
  382.         brhist.c \
  383.     bitstream.c \
  384.     fft.c \
  385.     get_audio.c \
  386.         id3tag.c \
  387.     ieeefloat.c \
  388.         lame.c \
  389.         newmdct.c \
  390.         parse.c \
  391.     portableio.c \
  392.     psymodel.c \
  393.     quantize.c \
  394.     quantize-pvt.c \
  395.     vbrquantize.c \
  396.     reservoir.c \
  397.     tables.c \
  398.     takehiro.c \
  399.     timestatus.c \
  400.     util.c \
  401.     vorbis_interface.c \
  402.         VbrTag.c \
  403.         version.c \
  404.         mpglib/common.c \
  405.         mpglib/dct64_i386.c \
  406.         mpglib/decode_i386.c \
  407.         mpglib/layer3.c \
  408.         mpglib/tabinit.c \
  409.         mpglib/interface.c \
  410.         mpglib/main.c 
  411.  
  412. ifeq ($(UNAME),MSDOS)
  413.   c_sources = $(subst /,\\,$(c_sources_s))
  414. else
  415.   c_sources = $(c_sources_s)
  416. endif
  417.  
  418. OBJ = $(c_sources:.c=.o)
  419. DEP = $(c_sources:.c=.d)
  420.  
  421. gtk_sources = gtkanal.c gpkplotting.c
  422. gtk_obj = $(gtk_sources:.c=.o)
  423. gtk_dep = $(gtk_sources:.c=.d)
  424.  
  425.  
  426.  
  427. NASM = nasm
  428. ASFLAGS=-f elf -i i386/
  429. %.o: %.nas
  430.     $(NASM) $(ASFLAGS) $< -o $@
  431. %.o: %.s
  432.     gcc -c $< -o $@
  433.  
  434. ## use MMX extension. you need nasm and MMX supported CPU.
  435. #CC_SWITCHES += -DMMX_choose_table
  436. #OBJ += i386/choose_table.o
  437.  
  438. %.o: %.c 
  439.     $(CC) $(CPP_OPTS) $(CC_SWITCHES) -c $< -o $@
  440.  
  441. %.d: %.c
  442.   ifeq ($(NOUNIXCMD),YES)
  443.     $(CC) $(MAKEDEP)  $(CPP_OPTS) $(CC_SWITCHES)  $< > $@
  444.   else
  445.     $(SHELL) -ec '$(CC) $(MAKEDEP)  $(CPP_OPTS) $(CC_SWITCHES)  $< | sed '\''s;$*.o;& $@;g'\'' > $@'
  446.   endif
  447.  
  448. all: $(PGM)
  449.  
  450. $(PGM):    main.o $(gtk_obj) new_clock.o libmp3lame.a 
  451.     $(CC) $(CC_OPTS) -o $(PGM)  main.o $(gtk_obj) new_clock.o -L. -lmp3lame $(LIBS) $(LIBSNDFILE) $(GTKLIBS) $(LIBTERMCAP) $(VORBIS_LIB)
  452.  
  453. mp3x:    mp3x.o $(gtk_obj) libmp3lame.a
  454.     $(CC) -o mp3x mp3x.o $(gtk_obj) $(OBJ) $(LIBS) $(LIBSNDFILE) $(GTKLIBS) $(LIBTERMCAP) $(VORBIS_LIB)
  455.  
  456. mp3rtp:    rtp.o mp3rtp.o libmp3lame.a
  457.     $(CC) -o mp3rtp mp3rtp.o rtp.o   $(OBJ) $(LIBS) $(LIBSNDFILE) $(GTKLIBS) $(LIBTERMCAP) $(VORBIS_LIB)
  458.  
  459. libmp3lame.a:  $(OBJ) Makefile
  460. #    cd libmp3lame
  461. #    make libmp3lame
  462.     $(AR) cr libmp3lame.a  $(OBJ) 
  463.     $(RANLIB) libmp3lame.a
  464.  
  465. clean:
  466.   ifeq ($(UNAME),MSDOS)
  467.     -del *.o
  468.     -del *.d
  469.     -del *.a
  470.     -del mpglib\*.o
  471.     -del mpglib\*.d
  472.     -del $(PGM)
  473.   else
  474.     -$(RM) $(gtk_obj) $(OBJ) $(DEP) $(PGM) main.o rtp.o mp3rtp mp3rtp.o \
  475.          mp3x.o mp3x libmp3lame.a 
  476.   endif
  477.  
  478.  
  479. tags: TAGS
  480.  
  481. TAGS: ${c_sources}
  482.     etags -T ${c_sources}
  483.  
  484. ifneq ($(MAKECMDGOALS),clean)
  485.   -include $(DEP)
  486. endif
  487.  
  488.  
  489. #
  490. #  testcase.mp3 is a 2926 byte file.  The first number output by
  491. #  wc is the number of bytes which differ between new output
  492. #  and 'official' results.  
  493. #
  494. #  Because of compilier options and effects of roundoff, the 
  495. #  number of bytes which are different may not be zero, but
  496. #  should be at most 30.
  497. #
  498. test: $(PGM)
  499.     ./lame  --nores -h testcase.wav testcase.new.mp3
  500.     cmp -l testcase.new.mp3 testcase.mp3 | wc
  501.  
  502. testg: $(PGM)
  503.     ./lame -g -h ../test/castanets.wav
  504.