-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
72 lines (60 loc) · 2.27 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
ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
BUILD_DIR=$(ROOT_DIR)/build
WASM_BUILD_DIR=$(ROOT_DIR)/build/wasm
BIN_PATH=$(ROOT_DIR)/build/bin
MAN_PATH=$(ROOT_DIR)/build/man
PATH:=$(PATH):$(BIN_PATH)
INSTALLS=--prefix=$(BUILD_DIR) --libdir=$(BUILD_DIR)/lib --includedir=$(BUILD_DIR)/include --bindir=$(BUILD_DIR)/bin
WASM_INSTALLS=--prefix=$(WASM_BUILD_DIR) --libdir=$(WASM_BUILD_DIR)/lib --includedir=$(WASM_BUILD_DIR)/include --bindir=$(WASM_BUILD_DIR)/bin
LIBX_SETTINGS = \
--prefix="$(BUILD_PATH)" \
--disable-cli \
--enable-static \
--disable-opencl \
--disable-interlaced \
--bit-depth=8 \
--chroma-format=420 \
--disable-avs \
--disable-swscale \
--disable-lavf \
--disable-ffms \
--disable-gpac \
--disable-lsmash \
--disable-bashcompletion \
WASM_LIBX_SETTINGS=$(LIBX_SETTINGS) --disable-asm --host=x86-none-linux
SIMD_FLAGS=-msse4.1 -msimd128
example:
gcc -I./build/include x264example.c $(BUILD_DIR)/lib/libx264.a -msse4 -O3 -pthread -Wall -lm -o main
wasm-example:
emcc -I$(WASM_BUILD_DIR)/include x264example.c $(WASM_BUILD_DIR)/lib/libx264.a $(SIMD_FLAGS) -O3 -s PROXY_TO_PTHREAD -s PTHREAD_POOL_SIZE=10 -s INITIAL_MEMORY=1024MB -pthread -Wall -lm -o index.html
# nasm build
build-nasm:
wget https://www.nasm.us/pub/nasm/releasebuilds/2.14.02/nasm-2.14.02.tar.bz2 && \
tar xjvf nasm-2.14.02.tar.bz2 && \
cd nasm-2.14.02 && \
./configure --bindir="$(BIN_PATH)" --mandir="$(MAN_PATH)" && \
make && \
make install
# Wasm build for x264 without threads and simd
wasm-libx264:
cd ./x264 && \
emconfigure ./configure $(WASM_INSTALLS) \
--extra-cflags="-pthread -c $(SIMD_FLAGS)" \
$(WASM_LIBX_SETTINGS) && \
emmake make -j8 && \
emmake make install
# Wasm build for x264 with threads and simd
wasm-libx264-simd:
cd ./x264 && \
emconfigure ./configure $(WASM_INSTALLS) \
--extra-cflags="-pthread -c $(SIMD_FLAGS) -D__REPLACE_SIMD__" \
$(WASM_LIBX_SETTINGS) && \
emmake make -j8 && \
emmake make install
# Build native libx264 for testing/comparisons
libx264:
cd x264 && \
COMPILER_FLAGS=-msse4 && \
./configure $(INSTALLS) $(LIBX_SETTINGS) --extra-cflags="-c -Wno-unknown-warning-option -fno-tree-vectorize -msse4" && \
make -j8 && \
make install