-
Notifications
You must be signed in to change notification settings - Fork 11
/
Makefile
87 lines (55 loc) · 1.64 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# Author: Dominik Harmim <[email protected]>
PACK = xharmi00
IS_IT_OK_DIR = is_it_ok_test
IS_IT_OK_SCRIPT = ./tests/is_it_ok.sh
DOC_DIR = doc
DOC = dokumentace.pdf
CC = gcc
CFLAGS = -std=c99 -Wall -Wextra -Werror
EXECUTABLE = ifj17_compiler
SRCS = *.c
OBJS = $(shell $(CC) $(CFLAGS) -MM $(SRCS) | grep ':' | cut -d ':' -f1 | tr '\n' ' ')
.PHONY: all
all: $(EXECUTABLE) clean_depdir
$(EXECUTABLE): $(OBJS)
.PHONY: pack
pack: clean $(PACK).tgz
$(PACK).tgz: $(DOC)
tar -czf $@ *.h *.c Makefile rozdeleni $^
.PHONY: clean_pack
clean_pack:
rm -f $(PACK).tgz
$(DOC):
cd $(DOC_DIR) && make
cp $(DOC_DIR)/$(DOC) $(DOC)
.PHONY: clean_doc
clean_doc:
rm -f $(DOC)
cd $(DOC_DIR) && make clean
.PHONY: is_it_ok
is_it_ok: $(PACK).tgz $(IS_IT_OK_SCRIPT) clean_is_it_ok
chmod +x $(IS_IT_OK_SCRIPT)
$(IS_IT_OK_SCRIPT) $(PACK).tgz $(IS_IT_OK_DIR)
.PHONY: clean_is_it_ok
clean_is_it_ok:
rm -rf $(IS_IT_OK_DIR)
.PHONY: clean
clean: clean_pack clean_is_it_ok clean_depdir clean_doc
rm -rf $(EXECUTABLE) *.o *.out *.dSYM/ log/
# #################### Auto-Dependency Generation #####################
DEPDIR := .d
$(shell mkdir -p $(DEPDIR) > /dev/null)
DEPFLAGS = -MT $@ -MMD -MP -MF $(DEPDIR)/$*.Td
.PHONY: clean_depdir
clean_depdir:
rm -rf $(DEPDIR)
COMPILE.c = $(CC) $(DEPFLAGS) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c
POSTCOMPILE = @mv -f $(DEPDIR)/$*.Td $(DEPDIR)/$*.d && touch $@
%.o: %.c
%.o: %.c $(DEPDIR)/%.d
$(COMPILE.c) $(OUTPUT_OPTION) $<
$(POSTCOMPILE)
$(DEPDIR)/%.d: ;
.PRECIOUS: $(DEPDIR)/%.d
include $(wildcard $(patsubst %, $(DEPDIR)/%.d, $(basename $(SRCS))))
# #####################################################################