-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
50 lines (42 loc) · 1.44 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
# ==============================
# DO NOT EDIT THIS FILE
# Created by: Endadul Hoque
# ==============================
# This Makefile is used easily clean each
# sub-directories and create the compressed tarball
# for submission.
# ==================================================
#
.PHONY: all distclean submit clean
PA := proj2
SUBDIRS := project-2
all:
$(error does nothing! valid command is 'make distclean' or 'make submit')
distclean:
@for dir in $(SUBDIRS); do \
$(MAKE) -C $$dir clean || exit 1; \
done
#========================================
#============ For submission ============
#========================================
USERNAME := $(shell echo $${USER})
PKG_DIR := $(USERNAME)-$(PA)
CPKG := $(PKG_DIR).tar.gz
clean:
@rm -rf $(CPKG) $(PKG_DIR)
submit:
ifeq (, $(USERNAME))
$(error Failed to resolve your username. Please contact TA.)
else
@echo 'Preparing submission for $(USERNAME)'
@rm -rf $(CPKG) $(PKG_DIR)
@echo 'Creating a new directory $(PKG_DIR)'
@mkdir $(PKG_DIR)
@find $(SUBDIRS)/source -name "*.cpp" -exec cp --parents {} $(USER)-$(PA)/ \;
@find $(SUBDIRS)/headers -name "*.h" -exec cp --parents {} $(USER)-$(PA)/ \;
@echo 'Creating archive $(CPKG)'
@tar -czf $(CPKG) $(PKG_DIR)
@rm -rf $(USER)-$(PA)
@echo "\nYour submission is ready to submit. To verify its content, try this 'tar tvzf $(CPKG)'."
@echo "\n***Please keep $(CPKG) here and specify its full path, including the file name, in your report.***\n"
endif