-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
35 lines (26 loc) · 998 Bytes
/
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
OUTDIR=pkg
MODULE=luhn
.PHONY: default clean
default: test clean
$(OUTDIR):
@mkdir -p $(OUTDIR)
test: $(OUTDIR) $(OUTDIR)/$(MODULE).o $(OUTDIR)/$(MODULE)_o2.o $(OUTDIR)/$(MODULE)_o3.o $(OUTDIR)/main.o
gcc $(OUTDIR)/$(MODULE).o $(OUTDIR)/main.o -o $(OUTDIR)/luhn
gcc -o2 $(OUTDIR)/$(MODULE)_o2.o $(OUTDIR)/main.o -o $(OUTDIR)/test_o2
gcc -o3 $(OUTDIR)/$(MODULE)_o3.o $(OUTDIR)/main.o -o $(OUTDIR)/test_o3
@echo "\ntest [human optimised]"
@./$(OUTDIR)/luhn || echo "failed"
@echo "\ntest [automatic optimalisation level 2]"
@./$(OUTDIR)/test_o2 || echo "failed"
@echo "\ntest [automatic optimalisation level 3]"
@./$(OUTDIR)/test_o3 || echo "failed"
$(OUTDIR)/$(MODULE).o: src/$(MODULE).c
gcc -o $(OUTDIR)/$(MODULE).o -c $^
$(OUTDIR)/$(MODULE)_o2.o: src/$(MODULE).c
gcc -o2 -o $(OUTDIR)/$(MODULE)_o2.o -c $^
$(OUTDIR)/$(MODULE)_o3.o: src/$(MODULE).c
gcc -o3 -o $(OUTDIR)/$(MODULE)_o3.o -c $^
$(OUTDIR)/main.o: src/main.c
gcc -o $(OUTDIR)/main.o -c $^
clean:
@rm -rf $(OUTDIR)