-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
44 lines (34 loc) · 983 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
37
38
39
40
41
42
43
44
SRC ?= src
BUILD ?= build
RUSTC ?= rustc
ARCH ?= $(shell $(RUSTC) -v | grep host | cut -f 2 -d ' ')
SYSLIBDIR ?= /usr/local/lib/rustlib/$(ARCH)/lib
DEPS ?= $(wildcard deps/*)
PROJNAME ?= $(subst rust-,,$(shell basename $(CURDIR)))
LIBSRC ?= $(SRC)/$(PROJNAME)/lib.rs
LIB ?= $(BUILD)/lib$(PROJNAME)-*.rlib
EXAMPLESRCS ?= $(wildcard $(SRC)/examples/*.rs)
.PHONY: all clean cleandeps deps lib test install examples
all: test
$(BUILD):
mkdir -p $(BUILD)
clean: cleandeps
rm -rf $(BUILD)/* || true
cleandeps:
@for dep in $(DEPS) ; do \
$(MAKE) -w -C $$dep clean ; \
done
deps:
@for dep in $(DEPS) ; do \
$(MAKE) -w -C $$dep && $(MAKE) -w -C $$dep install ; \
done
lib: $(BUILD) $(LIBSRC)
$(RUSTC) --out-dir $(BUILD) $(LIBSRC)
test: lib
$(RUSTC) --test -o $(BUILD)/test $(LIBSRC)
$(BUILD)/test
install:
cp $(wildcard $(LIB)) $(SYSLIBDIR)
examples: $(BUILD) lib install $(EXAMPLESRCS)
mkdir -p $(BUILD)/examples
$(RUSTC) $(EXAMPLESRCS) --out-dir $(BUILD)/examples