Chris@69: #################### COMPILE OPTIONS ####################### Chris@69: Chris@69: # Uncomment this for fixed-point build Chris@69: #FIXED_POINT=1 Chris@69: Chris@69: # It is strongly recommended to uncomment one of these Chris@69: # VAR_ARRAYS: Use C99 variable-length arrays for stack allocation Chris@69: # USE_ALLOCA: Use alloca() for stack allocation Chris@69: # If none is defined, then the fallback is a non-threadsafe global array Chris@69: CFLAGS := -DUSE_ALLOCA $(CFLAGS) Chris@69: #CFLAGS := -DVAR_ARRAYS $(CFLAGS) Chris@69: Chris@69: # These options affect performance Chris@69: # HAVE_LRINTF: Use C99 intrinsics to speed up float-to-int conversion Chris@69: #CFLAGS := -DHAVE_LRINTF $(CFLAGS) Chris@69: Chris@69: ###################### END OF OPTIONS ###################### Chris@69: Chris@69: -include package_version Chris@69: Chris@69: include silk_sources.mk Chris@69: include celt_sources.mk Chris@69: include opus_sources.mk Chris@69: Chris@69: ifdef FIXED_POINT Chris@69: SILK_SOURCES += $(SILK_SOURCES_FIXED) Chris@69: else Chris@69: SILK_SOURCES += $(SILK_SOURCES_FLOAT) Chris@69: OPUS_SOURCES += $(OPUS_SOURCES_FLOAT) Chris@69: endif Chris@69: Chris@69: EXESUFFIX = Chris@69: LIBPREFIX = lib Chris@69: LIBSUFFIX = .a Chris@69: OBJSUFFIX = .o Chris@69: Chris@69: CC = $(TOOLCHAIN_PREFIX)cc$(TOOLCHAIN_SUFFIX) Chris@69: AR = $(TOOLCHAIN_PREFIX)ar Chris@69: RANLIB = $(TOOLCHAIN_PREFIX)ranlib Chris@69: CP = $(TOOLCHAIN_PREFIX)cp Chris@69: Chris@69: cppflags-from-defines = $(addprefix -D,$(1)) Chris@69: cppflags-from-includes = $(addprefix -I,$(1)) Chris@69: ldflags-from-ldlibdirs = $(addprefix -L,$(1)) Chris@69: ldlibs-from-libs = $(addprefix -l,$(1)) Chris@69: Chris@69: WARNINGS = -Wall -W -Wstrict-prototypes -Wextra -Wcast-align -Wnested-externs -Wshadow Chris@69: CFLAGS += -O2 -g $(WARNINGS) -DOPUS_BUILD Chris@69: CINCLUDES = include silk celt Chris@69: Chris@69: ifdef FIXED_POINT Chris@69: CFLAGS += -DFIXED_POINT=1 -DDISABLE_FLOAT_API Chris@69: CINCLUDES += silk/fixed Chris@69: else Chris@69: CINCLUDES += silk/float Chris@69: endif Chris@69: Chris@69: Chris@69: LIBS = m Chris@69: Chris@69: LDLIBDIRS = ./ Chris@69: Chris@69: CFLAGS += $(call cppflags-from-defines,$(CDEFINES)) Chris@69: CFLAGS += $(call cppflags-from-includes,$(CINCLUDES)) Chris@69: LDFLAGS += $(call ldflags-from-ldlibdirs,$(LDLIBDIRS)) Chris@69: LDLIBS += $(call ldlibs-from-libs,$(LIBS)) Chris@69: Chris@69: COMPILE.c.cmdline = $(CC) -c $(CFLAGS) -o $@ $< Chris@69: LINK.o = $(CC) $(LDPREFLAGS) $(LDFLAGS) Chris@69: LINK.o.cmdline = $(LINK.o) $^ $(LDLIBS) -o $@$(EXESUFFIX) Chris@69: Chris@69: ARCHIVE.cmdline = $(AR) $(ARFLAGS) $@ $^ && $(RANLIB) $@ Chris@69: Chris@69: %$(OBJSUFFIX):%.c Chris@69: $(COMPILE.c.cmdline) Chris@69: Chris@69: %$(OBJSUFFIX):%.cpp Chris@69: $(COMPILE.cpp.cmdline) Chris@69: Chris@69: # Directives Chris@69: Chris@69: Chris@69: # Variable definitions Chris@69: LIB_NAME = opus Chris@69: TARGET = $(LIBPREFIX)$(LIB_NAME)$(LIBSUFFIX) Chris@69: Chris@69: SRCS_C = $(SILK_SOURCES) $(CELT_SOURCES) $(OPUS_SOURCES) Chris@69: Chris@69: OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(SRCS_C)) Chris@69: Chris@69: OPUSDEMO_SRCS_C = src/opus_demo.c Chris@69: OPUSDEMO_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(OPUSDEMO_SRCS_C)) Chris@69: Chris@69: TESTOPUSAPI_SRCS_C = tests/test_opus_api.c Chris@69: TESTOPUSAPI_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(TESTOPUSAPI_SRCS_C)) Chris@69: Chris@69: TESTOPUSDECODE_SRCS_C = tests/test_opus_decode.c Chris@69: TESTOPUSDECODE_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(TESTOPUSDECODE_SRCS_C)) Chris@69: Chris@69: TESTOPUSENCODE_SRCS_C = tests/test_opus_encode.c tests/opus_encode_regressions.c Chris@69: TESTOPUSENCODE_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(TESTOPUSENCODE_SRCS_C)) Chris@69: Chris@69: TESTOPUSPADDING_SRCS_C = tests/test_opus_padding.c Chris@69: TESTOPUSPADDING_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(TESTOPUSPADDING_SRCS_C)) Chris@69: Chris@69: OPUSCOMPARE_SRCS_C = src/opus_compare.c Chris@69: OPUSCOMPARE_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(OPUSCOMPARE_SRCS_C)) Chris@69: Chris@69: TESTS := test_opus_api test_opus_decode test_opus_encode test_opus_padding Chris@69: Chris@69: # Rules Chris@69: all: lib opus_demo opus_compare $(TESTS) Chris@69: Chris@69: lib: $(TARGET) Chris@69: Chris@69: check: all Chris@69: for test in $(TESTS); do ./$$test; done Chris@69: Chris@69: $(TARGET): $(OBJS) Chris@69: $(ARCHIVE.cmdline) Chris@69: Chris@69: opus_demo$(EXESUFFIX): $(OPUSDEMO_OBJS) $(TARGET) Chris@69: $(LINK.o.cmdline) Chris@69: Chris@69: test_opus_api$(EXESUFFIX): $(TESTOPUSAPI_OBJS) $(TARGET) Chris@69: $(LINK.o.cmdline) Chris@69: Chris@69: test_opus_decode$(EXESUFFIX): $(TESTOPUSDECODE_OBJS) $(TARGET) Chris@69: $(LINK.o.cmdline) Chris@69: Chris@69: test_opus_encode$(EXESUFFIX): $(TESTOPUSENCODE_OBJS) $(TARGET) Chris@69: $(LINK.o.cmdline) Chris@69: Chris@69: test_opus_padding$(EXESUFFIX): $(TESTOPUSPADDING_OBJS) $(TARGET) Chris@69: $(LINK.o.cmdline) Chris@69: Chris@69: opus_compare$(EXESUFFIX): $(OPUSCOMPARE_OBJS) Chris@69: $(LINK.o.cmdline) Chris@69: Chris@69: celt/celt.o: CFLAGS += -DPACKAGE_VERSION='$(PACKAGE_VERSION)' Chris@69: celt/celt.o: package_version Chris@69: Chris@69: package_version: force Chris@69: @if [ -x ./update_version ]; then \ Chris@69: ./update_version || true; \ Chris@69: elif [ ! -e ./package_version ]; then \ Chris@69: echo 'PACKAGE_VERSION="unknown"' > ./package_version; \ Chris@69: fi Chris@69: Chris@69: force: Chris@69: Chris@69: clean: Chris@69: rm -f opus_demo$(EXESUFFIX) opus_compare$(EXESUFFIX) $(TARGET) \ Chris@69: test_opus_api$(EXESUFFIX) test_opus_decode$(EXESUFFIX) \ Chris@69: test_opus_encode$(EXESUFFIX) test_opus_padding$(EXESUFFIX) \ Chris@69: $(OBJS) $(OPUSDEMO_OBJS) $(OPUSCOMPARE_OBJS) $(TESTOPUSAPI_OBJS) \ Chris@69: $(TESTOPUSDECODE_OBJS) $(TESTOPUSENCODE_OBJS) $(TESTOPUSPADDING_OBJS) Chris@69: Chris@69: .PHONY: all lib clean force check