-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathMakefile
61 lines (43 loc) · 1.71 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
MAKEFLAGS += --quiet
TARGETS = cubepro-encoder cubex-encoder cube3-encoder cube-decoder
LIBS = -lm
CC = gcc
CFLAGS += -g -Wall
OBJECTS = $(patsubst %.c, %.o, $(wildcard *.c))
HEADERS = $(wildcard *.h)
TESTFILES = $(wildcard tests/*.bfb)
CUBEPROTESTS = $(patsubst %.bfb, %.resultpro, $(TESTFILES)) $(patsubst %.bfb, %.result.decodepro, $(TESTFILES))
CUBEXTESTS = $(patsubst %.bfb, %.resultx, $(TESTFILES)) $(patsubst %.bfb, %.result.decodex, $(TESTFILES))
TESTOUTPUTS = $(CUBEPROTESTS) $(CUBEXTESTS)
.PHONY: default all clean test
all: $(TARGETS)
%.o: %.c $(HEADERS)
$(CC) $(CFLAGS) -c $< -o $@
.PRECIOUS: $(TARGETS) $(OBJECTS)
cubepro-encoder: cube-encoder.o blowfish.o
$(CC) $^ -Wall $(LIBS) -o $@
cubex-encoder: cubepro-encoder
cp $^ $@
cube3-encoder: cubepro-encoder
cp $^ $@
cube-decoder: cube-decoder.o blowfish.o
$(CC) $^ -Wall $(LIBS) -o $@
%.resultpro: %.bfb cubepro-encoder
./cubepro-encoder $< $(patsubst %.bfb, %.resultpro, $<)
diff $(patsubst %.bfb, %.cubepro, $<) $(patsubst %.bfb, %.resultpro, $<)
%.resultx: %.bfb cubex-encoder
./cubex-encoder $< $(patsubst %.bfb, %.resultx, $<)
diff $(patsubst %.bfb, %.cubex, $<) $(patsubst %.bfb, %.resultx, $<)
%.result.decodepro: %.resultpro cube-decoder
./cube-decoder $< $(patsubst %.resultpro, %.result.decodepro, $<)
diff $(patsubst %.resultpro, %.bfb, $<) $(patsubst %.resultpro, %.result.decodepro, $<)
%.result.decodex: %.resultx cube-decoder
./cube-decoder -x $< $(patsubst %.resultx, %.result.decodex, $<)
diff $(patsubst %.resultx, %.bfb, $<) $(patsubst %.resultx, %.result.decodex, $<)
test: test_clean $(TARGETS) $(TESTOUTPUTS)
echo "All tests completed successfully"
test_clean:
-rm -f tests/*.result*
clean: test_clean
-rm -f *.o
-rm -f $(TARGETS)