• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
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
15#CFLAGS := -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
48CFLAGS  += -O2 -g $(WARNINGS) -DOPUS_BUILD
49CINCLUDES = include silk celt
50
51ifdef FIXED_POINT
52CFLAGS += -DFIXED_POINT=1 -DDISABLE_FLOAT_API
53CINCLUDES += silk/fixed
54else
55CINCLUDES += silk/float
56endif
57
58
59LIBS = m
60
61LDLIBDIRS = ./
62
63CFLAGS  += $(call cppflags-from-defines,$(CDEFINES))
64CFLAGS  += $(call cppflags-from-includes,$(CINCLUDES))
65LDFLAGS += $(call ldflags-from-ldlibdirs,$(LDLIBDIRS))
66LDLIBS  += $(call ldlibs-from-libs,$(LIBS))
67
68COMPILE.c.cmdline   = $(CC) -c $(CFLAGS) -o $@ $<
69LINK.o              = $(CC) $(LDPREFLAGS) $(LDFLAGS)
70LINK.o.cmdline      = $(LINK.o) $^ $(LDLIBS) -o $@$(EXESUFFIX)
71
72ARCHIVE.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
84LIB_NAME = opus
85TARGET = $(LIBPREFIX)$(LIB_NAME)$(LIBSUFFIX)
86
87SRCS_C = $(SILK_SOURCES) $(CELT_SOURCES) $(OPUS_SOURCES)
88
89OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(SRCS_C))
90
91OPUSDEMO_SRCS_C = src/opus_demo.c
92OPUSDEMO_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(OPUSDEMO_SRCS_C))
93
94TESTOPUSAPI_SRCS_C = tests/test_opus_api.c
95TESTOPUSAPI_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(TESTOPUSAPI_SRCS_C))
96
97TESTOPUSDECODE_SRCS_C = tests/test_opus_decode.c
98TESTOPUSDECODE_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(TESTOPUSDECODE_SRCS_C))
99
100TESTOPUSENCODE_SRCS_C = tests/test_opus_encode.c
101TESTOPUSENCODE_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(TESTOPUSENCODE_SRCS_C))
102
103TESTOPUSPADDING_SRCS_C = tests/test_opus_padding.c
104TESTOPUSPADDING_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(TESTOPUSPADDING_SRCS_C))
105
106OPUSCOMPARE_SRCS_C = src/opus_compare.c
107OPUSCOMPARE_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(OPUSCOMPARE_SRCS_C))
108
109TESTS := test_opus_api test_opus_decode test_opus_encode test_opus_padding
110
111# Rules
112all: lib opus_demo opus_compare $(TESTS)
113
114lib: $(TARGET)
115
116check: all
117	for test in $(TESTS); do ./$$test; done
118
119$(TARGET): $(OBJS)
120	$(ARCHIVE.cmdline)
121
122opus_demo$(EXESUFFIX): $(OPUSDEMO_OBJS) $(TARGET)
123	$(LINK.o.cmdline)
124
125test_opus_api$(EXESUFFIX): $(TESTOPUSAPI_OBJS) $(TARGET)
126	$(LINK.o.cmdline)
127
128test_opus_decode$(EXESUFFIX): $(TESTOPUSDECODE_OBJS) $(TARGET)
129	$(LINK.o.cmdline)
130
131test_opus_encode$(EXESUFFIX): $(TESTOPUSENCODE_OBJS) $(TARGET)
132	$(LINK.o.cmdline)
133
134test_opus_padding$(EXESUFFIX): $(TESTOPUSPADDING_OBJS) $(TARGET)
135	$(LINK.o.cmdline)
136
137opus_compare$(EXESUFFIX): $(OPUSCOMPARE_OBJS)
138	$(LINK.o.cmdline)
139
140celt/celt.o: CFLAGS += -DPACKAGE_VERSION='$(PACKAGE_VERSION)'
141celt/celt.o: package_version
142
143package_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
150force:
151
152clean:
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