Fix varrious splint warnings, C89 compatibility, and compilation with the
[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 EXESUFFIX =
27 LIBPREFIX = lib
28 LIBSUFFIX = .a
29 OBJSUFFIX = .o
30
31 CC     = $(TOOLCHAIN_PREFIX)gcc$(TOOLCHAIN_SUFFIX)
32 CXX    = $(TOOLCHAIN_PREFIX)g++$(TOOLCHAIN_SUFFIX)
33 AR     = $(TOOLCHAIN_PREFIX)ar
34 RANLIB = $(TOOLCHAIN_PREFIX)ranlib
35 CP     = $(TOOLCHAIN_PREFIX)cp
36
37 cppflags-from-defines   = $(addprefix -D,$(1))
38 cppflags-from-includes  = $(addprefix -I,$(1))
39 ldflags-from-ldlibdirs  = $(addprefix -L,$(1))
40 ldlibs-from-libs                = $(addprefix -l,$(1))
41
42 WARNINGS = -Wall -W -Wstrict-prototypes -Wextra -Wcast-align -Wnested-externs -Wshadow -Wno-parentheses -Wno-unused-parameter -Wno-sign-compare
43 CFLAGS  += -O2 -g $(WARNINGS) -DOPUS_BUILD
44 ifdef FIXED_POINT
45 CFLAGS += -DFIXED_POINT=1 -DDISABLE_FLOAT_API
46 endif
47
48 CFLAGS  += $(call cppflags-from-defines,$(CDEFINES))
49 CFLAGS  += $(call cppflags-from-includes,$(CINCLUDES))
50 LDFLAGS += $(call ldflags-from-ldlibdirs,$(LDLIBDIRS))
51 LDLIBS  += $(call ldlibs-from-libs,$(LIBS))
52
53 COMPILE.c.cmdline   = $(CC) -c $(CFLAGS) -o $@ $<
54 COMPILE.cpp.cmdline = $(CXX) -c $(CFLAGS) -o $@ $<
55 LINK.o              = $(CC) $(LDPREFLAGS) $(LDFLAGS)
56 LINK.o.cmdline      = $(LINK.o) $^ $(LDLIBS) -o $@$(EXESUFFIX)
57
58 ARCHIVE.cmdline     = $(AR) $(ARFLAGS) $@ $^ && $(RANLIB) $@
59
60 %$(OBJSUFFIX):%.c
61         $(COMPILE.c.cmdline)
62
63 %$(OBJSUFFIX):%.cpp
64         $(COMPILE.cpp.cmdline)
65
66 # Directives
67
68 CINCLUDES += silk/ \
69         silk/float/ \
70         silk/fixed/ \
71         libcelt/ \
72         src/
73
74 # VPATH e.g. VPATH = src:../headers
75 VPATH = ./ \
76         silk/interface \
77         silk/src_FIX \
78         silk/src_FLP \
79         silk/src_SigProc_FIX \
80         silk/src_SigProc_FLP \
81         test
82
83 # Variable definitions
84 LIB_NAME = opus
85 TARGET = $(LIBPREFIX)$(LIB_NAME)$(LIBSUFFIX)
86
87 SRCS_C = $(SILK_SOURCES) $(CELT_SOURCES) $(OPUS_SOURCES)
88
89 OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(SRCS_C))
90
91 TESTOPUS_SRCS_C = src/test_opus.c
92 TESTOPUS_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(TESTOPUS_SRCS_C))
93
94 LIBS = m
95
96 LDLIBDIRS = ./
97
98 # Rules
99 default: all
100
101 all: $(TARGET) lib test_opus
102
103 lib: $(TARGET)
104
105 $(TARGET): $(OBJS)
106         $(ARCHIVE.cmdline)
107
108 test_opus$(EXESUFFIX): $(TESTOPUS_OBJS) $(TARGET)
109         $(LINK.o.cmdline)
110         
111 clean:
112         rm -f test_opus$(EXESUFFIX) $(TARGET) $(OBJS) $(TESTOPUS_OBJS)