1 #################### COMPILE OPTIONS ####################### 2 3 # Uncomment this for fixed-point build 4 #FIXED_POINT=1 5 6 # It is strongly recommended to uncomment one of these 7 # VAR_ARRAYS: Use C99 variable-length arrays for stack allocation 8 # USE_ALLOCA: Use alloca() for stack allocation 9 # If none is defined, then the fallback is a non-threadsafe global array 10 CFLAGS := -DUSE_ALLOCA $(CFLAGS) 11 #CFLAGS := -DVAR_ARRAYS $(CFLAGS) 12 13 # These options affect performance 14 # HAVE_LRINTF: Use C99 intrinsics to speed up float-to-int conversion 15 #CFLAGS := -DHAVE_LRINTF $(CFLAGS) 16 17 ###################### END OF OPTIONS ###################### 18 19 -include package_version 20 21 include silk_sources.mk 22 include celt_sources.mk 23 include opus_sources.mk 24 25 ifdef FIXED_POINT 26 SILK_SOURCES += $(SILK_SOURCES_FIXED) 27 else 28 SILK_SOURCES += $(SILK_SOURCES_FLOAT) 29 OPUS_SOURCES += $(OPUS_SOURCES_FLOAT) 30 endif 31 32 EXESUFFIX = 33 LIBPREFIX = lib 34 LIBSUFFIX = .a 35 OBJSUFFIX = .o 36 37 CC = $(TOOLCHAIN_PREFIX)cc$(TOOLCHAIN_SUFFIX) 38 AR = $(TOOLCHAIN_PREFIX)ar 39 RANLIB = $(TOOLCHAIN_PREFIX)ranlib 40 CP = $(TOOLCHAIN_PREFIX)cp 41 42 cppflags-from-defines = $(addprefix -D,$(1)) 43 cppflags-from-includes = $(addprefix -I,$(1)) 44 ldflags-from-ldlibdirs = $(addprefix -L,$(1)) 45 ldlibs-from-libs = $(addprefix -l,$(1)) 46 47 WARNINGS = -Wall -W -Wstrict-prototypes -Wextra -Wcast-align -Wnested-externs -Wshadow 48 CFLAGS += -O2 -g $(WARNINGS) -DOPUS_BUILD 49 CINCLUDES = include silk celt 50 51 ifdef FIXED_POINT 52 CFLAGS += -DFIXED_POINT=1 -DDISABLE_FLOAT_API 53 CINCLUDES += silk/fixed 54 else 55 CINCLUDES += silk/float 56 endif 57 58 59 LIBS = m 60 61 LDLIBDIRS = ./ 62 63 CFLAGS += $(call cppflags-from-defines,$(CDEFINES)) 64 CFLAGS += $(call cppflags-from-includes,$(CINCLUDES)) 65 LDFLAGS += $(call ldflags-from-ldlibdirs,$(LDLIBDIRS)) 66 LDLIBS += $(call ldlibs-from-libs,$(LIBS)) 67 68 COMPILE.c.cmdline = $(CC) -c $(CFLAGS) -o $@ $< 69 LINK.o = $(CC) $(LDPREFLAGS) $(LDFLAGS) 70 LINK.o.cmdline = $(LINK.o) $^ $(LDLIBS) -o $@$(EXESUFFIX) 71 72 ARCHIVE.cmdline = $(AR) $(ARFLAGS) $@ $^ && $(RANLIB) $@ 73 74 %$(OBJSUFFIX):%.c 75 $(COMPILE.c.cmdline) 76 77 %$(OBJSUFFIX):%.cpp 78 $(COMPILE.cpp.cmdline) 79 80 # Directives 81 82 83 # Variable definitions 84 LIB_NAME = opus 85 TARGET = $(LIBPREFIX)$(LIB_NAME)$(LIBSUFFIX) 86 87 SRCS_C = $(SILK_SOURCES) $(CELT_SOURCES) $(OPUS_SOURCES) 88 89 OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(SRCS_C)) 90 91 OPUSDEMO_SRCS_C = src/opus_demo.c 92 OPUSDEMO_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(OPUSDEMO_SRCS_C)) 93 94 TESTOPUSAPI_SRCS_C = tests/test_opus_api.c 95 TESTOPUSAPI_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(TESTOPUSAPI_SRCS_C)) 96 97 TESTOPUSDECODE_SRCS_C = tests/test_opus_decode.c 98 TESTOPUSDECODE_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(TESTOPUSDECODE_SRCS_C)) 99 100 TESTOPUSENCODE_SRCS_C = tests/test_opus_encode.c tests/opus_encode_regressions.c 101 TESTOPUSENCODE_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(TESTOPUSENCODE_SRCS_C)) 102 103 TESTOPUSPADDING_SRCS_C = tests/test_opus_padding.c 104 TESTOPUSPADDING_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(TESTOPUSPADDING_SRCS_C)) 105 106 OPUSCOMPARE_SRCS_C = src/opus_compare.c 107 OPUSCOMPARE_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(OPUSCOMPARE_SRCS_C)) 108 109 TESTS := test_opus_api test_opus_decode test_opus_encode test_opus_padding 110 111 # Rules 112 all: lib opus_demo opus_compare $(TESTS) 113 114 lib: $(TARGET) 115 116 check: all 117 for test in $(TESTS); do ./$$test; done 118 119 $(TARGET): $(OBJS) 120 $(ARCHIVE.cmdline) 121 122 opus_demo$(EXESUFFIX): $(OPUSDEMO_OBJS) $(TARGET) 123 $(LINK.o.cmdline) 124 125 test_opus_api$(EXESUFFIX): $(TESTOPUSAPI_OBJS) $(TARGET) 126 $(LINK.o.cmdline) 127 128 test_opus_decode$(EXESUFFIX): $(TESTOPUSDECODE_OBJS) $(TARGET) 129 $(LINK.o.cmdline) 130 131 test_opus_encode$(EXESUFFIX): $(TESTOPUSENCODE_OBJS) $(TARGET) 132 $(LINK.o.cmdline) 133 134 test_opus_padding$(EXESUFFIX): $(TESTOPUSPADDING_OBJS) $(TARGET) 135 $(LINK.o.cmdline) 136 137 opus_compare$(EXESUFFIX): $(OPUSCOMPARE_OBJS) 138 $(LINK.o.cmdline) 139 140 celt/celt.o: CFLAGS += -DPACKAGE_VERSION='$(PACKAGE_VERSION)' 141 celt/celt.o: package_version 142 143 package_version: force 144 @if [ -x ./update_version ]; then \ 145 ./update_version || true; \ 146 elif [ ! -e ./package_version ]; then \ 147 echo 'PACKAGE_VERSION="unknown"' > ./package_version; \ 148 fi 149 150 force: 151 152 clean: 153 rm -f opus_demo$(EXESUFFIX) opus_compare$(EXESUFFIX) $(TARGET) \ 154 test_opus_api$(EXESUFFIX) test_opus_decode$(EXESUFFIX) \ 155 test_opus_encode$(EXESUFFIX) test_opus_padding$(EXESUFFIX) \ 156 $(OBJS) $(OPUSDEMO_OBJS) $(OPUSCOMPARE_OBJS) $(TESTOPUSAPI_OBJS) \ 157 $(TESTOPUSDECODE_OBJS) $(TESTOPUSENCODE_OBJS) $(TESTOPUSPADDING_OBJS) 158 159 .PHONY: all lib clean force check 160