-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathMakefile
79 lines (63 loc) · 2.11 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
prefix ?= /usr/local
exec_prefix = $(prefix)
bindir = $(exec_prefix)/bin
libdir = $(exec_prefix)/lib
includedir = $(prefix)/include
datarootdir = $(prefix)/share
datadir = $(datarootdir)
RELEASE = debug
SRC=Cargo.toml $(shell find src crates -type f -wholename '*src/*.rs' \
-o -name 'Cargo.toml' \
-o -name 'Cargo.lock')
CLI_SRC=cli/Cargo.toml $(shell find cli/src -type f -name '*.rs')
FFI_SRC=ffi/Cargo.toml ffi/build.rs $(shell find ffi/src -type f -name '*.rs')
PACKAGE=distinst
HEADER=target/$(PACKAGE).h
PKGCONFIG=target/$(PACKAGE).pc
VAPI=ffi/$(PACKAGE).vapi
DEBUG ?= 0
ifeq (0,$(DEBUG))
ARGSD += --release
RELEASE = release
endif
VENDORED ?= 0
ifneq ($(VENDORED),0)
ARGS += "--frozen"
endif
BINARY=target/$(RELEASE)/$(PACKAGE)
LIBRARY=target/$(RELEASE)/lib$(PACKAGE).so
.PHONY: all clean distclean install uninstall update
all: $(BINARY) $(LIBRARY) $(HEADER) $(PKGCONFIG)
clean:
cargo clean
cargo clean --manifest-path ffi/Cargo.toml
distclean: clean
rm -rf .cargo vendor
install:
install -D -m 0755 "$(BINARY)" "$(DESTDIR)$(bindir)/$(PACKAGE)"
install -D -m 0644 "$(LIBRARY)" "$(DESTDIR)$(libdir)/lib$(PACKAGE).so"
install -D -m 0644 "$(HEADER)" "$(DESTDIR)$(includedir)/$(PACKAGE).h"
install -D -m 0644 "$(PKGCONFIG)" "$(DESTDIR)$(libdir)/pkgconfig/$(PACKAGE).pc"
install -D -m 0644 "$(VAPI)" "$(DESTDIR)$(datadir)/vala/vapi/$(PACKAGE).vapi"
uninstall:
rm -f "$(DESTDIR)$(bindir)/$(PACKAGE)"
rm -f "$(DESTDIR)$(libdir)/lib$(PACKAGE).so"
rm -f "$(DESTDIR)$(includedir)/$(PACKAGE).h"
rm -f "$(DESTDIR)$(libdir)/pkgconfig/$(PACKAGE).pc"
rm -f "$(DESTDIR)$(datadir)/vala/vapi/$(PACKAGE).vapi"
update:
cargo update
tests: $(SRC)
cargo test $(ARGS)
for crate in crates/*; do \
cargo test $(ARGS) --manifest-path $$crate/Cargo.toml; \
done
$(BINARY): $(SRC) $(CLI_SRC)
cargo build --manifest-path cli/Cargo.toml $(ARGS) $(ARGSD)
$(LIBRARY) $(HEADER) $(PKGCONFIG).stub: $(SRC) $(FFI_SRC)
cargo build --manifest-path ffi/Cargo.toml $(ARGS) $(ARGSD)
$(PKGCONFIG): $(PKGCONFIG).stub
echo "libdir=$(libdir)" > "$@.partial"
echo "includedir=$(includedir)" >> "$@.partial"
cat "$<" >> "$@.partial"
mv "$@.partial" "$@"