Makefile.mips 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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 $(CFLAGS)
  9. #CFLAGS := -DVAR_ARRAYS $(CFLAGS)
  10. # These options affect performance
  11. # HAVE_LRINTF: Use C99 intrinsics to speed up float-to-int conversion
  12. CFLAGS := -DHAVE_LRINTF $(CFLAGS)
  13. ###################### END OF OPTIONS ######################
  14. -include package_version
  15. include silk_sources.mk
  16. include celt_sources.mk
  17. include opus_sources.mk
  18. ifdef FIXED_POINT
  19. SILK_SOURCES += $(SILK_SOURCES_FIXED)
  20. else
  21. SILK_SOURCES += $(SILK_SOURCES_FLOAT)
  22. OPUS_SOURCES += $(OPUS_SOURCES_FLOAT)
  23. endif
  24. EXESUFFIX =
  25. LIBPREFIX = lib
  26. LIBSUFFIX = .a
  27. OBJSUFFIX = .o
  28. CC = $(TOOLCHAIN_PREFIX)cc$(TOOLCHAIN_SUFFIX)
  29. AR = $(TOOLCHAIN_PREFIX)ar
  30. RANLIB = $(TOOLCHAIN_PREFIX)ranlib
  31. CP = $(TOOLCHAIN_PREFIX)cp
  32. cppflags-from-defines = $(addprefix -D,$(1))
  33. cppflags-from-includes = $(addprefix -I,$(1))
  34. ldflags-from-ldlibdirs = $(addprefix -L,$(1))
  35. ldlibs-from-libs = $(addprefix -l,$(1))
  36. WARNINGS = -Wall -W -Wstrict-prototypes -Wextra -Wcast-align -Wnested-externs -Wshadow
  37. CFLAGS += -mips32r2 -mno-mips16 -std=gnu99 -O2 -g $(WARNINGS) -DENABLE_ASSERTIONS -DMIPSr1_ASM -DOPUS_BUILD -mdspr2 -march=74kc -mtune=74kc -mmt -mgp32
  38. CINCLUDES = include silk celt
  39. ifdef FIXED_POINT
  40. CFLAGS += -DFIXED_POINT=1 -DDISABLE_FLOAT_API
  41. CINCLUDES += silk/fixed
  42. else
  43. CINCLUDES += silk/float
  44. endif
  45. LIBS = m
  46. LDLIBDIRS = ./
  47. CFLAGS += $(call cppflags-from-defines,$(CDEFINES))
  48. CFLAGS += $(call cppflags-from-includes,$(CINCLUDES))
  49. LDFLAGS += $(call ldflags-from-ldlibdirs,$(LDLIBDIRS))
  50. LDLIBS += $(call ldlibs-from-libs,$(LIBS))
  51. COMPILE.c.cmdline = $(CC) -c $(CFLAGS) -o $@ $<
  52. LINK.o = $(CC) $(LDPREFLAGS) $(LDFLAGS)
  53. LINK.o.cmdline = $(LINK.o) $^ $(LDLIBS) -o $@$(EXESUFFIX)
  54. ARCHIVE.cmdline = $(AR) $(ARFLAGS) $@ $^ && $(RANLIB) $@
  55. %$(OBJSUFFIX):%.c
  56. $(COMPILE.c.cmdline)
  57. %$(OBJSUFFIX):%.cpp
  58. $(COMPILE.cpp.cmdline)
  59. # Directives
  60. # Variable definitions
  61. LIB_NAME = opus
  62. TARGET = $(LIBPREFIX)$(LIB_NAME)$(LIBSUFFIX)
  63. SRCS_C = $(SILK_SOURCES) $(CELT_SOURCES) $(OPUS_SOURCES)
  64. OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(SRCS_C))
  65. OPUSDEMO_SRCS_C = src/opus_demo.c
  66. OPUSDEMO_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(OPUSDEMO_SRCS_C))
  67. TESTOPUSAPI_SRCS_C = tests/test_opus_api.c
  68. TESTOPUSAPI_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(TESTOPUSAPI_SRCS_C))
  69. TESTOPUSDECODE_SRCS_C = tests/test_opus_decode.c
  70. TESTOPUSDECODE_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(TESTOPUSDECODE_SRCS_C))
  71. TESTOPUSENCODE_SRCS_C = tests/test_opus_encode.c tests/opus_encode_regressions.c
  72. TESTOPUSENCODE_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(TESTOPUSENCODE_SRCS_C))
  73. TESTOPUSPADDING_SRCS_C = tests/test_opus_padding.c
  74. TESTOPUSPADDING_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(TESTOPUSPADDING_SRCS_C))
  75. OPUSCOMPARE_SRCS_C = src/opus_compare.c
  76. OPUSCOMPARE_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(OPUSCOMPARE_SRCS_C))
  77. TESTS := test_opus_api test_opus_decode test_opus_encode test_opus_padding
  78. # Rules
  79. all: lib opus_demo opus_compare $(TESTS)
  80. lib: $(TARGET)
  81. check: all
  82. for test in $(TESTS); do ./$$test; done
  83. $(TARGET): $(OBJS)
  84. $(ARCHIVE.cmdline)
  85. opus_demo$(EXESUFFIX): $(OPUSDEMO_OBJS) $(TARGET)
  86. $(LINK.o.cmdline)
  87. test_opus_api$(EXESUFFIX): $(TESTOPUSAPI_OBJS) $(TARGET)
  88. $(LINK.o.cmdline)
  89. test_opus_decode$(EXESUFFIX): $(TESTOPUSDECODE_OBJS) $(TARGET)
  90. $(LINK.o.cmdline)
  91. test_opus_encode$(EXESUFFIX): $(TESTOPUSENCODE_OBJS) $(TARGET)
  92. $(LINK.o.cmdline)
  93. test_opus_padding$(EXESUFFIX): $(TESTOPUSPADDING_OBJS) $(TARGET)
  94. $(LINK.o.cmdline)
  95. opus_compare$(EXESUFFIX): $(OPUSCOMPARE_OBJS)
  96. $(LINK.o.cmdline)
  97. celt/celt.o: CFLAGS += -DPACKAGE_VERSION='$(PACKAGE_VERSION)'
  98. celt/celt.o: package_version
  99. package_version: force
  100. @if [ -x ./update_version ]; then \
  101. ./update_version || true; \
  102. elif [ ! -e ./package_version ]; then \
  103. echo 'PACKAGE_VERSION="unknown"' > ./package_version; \
  104. fi
  105. force:
  106. clean:
  107. rm -f opus_demo$(EXESUFFIX) opus_compare$(EXESUFFIX) $(TARGET) \
  108. test_opus_api$(EXESUFFIX) test_opus_decode$(EXESUFFIX) \
  109. test_opus_encode$(EXESUFFIX) test_opus_padding$(EXESUFFIX) \
  110. $(OBJS) $(OPUSDEMO_OBJS) $(OPUSCOMPARE_OBJS) $(TESTOPUSAPI_OBJS) \
  111. $(TESTOPUSDECODE_OBJS) $(TESTOPUSENCODE_OBJS) $(TESTOPUSPADDING_OBJS)
  112. .PHONY: all lib clean force check