-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMakefile
More file actions
90 lines (72 loc) · 2.66 KB
/
Copy pathMakefile
File metadata and controls
90 lines (72 loc) · 2.66 KB
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
# This Makefile provides minimum set of tools required to
# build a libwebrtc linked binary. You will need the following environment
# to properly make build done.
# - Linux (recommended: Ubuntu 18.04 LTS)
# - Vulkan Driver Support
# - Libraries:
# - Boost 1.70.1 or above (just headers needed)
# - OpenGL Mathematics libglm-dev 0.9 or above
# - Vulkan SDK, libvulkan-dev 1.0 or above
# Build steps:
# 1. In advance, requires libwebrtc compiled using Chromium build toolchain.
# Use the following git commit hash when you checkout branch in order to
# ensure that we use the same version of libwebrtc.
# 159c16f3ceea1d02d08d51fc83d843019d773ec6
# For more information of WebRTC build instructions,
# see https://webrtc.org/native-code/development/
# Use the following command to generate Ninja build file.
# ```gn gen out/Default --args='target_os="linux" is_debug=false rtc_include_tests=false is_component_build=false use_rtti=true'```
# 2. Specify the WebRTC /src directory path to `WEBRTC_ROOT`
# 3. Make sure that `WEBRTC_LIB_ROOT` matches the toolchain generated directory
# 4. make -j
ifndef WEBRTC_ROOT
$(error WEBRTC_ROOT is not set)
endif
WEBRTC_LIB_ROOT=$(WEBRTC_ROOT)/out/Default
TARGET=main
BUILD_DIR=build
SOURCE_DIR=src
INCLUDES=-I$(WEBRTC_ROOT) \
-I$(WEBRTC_ROOT)/third_party/abseil-cpp \
-I$(WEBRTC_ROOT)/third_party/libyuv/include \
-I$(SOURCE_DIR)
ISYSTEM_LIBCPP=-isystem$(WEBRTC_ROOT)/buildtools/third_party/libc++/trunk/include
CXX=$(WEBRTC_ROOT)/third_party/llvm-build/Release+Asserts/bin/clang++
CXXFLAGS=-Wno-macro-redefined \
-O2 \
-pthread \
-DWEBRTC_LINUX \
-DWEBRTC_POSIX \
-D_LIBCPP_ABI_UNSTABLE \
-fno-lto \
-std=c++11 \
-nostdinc++ \
$(ISYSTEM_LIBCPP) \
$(INCLUDES)
LD=$(CXX)
LDFLAGS_LINUX=-ldl -lX11
LDFLAGS_VULKAN=-lvulkan
LDFLAGS=-lpthread $(LDFLAGS_LINUX) $(LDFLAGS_VULKAN)
LIBWEBRTC_A=$(BUILD_DIR)/libwebrtc.a
LIBS=$(LIBWEBRTC_A)
AR=$(WEBRTC_ROOT)/third_party/llvm-build/Release+Asserts/bin/llvm-ar
SOURCES=$(shell find $(SOURCE_DIR) -name '*.cc')
OBJECTS=$(patsubst $(SOURCE_DIR)/%.cc, $(BUILD_DIR)/%.o, $(SOURCES))
HEADERS=$(shell find $(SOURCE_DIR) -name '*.h') $(shell find $(SOURCE_DIR) -name '*.inc')
.PHONY: all
all: $(TARGET)
.PHONY: shader
shader:
glslangValidator -o shaders/frag.spv -V shaders/shader.frag
glslangValidator -o shaders/vert.spv -V shaders/shader.vert
.PHONY: clean
clean:
rm -r $(BUILD_DIR)
rm -f $(TARGET)
$(BUILD_DIR)/%.o: $(SOURCE_DIR)/%.cc $(HEADERS)
@mkdir -p "$(@D)"
$(CXX) $(CXXFLAGS) -c $< -o $@
$(TARGET): $(OBJECTS) $(LIBS)
$(LD) -o $(TARGET) $(OBJECTS) $(LIBS) $(LDFLAGS)
$(LIBWEBRTC_A): $(shell find $(WEBRTC_LIB_ROOT)/obj -name '*.o')
$(AR) -r $@ $^