Makefile.draft 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. #################### COMPILE OPTIONS #######################
  2. # Uncomment this for fixed-point build
  3. #FIXED_POINT=1
  4. # It is strongly recommended to uncomment one of these
  5. # VAR_ARRAYS: Use C99 variable-length arrays for stack allocation
  6. # USE_ALLOCA: Use alloca() for stack allocation
  7. # If none is defined, then the fallback is a non-threadsafe global array
  8. CFLAGS += -DUSE_ALLOCA
  9. #CFLAGS += -DVAR_ARRAYS
  10. # These options affect performance
  11. # HAVE_LRINTF: Use C99 intrinsics to speed up float-to-int conversion
  12. # inline: Don't use the 'inline' keyword (for ANSI C compilers)
  13. # restrict: Don't use the 'restrict' keyword (for pre-C99 compilers)
  14. #CFLAGS += -DHAVE_LRINTF
  15. #CFLAGS += -Dinline=
  16. CFLAGS += -Drestrict=
  17. ###################### END OF OPTIONS ######################
  18. CFLAGS += -DOPUS_VERSION='"0.9.6"'
  19. include silk_sources.mk
  20. include celt_sources.mk
  21. include opus_sources.mk
  22. ifdef FIXED_POINT
  23. SILK_SOURCES += $(SILK_SOURCES_FIXED)
  24. else
  25. SILK_SOURCES += $(SILK_SOURCES_FLOAT)
  26. endif
  27. EXESUFFIX =
  28. LIBPREFIX = lib
  29. LIBSUFFIX = .a
  30. OBJSUFFIX = .o
  31. CC = $(TOOLCHAIN_PREFIX)gcc$(TOOLCHAIN_SUFFIX)
  32. CXX = $(TOOLCHAIN_PREFIX)g++$(TOOLCHAIN_SUFFIX)
  33. AR = $(TOOLCHAIN_PREFIX)ar
  34. RANLIB = $(TOOLCHAIN_PREFIX)ranlib
  35. CP = $(TOOLCHAIN_PREFIX)cp
  36. cppflags-from-defines = $(addprefix -D,$(1))
  37. cppflags-from-includes = $(addprefix -I,$(1))
  38. ldflags-from-ldlibdirs = $(addprefix -L,$(1))
  39. ldlibs-from-libs = $(addprefix -l,$(1))
  40. WARNINGS = -Wall -W -Wstrict-prototypes -Wextra -Wcast-align -Wnested-externs -Wshadow
  41. CFLAGS += -O2 -g $(WARNINGS) -DOPUS_BUILD
  42. ifdef FIXED_POINT
  43. CFLAGS += -DFIXED_POINT=1 -DDISABLE_FLOAT_API
  44. endif
  45. CFLAGS += $(call cppflags-from-defines,$(CDEFINES))
  46. CFLAGS += $(call cppflags-from-includes,$(CINCLUDES))
  47. LDFLAGS += $(call ldflags-from-ldlibdirs,$(LDLIBDIRS))
  48. LDLIBS += $(call ldlibs-from-libs,$(LIBS))
  49. COMPILE.c.cmdline = $(CC) -c $(CFLAGS) -o $@ $<
  50. COMPILE.cpp.cmdline = $(CXX) -c $(CFLAGS) -o $@ $<
  51. LINK.o = $(CC) $(LDPREFLAGS) $(LDFLAGS)
  52. LINK.o.cmdline = $(LINK.o) $^ $(LDLIBS) -o $@$(EXESUFFIX)
  53. ARCHIVE.cmdline = $(AR) $(ARFLAGS) $@ $^ && $(RANLIB) $@
  54. %$(OBJSUFFIX):%.c
  55. $(COMPILE.c.cmdline)
  56. %$(OBJSUFFIX):%.cpp
  57. $(COMPILE.cpp.cmdline)
  58. # Directives
  59. CINCLUDES += silk/ \
  60. silk/float/ \
  61. silk/fixed/ \
  62. celt/ \
  63. src/
  64. # VPATH e.g. VPATH = src:../headers
  65. VPATH = ./ \
  66. silk/interface \
  67. silk/src_FIX \
  68. silk/src_FLP \
  69. silk/src_SigProc_FIX \
  70. silk/src_SigProc_FLP \
  71. test
  72. # Variable definitions
  73. LIB_NAME = opus
  74. TARGET = $(LIBPREFIX)$(LIB_NAME)$(LIBSUFFIX)
  75. SRCS_C = $(SILK_SOURCES) $(CELT_SOURCES) $(OPUS_SOURCES)
  76. OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(SRCS_C))
  77. TESTOPUS_SRCS_C = src/test_opus.c
  78. TESTOPUS_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(TESTOPUS_SRCS_C))
  79. OPUSCOMPARE_SRCS_C = src/opus_compare.c
  80. OPUSCOMPARE_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(OPUSCOMPARE_SRCS_C))
  81. LIBS = m
  82. LDLIBDIRS = ./
  83. # Rules
  84. default: all
  85. all: $(TARGET) lib test_opus opus_compare
  86. lib: $(TARGET)
  87. $(TARGET): $(OBJS)
  88. $(ARCHIVE.cmdline)
  89. test_opus$(EXESUFFIX): $(TESTOPUS_OBJS) $(TARGET)
  90. $(LINK.o.cmdline)
  91. opus_compare$(EXESUFFIX): $(OPUSCOMPARE_OBJS)
  92. $(LINK.o.cmdline)
  93. clean:
  94. rm -f test_opus$(EXESUFFIX) opus_compare$(EXESUFFIX) $(TARGET) $(OBJS) $(TESTOPUS_OBJS)