-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
64 lines (57 loc) · 1.6 KB
/
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
ASSIGNMENT_NAME := assignment3
BASE_URL := https://cs140e.sergio.bz
SUBMISSION_SITE := $(BASE_URL)/assignments/submission/
SUBMIT_TAR := $(ASSIGNMENT_NAME).tar.gz
CS140E_REL_ROOT := ..
REPO_NAMES := 0-blinky 1-shell 2-fs 3-spawn os
QUESTIONS_DIRS := $(shell find . -type d -name "questions")
.PHONY: all check submission clean
all:
@echo "usage: make [target]"
@echo
@echo "available targets:"
@echo "check ensure every question is answered"
@echo "submission create submission tarball"
@echo "clean clean products from all targets"
check:
@okay=true; \
for qdir in $(QUESTIONS_DIRS); do \
for file in "$${qdir}/"*; do \
if ! [ -s "$${file}" ]; then \
okay=false; \
echo "Question file '$${file}' is empty."; \
fi \
done \
done; \
if ! $$okay; then \
echo "Questions remain unanswered. Aborting."; \
exit 1; \
else \
echo "All questions appear to be answered."; \
fi
.FORCE:
$(SUBMIT_TAR): .FORCE
@rm -f $@
@cwd="$${PWD}"; \
for repo in $(REPO_NAMES); do \
repo_path="$${cwd}/$(CS140E_REL_ROOT)/$${repo}"; \
cd "$${repo_path}"; \
if ! [ -z "$$(git status --porcelain)" ]; then \
echo "There are uncommited changes in $${repo}! Aborting."; \
rm -f $@; \
exit 1; \
else \
git_files=$$(git ls-files) ; \
cd "$${repo_path}/.." ; \
for file in $$git_files; do \
tar -rf "$${cwd}/$@" "$${repo}/$${file}"; \
done \
fi \
done
@gzip -f $@
@mv $@.gz $@
submission: $(SUBMIT_TAR)
@echo "Your submission file "$^" was successfully created."
@echo "Submit it at $(SUBMISSION_SITE)"
clean:
rm -f $(SUBMIT_TAR)