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