This repository has been archived by the owner on Nov 18, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
104 lines (84 loc) · 3.12 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
VERSION_MAJOR = 0
VERSION_MINOR = 1
VERSION_PATCH = 0
VERSION = $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH)
prefix=/usr/local
incdir=$(prefix)/include
bindir=$(prefix)/bin
libdir=$(prefix)/lib
mandir=$(prefix)/man
BINDIR=$(DESTDIR)$(bindir)
INCDIR=$(DESTDIR)$(incdir)/rav1e
LIBDIR=$(DESTDIR)$(libdir)
build_mode:=release
ifeq ($(build_mode),debug)
cargo_mode_opt:=
else
cargo_mode_opt:=--${build_mode}
endif
STATIC_NAME=librav1e.a
OS=$(shell uname -s)
# Horrible hack for Msys
#
# This only works natively building on Windows
# with a GNU toolchain Rust. Tested in MSYS2.
ifneq ($(OS),Linux)
ifneq ($(OS),Darwin)
OS=$(shell uname -o)
STATIC_NAME=rav1e.lib
endif
endif
SO_NAME_Darwin=librav1e.dylib
SO_NAME_MAJOR_Darwin=librav1e.$(VERSION_MAJOR).dylib
SO_NAME_INSTALL_Darwin=librav1e.$(VERSION).dylib
SO_NAME_Linux=librav1e.so
SO_NAME_MAJOR_Linux=librav1e.so.$(VERSION_MAJOR)
SO_NAME_INSTALL_Linux=librav1e.so.$(VERSION)
SO_NAME_INSTALL_Msys=rav1e.dll
SO_NAME_Msys=rav1e.dll
all: target/$(build_mode)/$(STATIC_NAME) rav1e.pc include/rav1e.h
examples: simple_encoding
clean:
cargo clean
-rm -f rav1e.pc
-rm -f include/rav1e.h
-rm -f simple_encoding
include/rav1e.h: target/$(build_mode)/$(STATIC_NAME)
target/$(build_mode)/$(STATIC_NAME): Cargo.toml src/lib.rs
cargo build ${cargo_mode_opt}
rav1e.pc: data/rav1e.pc.in Makefile Cargo.toml
sed -e "s;@prefix@;$(prefix);" \
-e "s;@libdir@;$(libdir);" \
-e "s;@incdir@;$(incdir);" \
-e "s;@VERSION@;$(VERSION);" \
-e "s;@PRIVATE_LIBS@;$$(rustc --print native-static-libs /dev/null --crate-type staticlib 2>&1| grep native-static-libs | cut -d ':' -f 3);" data/rav1e.pc.in > $@
simple_encoding: c-examples/simple_encoding.c target/$(build_mode)/$(STATIC_NAME) rav1e.pc
$(CC) -g -O0 -std=c99 $< -o $@ target/$(build_mode)/$(STATIC_NAME) `grep Libs.private rav1e.pc | cut -d ':' -f 2` -Iinclude
status_to_str: c-tests/status_to_str.c target/$(build_mode)/$(STATIC_NAME) rav1e.pc
$(CC) -g -O0 -std=c99 $< -o $@ target/$(build_mode)/$(STATIC_NAME) `grep Libs.private rav1e.pc | cut -d ':' -f 2` -Iinclude
simple_encoding_installed: c-examples/simple_encoding.c target/$(build_mode)/$(STATIC_NAME) rav1e.pc
$(CC) -g -O0 -std=c99 $< -o $@ `pkg-config --cflags --libs rav1e`
install: target/$(build_mode)/$(STATIC_NAME) rav1e.pc include/rav1e.h target/$(build_mode)/$(SO_NAME_$(OS))
-mkdir -p $(INCDIR) $(LIBDIR)/pkgconfig
cp rav1e.pc $(LIBDIR)/pkgconfig
cp target/$(build_mode)/$(STATIC_NAME) $(LIBDIR)
cp target/$(build_mode)/$(SO_NAME_$(OS)) $(LIBDIR)/$(SO_NAME_INSTALL_$(OS))
ifneq ($(OS),Msys)
ln -sf $(LIBDIR)/$(SO_NAME_INSTALL_$(OS)) $(LIBDIR)/$(SO_NAME_$(OS))
ln -sf $(LIBDIR)/$(SO_NAME_INSTALL_$(OS)) $(LIBDIR)/$(SO_NAME_MAJOR_$(OS))
else
cp target/$(build_mode)/$(SO_NAME_$(OS)).a $(LIBDIR)/$(SO_NAME_INSTALL_$(OS)).a
cp target/$(build_mode)/rav1e.def $(LIBDIR)/rav1e.def
endif
cp include/rav1e.h $(INCDIR)
uninstall:
ifneq ($(OS),Msys)
-rm $(LIBDIR)/$(SO_NAME_INSTALL_$(OS))
else
-rm $(LIBDIR)/rav1e.def
endif
-rm $(LIBDIR)/$(SO_NAME_$(OS))
-rm $(LIBDIR)/pkgconfig/rav1e.pc
-rm $(LIBDIR)/$(STATIC_NAME)
-rm $(INCDIR)/rav1e.h
.PHONY: all install uninstall examples