-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
77 lines (63 loc) · 2.46 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
# compiler env.
UNAME := $(shell uname -s)
ifeq ($(UNAME),Linux)
CXX=ccache clang++
LDLIBS=-ldl -lasound
CXXFLAGS=-std=c++2a -MMD -MP -Wall -fPIC
SHARED_CXXFLAGS= -fPIC -shared
endif
ifeq ($(UNAME),Darwin)
CXX=ccache clang++
LDLIBS=-stdlib=libc++
CXXFLAGS=-std=c++2a -MMD -MP -Wall -Wno-deprecated-anon-enum-enum-conversion
# SHARED_CXXFLAGS= -flat_namespace -dynamiclib
SHARED_CXXFLAGS=-dynamiclib
endif
LDFLAGS=-pthread
# project config
AFW_DIR=../audioframework
AFW_INC_DIR=$(AFW_DIR)/include
AFW_LIB_DIR=$(AFW_DIR)/lib
AFW_HELPER_DIR=../AndroidAudioHalHelper
AFW_HELPER_INC=$(AFW_HELPER_DIR)/src
AFW_HELPER_LIB_DIR=$(AFW_HELPER_DIR)/lib
ANDROID_HOME := $(shell printenv ANDROID_HOME)
ANDROID_MEDIA_INC=$(ANDROID_HOME)/system/media/audio/include
ANDROID_CUTIL_INC=$(ANDROID_HOME)/system/core/libcutils/include
ANDROID_FMQ_INC=$(ANDROID_HOME)/system/libfmq/include
ANDROID_FMQ_INC2=$(ANDROID_HOME)/system/libfmq/base
ANDROID_LIBBASE_INC=$(ANDROID_HOME)/system/libbase/include
ANDROID_UTILS_INC=$(ANDROID_HOME)/system/core/libutils/include
ANDROID_HIDL_INC=$(ANDROID_HOME)/system/libhidl/base/include
ANDROID_LOG_INC=$(ANDROID_HOME)/system/core/liblog/include
ANDROID_LOG_S_INC=$(ANDROID_HOME)/system/logging/liblog/include
SRC_DIR = ./src
OBJ_DIR = ./out
BIN_DIR = ./bin
SRCS = $(wildcard $(SRC_DIR)/*.cpp)
OBJS = $(addprefix $(OBJ_DIR)/, $(notdir $(SRCS:.cpp=.o)))
AFWHAL_TARGET =$(BIN_DIR)/afwhal
# --- Build for sink example(shared) ------------
UNAME := $(shell uname -s)
ifeq ($(UNAME),Linux)
AFW_HELPER_DYNAMIC_LIB = $(AFW_HELPER_LIB_DIR)/libaudiohalhelper.so
AFW_DYNAMIC_LIB = $(AFW_LIB_DIR)/libafw.so
endif
ifeq ($(UNAME),Darwin)
AFW_HELPER_DYNAMIC_LIB = $(AFW_HELPER_LIB_DIR)/libaudiohalhelper.dylib
AFW_DYNAMIC_LIB = $(AFW_LIB_DIR)/libafw.dylib
endif
DEPS = $(OBJS:.o=.d)
default: $(AFWHAL_TARGET)
.PHONY: default
$(AFWHAL_TARGET): $(OBJS)
@[ -d $(BIN_DIR) ] || mkdir -p $(BIN_DIR)
$(CXX) $(LDFLAGS) $(OBJS) -o $@ $(LDLIBS) $(AFW_DYNAMIC_LIB) $(AFW_HELPER_DYNAMIC_LIB)
$(OBJS): $(SRCS)
echo Android home is $(ANDROID_HOME)
@[ -d $(OBJ_DIR) ] || mkdir -p $(OBJ_DIR)
$(CXX) $(CXXFLAGS) -I $(AFW_INC_DIR) -I $(AFW_HELPER_INC) -I $(ANDROID_MEDIA_INC) -I $(ANDROID_CUTIL_INC) -I $(ANDROID_FMQ_INC) -I $(ANDROID_FMQ_INC2) -I $(ANDROID_LIBBASE_INC) -I $(ANDROID_UTILS_INC) -I $(ANDROID_HIDL_INC) -I $(ANDROID_LOG_INC) -I $(ANDROID_LOG_S_INC) -c $(SRC_DIR)/$(notdir $(@:.o=.cpp)) -o $@
-include $(DEPS)
# --- clean up ------------------------
clean:
rm -f $(OBJS) $(AFWHAL_TARGET)