-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathMakefile
More file actions
46 lines (36 loc) · 1.05 KB
/
Makefile
File metadata and controls
46 lines (36 loc) · 1.05 KB
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
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 deps -C $$dep && $(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 $(TEST)
install:
@cp $(wildcard $(LIB)) $(SYSLIBDIR)
examples: $(BUILD) lib install $(EXAMPLESRCS)
@mkdir -p $(BUILD)/examples
@for example in $(EXAMPLESRCS) ; do \
$(RUSTC) $$example --out-dir $(BUILD)/examples || exit 1; \
done