Use more MAC16_16's and unroll a loop.
[opus.git] / Makefile.unix
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
10 CFLAGS := -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 #      inline: Don't use the 'inline' keyword (for ANSI C compilers)
16 #    restrict: Don't use the 'restrict' keyword (for pre-C99 compilers)
17 #CFLAGS := -DHAVE_LRINTF $(CFLAGS)
18 #CFLAGS := -Dinline= $(CFLAGS)
19 CFLAGS := -Drestrict= $(CFLAGS)
20
21 ###################### END OF OPTIONS ######################
22
23 -include package_version
24
25 include silk_sources.mk
26 include celt_sources.mk
27 include opus_sources.mk
28
29 ifdef FIXED_POINT
30 SILK_SOURCES += $(SILK_SOURCES_FIXED)
31 else
32 SILK_SOURCES += $(SILK_SOURCES_FLOAT)
33 OPUS_SOURCES += $(OPUS_SOURCES_FLOAT)
34 endif
35
36 EXESUFFIX =
37 LIBPREFIX = lib
38 LIBSUFFIX = .a
39 OBJSUFFIX = .o
40
41 CC     = $(TOOLCHAIN_PREFIX)cc$(TOOLCHAIN_SUFFIX)
42 AR     = $(TOOLCHAIN_PREFIX)ar
43 RANLIB = $(TOOLCHAIN_PREFIX)ranlib
44 CP     = $(TOOLCHAIN_PREFIX)cp
45
46 cppflags-from-defines   = $(addprefix -D,$(1))
47 cppflags-from-includes  = $(addprefix -I,$(1))
48 ldflags-from-ldlibdirs  = $(addprefix -L,$(1))
49 ldlibs-from-libs        = $(addprefix -l,$(1))
50
51 WARNINGS = -Wall -W -Wstrict-prototypes -Wextra -Wcast-align -Wnested-externs -Wshadow
52 CFLAGS  += -O2 -g $(WARNINGS) -DOPUS_BUILD
53 CINCLUDES = include silk celt
54
55 ifdef FIXED_POINT
56 CFLAGS += -DFIXED_POINT=1 -DDISABLE_FLOAT_API
57 CINCLUDES += silk/fixed
58 else
59 CINCLUDES += silk/float
60 endif
61
62
63 LIBS = m
64
65 LDLIBDIRS = ./
66
67 CFLAGS  += $(call cppflags-from-defines,$(CDEFINES))
68 CFLAGS  += $(call cppflags-from-includes,$(CINCLUDES))
69 LDFLAGS += $(call ldflags-from-ldlibdirs,$(LDLIBDIRS))
70 LDLIBS  += $(call ldlibs-from-libs,$(LIBS))
71
72 COMPILE.c.cmdline   = $(CC) -c $(CFLAGS) -o $@ $<
73 LINK.o              = $(CC) $(LDPREFLAGS) $(LDFLAGS)
74 LINK.o.cmdline      = $(LINK.o) $^ $(LDLIBS) -o $@$(EXESUFFIX)
75
76 ARCHIVE.cmdline     = $(AR) $(ARFLAGS) $@ $^ && $(RANLIB) $@
77
78 %$(OBJSUFFIX):%.c
79         $(COMPILE.c.cmdline)
80
81 %$(OBJSUFFIX):%.cpp
82         $(COMPILE.cpp.cmdline)
83
84 # Directives
85
86
87 # Variable definitions
88 LIB_NAME = opus
89 TARGET = $(LIBPREFIX)$(LIB_NAME)$(LIBSUFFIX)
90
91 SRCS_C = $(SILK_SOURCES) $(CELT_SOURCES) $(OPUS_SOURCES)
92
93 OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(SRCS_C))
94
95 OPUSDEMO_SRCS_C = src/opus_demo.c
96 OPUSDEMO_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(OPUSDEMO_SRCS_C))
97
98 OPUSCOMPARE_SRCS_C = src/opus_compare.c
99 OPUSCOMPARE_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(OPUSCOMPARE_SRCS_C))
100
101 # Rules
102 all: lib opus_demo opus_compare
103
104 lib: $(TARGET)
105
106 $(TARGET): $(OBJS)
107         $(ARCHIVE.cmdline)
108
109 opus_demo$(EXESUFFIX): $(OPUSDEMO_OBJS) $(TARGET)
110         $(LINK.o.cmdline)
111
112 opus_compare$(EXESUFFIX): $(OPUSCOMPARE_OBJS)
113         $(LINK.o.cmdline)
114
115 celt/celt.o: CFLAGS += -DPACKAGE_VERSION='$(PACKAGE_VERSION)'
116 celt/celt.o: package_version
117
118 package_version: force
119         @if [ -x ./update_version ]; then \
120                 ./update_version || true; \
121         elif [ ! -e ./package_version ]; then \
122                 echo 'PACKAGE_VERSION="unknown"' > ./package_version; \
123         fi
124
125 force:
126
127 clean:
128         rm -f opus_demo$(EXESUFFIX) opus_compare$(EXESUFFIX) $(TARGET) \
129                 $(OBJS) $(OPUSDEMO_OBJS) $(OPUSCOMPARE_OBJS)
130
131 .PHONY: all lib clean