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