forked from wapiflapi/CaH
-
Notifications
You must be signed in to change notification settings - Fork 0
/
chall_generic.mk
107 lines (81 loc) · 2.02 KB
/
chall_generic.mk
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
PLAYERDIR = player/
SERVERDIR = server/
DEVDIR ?= dev/
PLAYERFILES ?=
SERVERFILES ?=
PLAYERFILES := $(addprefix $(PLAYERDIR),$(PLAYERFILES))
SERVERFILES := $(addprefix $(SERVERDIR),$(SERVERFILES))
all: dev server player
# check for the impossible error
check:
@if [ $(shell realpath -s $(PLAYERDIR)) == "/" ]; \
then \
echo "PLAYERDIR is set to /. YOU DONT WANT THAT!"; \
fi; \
if [ $(shell realpath -s $(DEVDIR)) == "/" ]; \
then \
echo "DEVDIR is set to /. YOU DONT WANT THAT!"; \
fi; \
if [ $(shell realpath -s $(SERVERDIR)) == "/" ]; \
then \
echo "SERVERDIR is set to /. YOU DONT WANT THAT!"; \
fi;
# Setup server directory
server: $(SERVERFILES)
-@rmdir --ignore-fail-on-non-empty $(SERVERDIR) &> /dev/null || true
$(SERVERDIR)%: $(DEVDIR)%
@if [ ! -d $(SERVERDIR) ]; \
then \
mkdir -p $(SERVERDIR); \
fi;
cp -r $^ $(SERVERDIR)
# Setup player directory
player: $(PLAYERFILES)
-@rmdir --ignore-fail-on-non-empty $(PLAYERDIR) &> /dev/null || true
$(PLAYERDIR)%: $(DEVDIR)%
@if [ ! -d $(PLAYERDIR) ]; \
then \
mkdir -p $(PLAYERDIR); \
fi;
cp -r $^ $(PLAYERDIR)
# Exec sub-makefile
dev:
@if [ -f $(DEVDIR)Makefile ]; \
then \
make -C $(DEVDIR); \
fi;
# If some dependancy in DEVDIR are not present
# then there is probably a sub-makefile that can
# create them
$(DEVDIR)%:
@if [ -f $(DEVDIR)Makefile ]; \
then \
make -C $(DEVDIR) $(@:$(DEVDIR)%=%); \
fi;
clean:
@if [ -f $(DEVDIR)Makefile ]; \
then \
make -C dev/ clean; \
fi;
fclean: clean
$(RM) -r $(PLAYERFILES)
$(RM) -r $(SERVERFILES)
-@rmdir --ignore-fail-on-non-empty $(PLAYERDIR) &> /dev/null || true
-@rmdir --ignore-fail-on-non-empty $(SERVERDIR) &> /dev/null || true
@if [ -f $(DEVDIR)Makefile ]; \
then \
make -C dev/ fclean; \
fi;
real-fclean: fclean
$(RM) -r $(PLAYERDIR)
$(RM) -r $(SERVERDIR)
re: fclean all
# It would be nice to test the program
test:
@if [ -f test/test.py ]; \
then \
nosetests3 -v test/test.py; \
else \
echo "There is no test available"; \
fi;
.PHONY: all clean fclean dev re test real-fclean