This repository has been archived by the owner on Mar 16, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
91 lines (64 loc) · 2.19 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
88
89
90
91
ifneq ($(wildcard /usr/local/bin/gcc-4.9),)
CC=gcc-4.9
else
CC=clang
endif
RM=rm -f
CFLAGS= -std=c11 -Ofast -pedantic -Wall -Wextra -funsigned-char
LDFLAGS=
LDLIBS=
# Uncomment for release
RELEASE:=1
ifeq ($(RELEASE),1)
# Release
CFLAGS+=-DNDEBUG
LDLIBS+=-s # Strip binary
else
# Debug
CFLAGS+=-g -fstack-protector-all
endif
BIN=ifj
SRCS=$(wildcard *.c)
OBJS=$(subst .c,.o,$(SRCS))
LEADER_NAME=xmikus15
all: $(BIN)
zip:
rm $(LEADER_NAME).zip || true
cp docs/dokumentace.pdf dokumentace.pdf
zip $(LEADER_NAME).zip *.c *.h Makefile rozdeleni rozsireni dokumentace.pdf
rm dokumentace.pdf
$(BIN): $(OBJS) lib.a
$(CC) $(LDFLAGS) -o $(BIN) $(BIN).o lib.a $(LDLIBS)
depend: .depend
.depend: $(SRCS)
rm -f ./.depend
$(CC) -MM $^>>./.depend;
.PHONY: test
lib.a: $(filter-out $(BIN).o, $(OBJS))
ar -rcs $@ $(filter-out $(BIN).o, $(OBJS))
playground: all
test -d "playground" && $(MAKE) -C playground || true
test: all
test -d "unit_tests" && $(MAKE) -C unit_tests || true
clean:
$(RM) *.o *.a $(BIN) core* *.zip
# Must be true at the end, because make clean fails unsuccessfully
test -d "unit_tests" && $(MAKE) -C unit_tests clean || true
test -d "playground" && $(MAKE) -C playground clean || true
dist-clean: clean
$(RM) *~ .dependtool
#
# IFJ 2014/2015 Test Makefie
#
# Stanislav Nechutný - xnechu01
#
TESTFILES=$(patsubst tests/%.pas, tests/%, $(shell ls tests/*.pas));
tests: ifj $(TESTFILES)
# Done
tests/%: tests/%.pas
@echo -e "\n"
-$(shell valgrind ./ifj $< < [email protected] > /dev/null 2> [email protected]; if [ $$(grep "ERROR SUMMARY: 0 errors from 0 contexts" [email protected] | wc -l) = "1" ]; then rm [email protected]; else /bin/echo -e "#"; grep "ERROR SUMMARY:" [email protected]; fi; )
-$(shell ./ifj $< > [email protected] 2> [email protected] < [email protected];echo "$$?" > [email protected];diff [email protected] [email protected] > /dev/null;if [ "$$?" = "0" ]; then diff [email protected] [email protected] > /dev/null; if [ "$$?" = "0" ]; then echo "# OK ... $@"; rm [email protected] [email protected] [email protected]; else echo "# ERROR ... $@"; fi; else echo "# ERROR ... $@"; fi)
sandwich:
-$(shell if [[ $$(whoami) == "root" ]] ; then echo "# Yes, my lord."; else echo "# You are not root!"; fi)
include .depend