f68b048ac85efe92a6221723e2f08a4cb7f6fc06
[opus.git] / Makefile.draft
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
11 #CFLAGS += -DVAR_ARRAYS
12
13 # These options affect performance
14 # HAVE_LRINTF: Use C99 intrinsics to speed up float-to-int conversion
15 # restrict: Don't use the 'restrict' optimization (for pre-C99 compilers)
16 #CFLAGS += -DHAVE_LRINTF
17 CFLAGS += -Drestrict=
18
19 ###################### END OF OPTIONS ######################
20
21 CFLAGS += -DOPUS_VERSION='"0.9.6"'
22 include silk_sources.mk
23 include celt_sources.mk
24 include opus_sources.mk
25
26 ifdef FIXED_POINT
27 SILK_SOURCES += $(SILK_SOURCES_FIXED)
28 else
29 SILK_SOURCES += $(SILK_SOURCES_FLOAT)
30 endif
31
32 EXESUFFIX =
33 LIBPREFIX = lib
34 LIBSUFFIX = .a
35 OBJSUFFIX = .o
36
37 CC     = $(TOOLCHAIN_PREFIX)gcc$(TOOLCHAIN_SUFFIX)
38 CXX    = $(TOOLCHAIN_PREFIX)g++$(TOOLCHAIN_SUFFIX)
39 AR     = $(TOOLCHAIN_PREFIX)ar
40 RANLIB = $(TOOLCHAIN_PREFIX)ranlib
41 CP     = $(TOOLCHAIN_PREFIX)cp
42
43 cppflags-from-defines   = $(addprefix -D,$(1))
44 cppflags-from-includes  = $(addprefix -I,$(1))
45 ldflags-from-ldlibdirs  = $(addprefix -L,$(1))
46 ldlibs-from-libs                = $(addprefix -l,$(1))
47
48 WARNINGS = -Wall -W -Wstrict-prototypes -Wextra -Wcast-align -Wnested-externs -Wshadow -Wno-parentheses -Wno-unused-parameter -Wno-sign-compare
49 CFLAGS  += -O2 -g $(WARNINGS) -DOPUS_BUILD
50 ifdef FIXED_POINT
51 CFLAGS += -DFIXED_POINT=1 -DDISABLE_FLOAT_API
52 endif
53
54 CFLAGS  += $(call cppflags-from-defines,$(CDEFINES))
55 CFLAGS  += $(call cppflags-from-includes,$(CINCLUDES))
56 LDFLAGS += $(call ldflags-from-ldlibdirs,$(LDLIBDIRS))
57 LDLIBS  += $(call ldlibs-from-libs,$(LIBS))
58
59 COMPILE.c.cmdline   = $(CC) -c $(CFLAGS) -o $@ $<
60 COMPILE.cpp.cmdline = $(CXX) -c $(CFLAGS) -o $@ $<
61 LINK.o              = $(CC) $(LDPREFLAGS) $(LDFLAGS)
62 LINK.o.cmdline      = $(LINK.o) $^ $(LDLIBS) -o $@$(EXESUFFIX)
63
64 ARCHIVE.cmdline     = $(AR) $(ARFLAGS) $@ $^ && $(RANLIB) $@
65
66 %$(OBJSUFFIX):%.c
67         $(COMPILE.c.cmdline)
68
69 %$(OBJSUFFIX):%.cpp
70         $(COMPILE.cpp.cmdline)
71
72 # Directives
73
74 CINCLUDES += silk/ \
75         silk/float/ \
76         silk/fixed/ \
77         libcelt/ \
78         src/
79
80 # VPATH e.g. VPATH = src:../headers
81 VPATH = ./ \
82         silk/interface \
83         silk/src_FIX \
84         silk/src_FLP \
85         silk/src_SigProc_FIX \
86         silk/src_SigProc_FLP \
87         test
88
89 # Variable definitions
90 LIB_NAME = opus
91 TARGET = $(LIBPREFIX)$(LIB_NAME)$(LIBSUFFIX)
92
93 SRCS_C = $(SILK_SOURCES) $(CELT_SOURCES) $(OPUS_SOURCES)
94
95 OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(SRCS_C))
96
97 TESTOPUS_SRCS_C = src/test_opus.c
98 TESTOPUS_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(TESTOPUS_SRCS_C))
99
100 LIBS = m
101
102 LDLIBDIRS = ./
103
104 # Rules
105 default: all
106
107 all: $(TARGET) lib test_opus
108
109 lib: $(TARGET)
110
111 $(TARGET): $(OBJS)
112         $(ARCHIVE.cmdline)
113
114 test_opus$(EXESUFFIX): $(TESTOPUS_OBJS) $(TARGET)
115         $(LINK.o.cmdline)
116         
117 clean:
118         rm -f test_opus$(EXESUFFIX) $(TARGET) $(OBJS) $(TESTOPUS_OBJS)