2013-10-25 11:10:52 +00:00
|
|
|
# Binaries
|
2013-10-25 16:00:39 +00:00
|
|
|
RUSTC ?= rustc
|
|
|
|
RM := rm
|
2013-10-23 15:09:40 +00:00
|
|
|
|
2013-10-25 11:10:52 +00:00
|
|
|
# Flags
|
2014-02-07 06:39:07 +00:00
|
|
|
RUSTCFLAGS := --opt-level=3
|
2013-10-25 16:00:39 +00:00
|
|
|
RMFLAGS :=
|
2013-10-23 15:09:40 +00:00
|
|
|
|
2013-12-27 07:48:38 +00:00
|
|
|
# Possible programs
|
|
|
|
PROGS := \
|
2013-12-20 19:34:45 +00:00
|
|
|
base64 \
|
2014-01-07 00:54:02 +00:00
|
|
|
basename \
|
2013-12-02 11:50:24 +00:00
|
|
|
cat \
|
2013-12-03 09:29:32 +00:00
|
|
|
dirname \
|
2013-12-02 11:50:24 +00:00
|
|
|
echo \
|
|
|
|
env \
|
|
|
|
false \
|
2014-01-01 23:32:21 +00:00
|
|
|
mkdir \
|
2013-12-02 11:50:24 +00:00
|
|
|
printenv \
|
2013-12-05 11:36:08 +00:00
|
|
|
pwd \
|
2013-12-18 06:09:32 +00:00
|
|
|
rm \
|
2013-12-18 18:39:23 +00:00
|
|
|
rmdir \
|
2013-12-18 17:26:42 +00:00
|
|
|
sleep \
|
2014-02-05 19:46:28 +00:00
|
|
|
seq \
|
2013-12-23 17:12:26 +00:00
|
|
|
tee \
|
2013-12-02 11:50:24 +00:00
|
|
|
true \
|
2014-02-01 05:18:57 +00:00
|
|
|
truncate \
|
2014-01-16 01:51:43 +00:00
|
|
|
users \
|
2013-12-02 11:50:24 +00:00
|
|
|
wc \
|
|
|
|
yes \
|
2014-01-10 08:23:12 +00:00
|
|
|
tty \
|
2013-12-10 01:59:41 +00:00
|
|
|
hostname \
|
2013-12-02 11:50:24 +00:00
|
|
|
|
2014-02-08 03:35:03 +00:00
|
|
|
UNIX_PROGS := \
|
|
|
|
whoami \
|
|
|
|
|
|
|
|
ifneq ($(OS),Windows_NT)
|
|
|
|
PROGS := $(PROGS) $(UNIX_PROGS)
|
|
|
|
endif
|
|
|
|
|
2013-12-27 07:48:38 +00:00
|
|
|
BUILD ?= $(PROGS)
|
|
|
|
|
|
|
|
# Output names
|
|
|
|
EXES := \
|
2014-02-08 03:35:03 +00:00
|
|
|
$(sort $(filter $(BUILD),$(filter-out $(DONT_BUILD),$(PROGS))))
|
2013-12-02 11:50:24 +00:00
|
|
|
|
2013-12-27 21:32:56 +00:00
|
|
|
# Programs with usable tests
|
|
|
|
TEST_PROGS := \
|
2013-12-02 11:50:24 +00:00
|
|
|
cat \
|
2014-01-05 22:22:04 +00:00
|
|
|
mkdir \
|
2014-02-05 19:46:28 +00:00
|
|
|
seq \
|
2014-02-04 06:54:57 +00:00
|
|
|
truncate \
|
2013-12-02 11:50:24 +00:00
|
|
|
|
2013-12-27 21:32:56 +00:00
|
|
|
TEST ?= $(TEST_PROGS)
|
|
|
|
|
|
|
|
TESTS := \
|
|
|
|
$(filter $(TEST),$(filter-out $(DONT_TEST),$(filter $(BUILD),$(filter-out $(DONT_BUILD),$(TEST_PROGS)))))
|
2013-10-23 15:09:40 +00:00
|
|
|
|
2013-10-25 11:10:52 +00:00
|
|
|
# Utils stuff
|
2013-10-25 16:00:39 +00:00
|
|
|
EXES_PATHS := $(addprefix build/,$(EXES))
|
2013-10-25 16:33:24 +00:00
|
|
|
command = sh -c '$(1)'
|
2013-10-23 15:09:40 +00:00
|
|
|
|
2013-10-25 11:10:52 +00:00
|
|
|
# Main exe build rule
|
2013-10-23 15:09:40 +00:00
|
|
|
define EXE_BUILD
|
2013-11-27 23:19:21 +00:00
|
|
|
build/$(1): $(1)/$(1).rs
|
2013-10-23 15:09:40 +00:00
|
|
|
$(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
|
2013-11-27 23:19:21 +00:00
|
|
|
test_$(1): tmp/$(1)_test build build/$(1)
|
2013-10-23 15:09:40 +00:00
|
|
|
$(call command,tmp/$(1)_test)
|
|
|
|
|
2013-10-25 16:00:39 +00:00
|
|
|
tmp/$(1)_test: $(1)/test.rs
|
2013-11-27 23:14:19 +00:00
|
|
|
$(call command,$(RUSTC) $(RUSTCFLAGS) --test -o tmp/$(1)_test $(1)/test.rs)
|
2013-10-23 15:09:40 +00:00
|
|
|
endef
|
|
|
|
|
2013-10-25 11:10:52 +00:00
|
|
|
# Main rules
|
2013-10-25 16:00:39 +00:00
|
|
|
all: build $(EXES_PATHS)
|
2013-10-23 15:09:40 +00:00
|
|
|
|
2013-10-25 16:00:39 +00:00
|
|
|
test: tmp $(addprefix test_,$(TESTS))
|
|
|
|
$(RM) -rf tmp
|
2013-10-23 15:09:40 +00:00
|
|
|
|
|
|
|
clean:
|
2013-10-25 16:00:39 +00:00
|
|
|
$(RM) -rf build tmp
|
2013-10-23 15:09:40 +00:00
|
|
|
|
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))))
|
|
|
|
|
2013-10-25 16:00:39 +00:00
|
|
|
.PHONY: all test clean
|