-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
134 lines (102 loc) · 3.33 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#
# Makefile for Silk SDK
#
# Copyright (c) 2012, Skype Limited
# All rights reserved.
#
#Platform detection and settings
BUILD_OS := $(shell uname | sed -e 's/^.*Darwin.*/MacOS-X/ ; s/^.*CYGWIN.*/Windows/')
BUILD_ARCHITECTURE := $(shell uname -m | sed -e 's/i686/i386/')
EXESUFFIX =
LIBPREFIX = lib
LIBSUFFIX = .a
OBJSUFFIX = .o
CC = $(TOOLCHAIN_PREFIX)gcc$(TOOLCHAIN_SUFFIX)
CXX = $(TOOLCHAIN_PREFIX)g++$(TOOLCHAIN_SUFFIX)
AR = $(TOOLCHAIN_PREFIX)ar
RANLIB = $(TOOLCHAIN_PREFIX)ranlib
CP = $(TOOLCHAIN_PREFIX)cp
cppflags-from-defines = $(addprefix -D,$(1))
cppflags-from-includes = $(addprefix -I,$(1))
ldflags-from-ldlibdirs = $(addprefix -L,$(1))
ldlibs-from-libs = $(addprefix -l,$(1))
ifneq (,$(TARGET_CPU))
CFLAGS += -mcpu=$(TARGET_CPU)
ifneq (,$(TARGET_TUNE))
CFLAGS += -mtune=$(TARGET_TUNE)
else
CFLAGS += -mtune=$(TARGET_CPU)
endif
endif
ifneq (,$(TARGET_FPU))
CFLAGS += -mfpu=$(TARGET_FPU)
endif
ifneq (,$(TARGET_ARCH))
CFLAGS += -march=$(TARGET_ARCH)
endif
# Helper to make NEON testing easier, when using USE_NEON=yes do not set TARGET_CPU or TARGET_FPU
ifeq (yes,$(USE_NEON))
CFLAGS += -mcpu=cortex-a8 -mfloat-abi=softfp -mfpu=neon
endif
CFLAGS += -Wall -enable-threads -O3
CFLAGS += $(call cppflags-from-defines,$(CDEFINES))
CFLAGS += $(call cppflags-from-defines,$(ADDED_DEFINES))
CFLAGS += $(call cppflags-from-includes,$(CINCLUDES))
LDFLAGS += $(call ldflags-from-ldlibdirs,$(LDLIBDIRS))
LDLIBS += $(call ldlibs-from-libs,$(LIBS))
COMPILE.c.cmdline = $(CC) -c $(CFLAGS) $(ADDED_CFLAGS) -o $@ $<
COMPILE.S.cmdline = $(CC) -c $(CFLAGS) $(ADDED_CFLAGS) -o $@ $<
COMPILE.cpp.cmdline = $(CXX) -c $(CFLAGS) $(ADDED_CFLAGS) -o $@ $<
LINK.o = $(CXX) $(LDPREFLAGS) $(LDFLAGS)
LINK.o.cmdline = $(LINK.o) $^ $(LDLIBS) -o $@$(EXESUFFIX)
ARCHIVE.cmdline = $(AR) $(ARFLAGS) $@ $^ && $(RANLIB) $@
%$(OBJSUFFIX):%.c
$(COMPILE.c.cmdline)
%$(OBJSUFFIX):%.cpp
$(COMPILE.cpp.cmdline)
%$(OBJSUFFIX):%.S
$(COMPILE.S.cmdline)
# Directives
CINCLUDES += src/include src/lib src/test
# VPATH e.g. VPATH = src:../headers
VPATH = src \
src/include \
src/lib \
src/test
# Variable definitions
LIB_NAME = SKP_SILK_SDK
TARGET = $(LIBPREFIX)$(LIB_NAME)$(LIBSUFFIX)
PROGENC = silkenc
PROGDEC = silkdec
PROGCMP = pcmcompare
SRCS_C = $(wildcard src/lib/*.c)
ifneq (,$(TOOLCHAIN_PREFIX))
SRCS_S = $(wildcard src/lib/*.S)
OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(SRCS_C)) $(patsubst %.S,%$(OBJSUFFIX),$(SRCS_S))
else
OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(SRCS_C))
endif
ENCODER_SRCS_C = src/test/silkenc.c
ENCODER_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(ENCODER_SRCS_C))
DECODER_SRCS_C = src/test/silkdec.c
DECODER_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(DECODER_SRCS_C))
SIGNALCMP_SRCS_C = src/test/pcmcompare.c
SIGNALCMP_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(SIGNALCMP_SRCS_C))
LIBS = $(LIB_NAME)
LDLIBDIRS = ./
# Rules
default: all
all: $(TARGET) $(PROGENC) $(PROGDEC) $(PROGCMP)
lib: $(TARGET)
$(TARGET): $(OBJS)
$(ARCHIVE.cmdline)
$(PROGENC)$(EXESUFFIX): $(ENCODER_OBJS)
$(LINK.o.cmdline)
$(PROGDEC)$(EXESUFFIX): $(DECODER_OBJS)
$(LINK.o.cmdline)
$(PROGCMP)$(EXESUFFIX): $(SIGNALCMP_OBJS)
$(LINK.o.cmdline)
clean:
$(RM) $(TARGET)* $(OBJS) $(ENCODER_OBJS) $(DECODER_OBJS) \
$(SIGNALCMP_OBJS) $(TEST_OBJS) \
$(PROGENC)$(EXESUFFIX) $(PROGDEC)$(EXESUFFIX) $(PROGCMP)$(EXESUFFIX)