-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
76 lines (59 loc) · 1.42 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
CC=clang
CFLAGS = -std=c11 -Wall -pedantic -Iinclude -Wall -O3 -laio
SRC_FILES = $(wildcard src/*.c) $(wildcard src/*/*.c)
FILES = $(basename $(SRC_FILES:src/%=%))
OBJ_FILES = $(addprefix obj/,$(FILES:=.o))
TEST_FILES = $(join $(dir $(addprefix bin/tests/,$(FILES))), $(addprefix test_,$(notdir $(FILES))))
VERSION = v0.1.0
.PHONY: all
all: bin/example bin/bdev bin/guest0 $(TESTS)
.PHONY: clean
clean:
@rm -rf obj
@rm -rf bin
.PHONY: build
build: $(TESTS) $(OBJ_FILES)
obj/%.o: src/%.c
@mkdir -p $(dir $@)
@$(CC) -c $(CFLAGS) $^ -o $@
bin/tests/%: tests/%.c $(OBJ_FILES)
@mkdir -p $(dir $@)
@$(CC) $(CFLAGS) $^ -o $@
obj/guest0.o: main/guest0.S
@mkdir -p $(dir $@)
@as -32 $^ -o $@
bin/guest0: obj/guest0.o
@mkdir -p $(dir $@)
@ld -m elf_i386 --oformat binary -N -e _start -Ttext 0x10000 -o $@ $^
bin/example: main/example.c $(OBJ_FILES)
@mkdir -p $(dir $@)
@$(CC) $(CFLAGS) $^ -o $@
bin/bdev: main/bdev.c $(OBJ_FILES)
@mkdir -p $(dir $@)
@$(CC) $(CFLAGS) $^ -o $@
# suppress error for missing test file
bin/tests/%:
@:
.PHONY: object-files
object-files:
@echo $(OBJ_FILES)
.PHONY: test
test: $(TEST_FILES)
tests/run.sh $(TEST_FILES)
.PHONY: version
version:
@echo ${VERSION}
.PHONY: list-deps
list-deps:
@:
.PHONY: install-deps
install-deps:
@:
.PHONY: build-deps
build-deps:
@:
.PHONY: lint
lint:
@for file in $(SRC_FILES); do \
clang-tidy $$file --checks=clang-analyzer-*,performance-* -- $(CFLAGS); \
done