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 CFLAGS += -O2 -g $(WARNINGS) -DOPUS_BUILD
|
cannam@154
|
49 CINCLUDES = include silk celt
|
cannam@154
|
50
|
cannam@154
|
51 ifdef FIXED_POINT
|
cannam@154
|
52 CFLAGS += -DFIXED_POINT=1 -DDISABLE_FLOAT_API
|
cannam@154
|
53 CINCLUDES += silk/fixed
|
cannam@154
|
54 else
|
cannam@154
|
55 CINCLUDES += silk/float
|
cannam@154
|
56 endif
|
cannam@154
|
57
|
cannam@154
|
58
|
cannam@154
|
59 LIBS = m
|
cannam@154
|
60
|
cannam@154
|
61 LDLIBDIRS = ./
|
cannam@154
|
62
|
cannam@154
|
63 CFLAGS += $(call cppflags-from-defines,$(CDEFINES))
|
cannam@154
|
64 CFLAGS += $(call cppflags-from-includes,$(CINCLUDES))
|
cannam@154
|
65 LDFLAGS += $(call ldflags-from-ldlibdirs,$(LDLIBDIRS))
|
cannam@154
|
66 LDLIBS += $(call ldlibs-from-libs,$(LIBS))
|
cannam@154
|
67
|
cannam@154
|
68 COMPILE.c.cmdline = $(CC) -c $(CFLAGS) -o $@ $<
|
cannam@154
|
69 LINK.o = $(CC) $(LDPREFLAGS) $(LDFLAGS)
|
cannam@154
|
70 LINK.o.cmdline = $(LINK.o) $^ $(LDLIBS) -o $@$(EXESUFFIX)
|
cannam@154
|
71
|
cannam@154
|
72 ARCHIVE.cmdline = $(AR) $(ARFLAGS) $@ $^ && $(RANLIB) $@
|
cannam@154
|
73
|
cannam@154
|
74 %$(OBJSUFFIX):%.c
|
cannam@154
|
75 $(COMPILE.c.cmdline)
|
cannam@154
|
76
|
cannam@154
|
77 %$(OBJSUFFIX):%.cpp
|
cannam@154
|
78 $(COMPILE.cpp.cmdline)
|
cannam@154
|
79
|
cannam@154
|
80 # Directives
|
cannam@154
|
81
|
cannam@154
|
82
|
cannam@154
|
83 # Variable definitions
|
cannam@154
|
84 LIB_NAME = opus
|
cannam@154
|
85 TARGET = $(LIBPREFIX)$(LIB_NAME)$(LIBSUFFIX)
|
cannam@154
|
86
|
cannam@154
|
87 SRCS_C = $(SILK_SOURCES) $(CELT_SOURCES) $(OPUS_SOURCES)
|
cannam@154
|
88
|
cannam@154
|
89 OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(SRCS_C))
|
cannam@154
|
90
|
cannam@154
|
91 OPUSDEMO_SRCS_C = src/opus_demo.c
|
cannam@154
|
92 OPUSDEMO_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(OPUSDEMO_SRCS_C))
|
cannam@154
|
93
|
cannam@154
|
94 TESTOPUSAPI_SRCS_C = tests/test_opus_api.c
|
cannam@154
|
95 TESTOPUSAPI_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(TESTOPUSAPI_SRCS_C))
|
cannam@154
|
96
|
cannam@154
|
97 TESTOPUSDECODE_SRCS_C = tests/test_opus_decode.c
|
cannam@154
|
98 TESTOPUSDECODE_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(TESTOPUSDECODE_SRCS_C))
|
cannam@154
|
99
|
cannam@154
|
100 TESTOPUSENCODE_SRCS_C = tests/test_opus_encode.c tests/opus_encode_regressions.c
|
cannam@154
|
101 TESTOPUSENCODE_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(TESTOPUSENCODE_SRCS_C))
|
cannam@154
|
102
|
cannam@154
|
103 TESTOPUSPADDING_SRCS_C = tests/test_opus_padding.c
|
cannam@154
|
104 TESTOPUSPADDING_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(TESTOPUSPADDING_SRCS_C))
|
cannam@154
|
105
|
cannam@154
|
106 OPUSCOMPARE_SRCS_C = src/opus_compare.c
|
cannam@154
|
107 OPUSCOMPARE_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(OPUSCOMPARE_SRCS_C))
|
cannam@154
|
108
|
cannam@154
|
109 TESTS := test_opus_api test_opus_decode test_opus_encode test_opus_padding
|
cannam@154
|
110
|
cannam@154
|
111 # Rules
|
cannam@154
|
112 all: lib opus_demo opus_compare $(TESTS)
|
cannam@154
|
113
|
cannam@154
|
114 lib: $(TARGET)
|
cannam@154
|
115
|
cannam@154
|
116 check: all
|
cannam@154
|
117 for test in $(TESTS); do ./$$test; done
|
cannam@154
|
118
|
cannam@154
|
119 $(TARGET): $(OBJS)
|
cannam@154
|
120 $(ARCHIVE.cmdline)
|
cannam@154
|
121
|
cannam@154
|
122 opus_demo$(EXESUFFIX): $(OPUSDEMO_OBJS) $(TARGET)
|
cannam@154
|
123 $(LINK.o.cmdline)
|
cannam@154
|
124
|
cannam@154
|
125 test_opus_api$(EXESUFFIX): $(TESTOPUSAPI_OBJS) $(TARGET)
|
cannam@154
|
126 $(LINK.o.cmdline)
|
cannam@154
|
127
|
cannam@154
|
128 test_opus_decode$(EXESUFFIX): $(TESTOPUSDECODE_OBJS) $(TARGET)
|
cannam@154
|
129 $(LINK.o.cmdline)
|
cannam@154
|
130
|
cannam@154
|
131 test_opus_encode$(EXESUFFIX): $(TESTOPUSENCODE_OBJS) $(TARGET)
|
cannam@154
|
132 $(LINK.o.cmdline)
|
cannam@154
|
133
|
cannam@154
|
134 test_opus_padding$(EXESUFFIX): $(TESTOPUSPADDING_OBJS) $(TARGET)
|
cannam@154
|
135 $(LINK.o.cmdline)
|
cannam@154
|
136
|
cannam@154
|
137 opus_compare$(EXESUFFIX): $(OPUSCOMPARE_OBJS)
|
cannam@154
|
138 $(LINK.o.cmdline)
|
cannam@154
|
139
|
cannam@154
|
140 celt/celt.o: CFLAGS += -DPACKAGE_VERSION='$(PACKAGE_VERSION)'
|
cannam@154
|
141 celt/celt.o: package_version
|
cannam@154
|
142
|
cannam@154
|
143 package_version: force
|
cannam@154
|
144 @if [ -x ./update_version ]; then \
|
cannam@154
|
145 ./update_version || true; \
|
cannam@154
|
146 elif [ ! -e ./package_version ]; then \
|
cannam@154
|
147 echo 'PACKAGE_VERSION="unknown"' > ./package_version; \
|
cannam@154
|
148 fi
|
cannam@154
|
149
|
cannam@154
|
150 force:
|
cannam@154
|
151
|
cannam@154
|
152 clean:
|
cannam@154
|
153 rm -f opus_demo$(EXESUFFIX) opus_compare$(EXESUFFIX) $(TARGET) \
|
cannam@154
|
154 test_opus_api$(EXESUFFIX) test_opus_decode$(EXESUFFIX) \
|
cannam@154
|
155 test_opus_encode$(EXESUFFIX) test_opus_padding$(EXESUFFIX) \
|
cannam@154
|
156 $(OBJS) $(OPUSDEMO_OBJS) $(OPUSCOMPARE_OBJS) $(TESTOPUSAPI_OBJS) \
|
cannam@154
|
157 $(TESTOPUSDECODE_OBJS) $(TESTOPUSENCODE_OBJS) $(TESTOPUSPADDING_OBJS)
|
cannam@154
|
158
|
cannam@154
|
159 .PHONY: all lib clean force check
|