2013-10-25 11:10:52 +00:00
|
|
|
# Binaries
|
2013-10-23 15:09:40 +00:00
|
|
|
RUSTC ?= rustc
|
2013-10-25 11:10:52 +00:00
|
|
|
RM = rm
|
2013-10-23 15:09:40 +00:00
|
|
|
|
2013-10-25 11:10:52 +00:00
|
|
|
# Flags
|
2013-10-23 15:09:40 +00:00
|
|
|
RUSTCFLAGS :=
|
2013-10-25 11:10:52 +00:00
|
|
|
RMFLAGS :=
|
2013-10-23 15:09:40 +00:00
|
|
|
|
2013-10-25 11:10:52 +00:00
|
|
|
# Output names
|
2013-10-23 15:09:40 +00:00
|
|
|
EXES := false printenv true yes cat whoami
|
|
|
|
TESTS := cat
|
|
|
|
|
2013-10-25 11:10:52 +00:00
|
|
|
# Utils stuff
|
2013-10-23 15:21:23 +00:00
|
|
|
EXES_PATHS := $(addprefix build/,$(EXES))
|
|
|
|
|
2013-10-23 15:09:40 +00:00
|
|
|
command = sh -c '$(1)'
|
|
|
|
|
2013-10-25 11:10:52 +00:00
|
|
|
# Main exe build rule
|
2013-10-23 15:09:40 +00:00
|
|
|
define EXE_BUILD
|
|
|
|
build/$(1): $(1)/$(1).rs
|
|
|
|
$(call command,$(RUSTC) $(RUSTCFLAGS) -o build/$(1) $(1)/$(1).rs)
|
|
|
|
endef
|
|
|
|
|
2013-10-25 11:10:52 +00:00
|
|
|
# Test exe built rules
|
2013-10-23 15:09:40 +00:00
|
|
|
define TEST_BUILD
|
|
|
|
test_$(1): tmp/$(1)_test
|
|
|
|
$(call command,tmp/$(1)_test)
|
|
|
|
|
|
|
|
tmp/$(1)_test: $(1)/test.rs
|
|
|
|
$(RUSTC) $(RUSTCFLAGS) -o tmp/$(1)_test $(1)/test.rs
|
|
|
|
endef
|
|
|
|
|
2013-10-25 11:10:52 +00:00
|
|
|
# Main rules
|
2013-10-23 15:09:40 +00:00
|
|
|
all: build $(EXES_PATHS)
|
|
|
|
|
|
|
|
test: tmp $(addprefix test_,$(TESTS))
|
|
|
|
rm -rf tmp
|
|
|
|
|
|
|
|
clean:
|
|
|
|
rm -rf build tmp
|
|
|
|
|
2013-08-02 17:24:20 +00:00
|
|
|
build:
|
|
|
|
mkdir build
|
2013-10-23 15:09:40 +00:00
|
|
|
|
|
|
|
tmp:
|
2013-10-22 13:31:51 +00:00
|
|
|
mkdir tmp
|
|
|
|
|
2013-10-25 11:10:52 +00:00
|
|
|
# Creating necessary rules for each targets
|
2013-10-23 15:09:40 +00:00
|
|
|
$(foreach exe,$(EXES),$(eval $(call EXE_BUILD,$(exe))))
|
|
|
|
$(foreach test,$(TESTS),$(eval $(call TEST_BUILD,$(test))))
|
|
|
|
|
|
|
|
.PHONY: all test clean
|