-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathMakefile
148 lines (121 loc) · 3.66 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# Copyright(C) 2020, Bruno César Ribas <[email protected]>
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of version 2.1 of the GNU Lesser General Public License
# as published by the Free Software Foundation.
#
# This program is distributed in the hope that it would be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
SOURCE=$(wildcard *.c)
BINARY?=dummy\
bubblesort\
bubblesortsentinela\
combsort\
selectionsort\
selectionsortR\
insertionsortslow\
insertionsort\
shellsort\
quicksort\
quicksortinsertion\
quicksortM3\
quicksortM3insertion\
mergesort\
insertionsortmetades\
systemqsort\
introsortquickmerge\
introsortquickmergelongjmp\
introsortquickheaplongjmp\
radixsort\
redblacktreesort\
cppsort\
pqsortsimple\
heapsort\
countingsort\
bstsort
ORDENADO=$(wildcard input/*ordenado)
ALEATORIO=$(wildcard input/*aleatorio)
REVERSO=$(wildcard input/*reverso)
TIMEOUT?=0
CFLAGS=-O2 -static
CXXFLAGS=-O2 -static
all: input/.in ${BINARY}
check:
@for COMANDO in time timeout shuf md5sum sort bash gcc; do\
if ! which $$COMANDO >/dev/null; then\
echo "Faltando comando '$$COMANDO'";\
exit 1;\
fi;\
done
@echo "As dependências parecem estar todas presentes"
input/.in:
mkdir -p input
cd input && bash ../gera-entrada
touch input/.in
%: main.c %.c
gcc -D__$@__ $(CFLAGS) $^ -o $@
dummy: main.c
gcc -D__$@__ $(CFLAGS) $^ -o $@
quicksort: main.c quicksort.c separa.c
gcc -D__$@__ $(CFLAGS) $^ -o $@
quicksortinsertion: main.c quicksortinsertion.c separa.c insertionsort.c
gcc -D__$@__ $(CFLAGS) $^ -o $@
quicksortM3: main.c quicksortM3.c separa.c
gcc -D__$@__ $(CFLAGS) $^ -o $@
quicksortM3insertion: main.c quicksortM3insertion.c separa.c insertionsort.c
gcc -D__$@__ $(CFLAGS) $^ -o $@
insertionsortmetades: main.c insertionsortmetades.c mergesort.c insertionsort.c
gcc -D__$@__ $(CFLAGS) $^ -o $@ -lm
introsortquickmerge: main.c introsortquickmerge.c separa.c insertionsort.c mergesort.c
gcc -D__$@__ $(CFLAGS) $^ -o $@ -lm
introsortquickmergelongjmp: main.c introsortquickmergelongjmp.c separa.c insertionsort.c mergesort.c
gcc -D__$@__ $(CFLAGS) $^ -o $@ -lm
introsortquickheaplongjmp: main.c introsortquickheaplongjmp.c separa.c insertionsort.c heapsort.c priority-queue.c
gcc -D__$@__ $(CFLAGS) $^ -o $@ -lm
radixsort: main.c radixsort.c
gcc -D__$@__ $(CFLAGS) $^ -o $@ -lm
pqsortsimple: main.c pqsortsimple.c priority-queue.c
gcc -D__$@__ $(CFLAGS) $^ -o $@
heapsort: main.c heapsort.c priority-queue.c
gcc -D__$@__ $(CFLAGS) $^ -o $@
cppsort: main.c cppsort.cpp
g++ -D__$@__ $(CXXFLAGS) $^ -o $@
printorder:
@for T in 08 09 10 11 12 13 14 15 16 17 18 19 20;do\
printf " %s " $$T;\
done;\
echo
time.%: $(BINARY) input/.in
@echo "--- $@ ---"
@ulimit -s 32000
@for B in $(BINARY); do\
echo "# $$B";\
for F in input/*-$(subst time.,,$@);do\
printf " ";\
timeout $(TIMEOUT) time -f %e ./$$B < $$F >/dev/null|| echo " TLE";\
done 2>&1|tr -d '\n';\
echo;\
done | tee $@
teste: $(BINARY) input/.in
@for F in input/15*;do\
echo "# $$F";\
for B in $(BINARY); do\
printf "$$B ";\
timeout $(TIMEOUT) ./$$B < $$F |md5sum|| echo " TLE";\
done;\
echo;\
done
testesimples: $(BINARY)
@for B in $(BINARY); do \
REVERSO=$$(./$$B < input/10-reverso | md5sum | cut -d ' ' -f 1); \
REPETIDO=$$(./$$B < input/10-muitosrepetidos | md5sum | cut -d ' ' -f 1); \
printf "$$B - [$$REVERSO] [$$REPETIDO]\n"; \
done
echo%:
@echo
.PHONY: teste testesimples check
clean:
rm -f $(BINARY) time.*
dist-clean: clean
rm -rf input/