-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
36 lines (28 loc) · 870 Bytes
/
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
CBINDGEN ?= cbindgen
CARGO ?= cargo
TARGET ?=
PROFILE ?= release
DESTINATION ?= .
CARGO_TARGET_DIR ?= ../../target
CARGO_OUTPUT_DIR := $(CARGO_TARGET_DIR)/$(TARGET)/$(PROFILE)
CARGOFLAGS += --target-dir $(CARGO_TARGET_DIR)
ifeq ($(PROFILE), release)
CARGOFLAGS += --release
endif
ifneq ($(TARGET),)
CARGOFLAGS += --target
CARGOFLAGS += $(TARGET)
endif
.PHONY: clean
# copy the library to the final destination, and strip the _ffi part
$(DESTINATION)/libmaybenot.a: $(CARGO_OUTPUT_DIR)/libmaybenot_ffi.a
cp $^ $@
# generate maybenot.h
maybenot.h: src/*.rs Cargo.toml cbindgen.toml
${CBINDGEN} -o maybenot.h
# build the static library
$(CARGO_OUTPUT_DIR)/libmaybenot_ffi.a: maybenot.h src/*.rs Cargo.toml cbindgen.toml
RUSTFLAGS="-C metadata=maybenot-ffi" ${CARGO} build $(CARGOFLAGS)
clean:
rm -f $(DESTINATION)/libmaybenot.a
${CARGO} clean $(CARGOFLAGS)