A simpler build system for the draft
[opus.git] / Makefile.draft
1 include silk_sources.mk
2 include celt_sources.mk
3 include opus_sources.mk
4
5 EXESUFFIX =
6 LIBPREFIX = lib
7 LIBSUFFIX = .a
8 OBJSUFFIX = .o
9
10 CC     = $(TOOLCHAIN_PREFIX)gcc$(TOOLCHAIN_SUFFIX)
11 CXX    = $(TOOLCHAIN_PREFIX)g++$(TOOLCHAIN_SUFFIX)
12 AR     = $(TOOLCHAIN_PREFIX)ar
13 RANLIB = $(TOOLCHAIN_PREFIX)ranlib
14 CP     = $(TOOLCHAIN_PREFIX)cp
15
16 cppflags-from-defines   = $(addprefix -D,$(1))
17 cppflags-from-includes  = $(addprefix -I,$(1))
18 ldflags-from-ldlibdirs  = $(addprefix -L,$(1))
19 ldlibs-from-libs                = $(addprefix -l,$(1))
20
21 CFLAGS  += -O2 -g -Wall -DOPUS_BUILD -Drestrict=
22
23 CFLAGS  += $(call cppflags-from-defines,$(CDEFINES))
24 CFLAGS  += $(call cppflags-from-includes,$(CINCLUDES))
25 LDFLAGS += $(call ldflags-from-ldlibdirs,$(LDLIBDIRS))
26 LDLIBS  += $(call ldlibs-from-libs,$(LIBS))
27
28 COMPILE.c.cmdline   = $(CC) -c $(CFLAGS) -o $@ $<
29 COMPILE.cpp.cmdline = $(CXX) -c $(CFLAGS) -o $@ $<
30 LINK.o              = $(CC) $(LDPREFLAGS) $(LDFLAGS)
31 LINK.o.cmdline      = $(LINK.o) $^ $(LDLIBS) -o $@$(EXESUFFIX)
32
33 ARCHIVE.cmdline     = $(AR) $(ARFLAGS) $@ $^ && $(RANLIB) $@
34
35 %$(OBJSUFFIX):%.c
36         $(COMPILE.c.cmdline)
37
38 %$(OBJSUFFIX):%.cpp
39         $(COMPILE.cpp.cmdline)
40
41 # Directives
42
43 CINCLUDES += silk/interface \
44         silk/src_common \
45         silk/test silk/src_FIX \
46         silk/src_FLP \
47         silk/src_SigProc_FIX \
48         silk/src_SigProc_FLP \
49         celt/libcelt \
50         src
51
52 # VPATH e.g. VPATH = src:../headers
53 VPATH = ./ \
54         silk/interface \
55         silk/src_FIX \
56         silk/src_FLP \
57         silk/src_SigProc_FIX \
58         silk/src_SigProc_FLP \
59         test
60
61 # Variable definitions
62 LIB_NAME = libopus
63 TARGET = $(LIBPREFIX)$(LIB_NAME)$(LIBSUFFIX)
64
65 SRCS_C = $(SILK_SOURCES) $(CELT_SOURCES) $(OPUS_SOURCES)
66
67 OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(SRCS_C))
68
69 TESTOPUS_SRCS_C = src/test_opus.c
70 TESTOPUS_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(TESTOPUS_SRCS_C))
71
72 LIBS = $(LIB_NAME) m
73
74 LDLIBDIRS = ./
75
76 # Rules
77 default: all
78
79 all: $(TARGET) lib test_opus
80
81 lib: $(TARGET)
82
83 $(TARGET): $(OBJS)
84         $(ARCHIVE.cmdline)
85
86 test_opus$(EXESUFFIX): $(TESTOPUS_OBJS)
87         $(LINK.o.cmdline)
88