-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
45 lines (33 loc) · 1.08 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
SRC_DIR = src
OBJ_DIR = build
INCL_DIR = include
TESTS = bible frost gophers liam odyssey raven simple
EXE = huffman
SRC = $(wildcard $(SRC_DIR)/*.c)
OBJ = $(SRC:$(SRC_DIR)/%.c=$(OBJ_DIR)/%.o)
CC = gcc
CFLAGS = -Wall -I $(INCL_DIR) -O2
.PHONY: all clean
all: $(EXE)
$(EXE): $(OBJ)
$(CC) $(CFLAGS) -o $(EXE) $(OBJ)
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c | $(OBJ_DIR)
$(CC) $(CFLAGS) -c $< -o $@
test:
make
for name in $(TESTS) ; do \
./$(EXE) 0 tests/$$name.txt output/compression/$$name.huf ; \
./$(EXE) 1 output/compression/$$name.huf output/decompression/$${name}_dec.txt ; \
diff tests/$$name.txt output/decompression/$${name}_dec.txt ; \
done
leaks:
make
leaks -atExit -- ./$(EXE) 0 tests/gophers.txt output/compression/gophers.huf
leaks -atExit -- ./$(EXE) 1 output/compression/gophers.huf output/decompression/gophers_dec.txt
leaks -atExit -- ./$(EXE) 0 tests/bible.txt output/compression/bible.huf
leaks -atExit -- ./$(EXE) 1 output/compression/bible.huf output/decompression/bible_dec.txt
clean:
rm $(EXE)
rm build/*.o;
rm output/compression/*;
rm output/decompression/*;