-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
62 lines (49 loc) · 1.43 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
obj-m += ouichefs.o
ouichefs-objs := src/fs.o src/super.o src/inode.o src/file.o \
src/dir.o src/read.o src/write.o src/defrag.o src/ioctl.o
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
ENV_KERNELDIR := $(shell grep -Po '^KERNELDIR=\K.*' .env 2> /dev/null)
ifdef ENV_KERNELDIR
KERNELDIR := $(ENV_KERNELDIR)
endif
BUILDDIR := build
SHAREDIR := share
define move_files
mkdir -p $(SHAREDIR)
mkdir -p $(BUILDDIR)
cp ouichefs.ko $(SHAREDIR)/ouichefs.ko
mv .*.cmd src/.*.cmd *.o src/*.o *.ko *.mod \
*.mod.c *.symvers *.order $(BUILDDIR)
endef
all: module user scripts
module:
# module
make -C $(KERNELDIR) M=$(PWD) modules
$(call move_files)
user: test test_insert test_cached bench bench_insert demo
test:
$(CC) -static src/user/test.c -o $(SHAREDIR)/test.o
test_insert:
$(CC) -static src/user/test_insert.c -o $(SHAREDIR)/test_insert.o
test_cached:
$(CC) -static src/user/test_cached.c -o $(SHAREDIR)/test_cached.o
bench:
$(CC) -static src/user/bench.c -o $(SHAREDIR)/bench.o
bench_insert:
$(CC) -static src/user/bench_insert.c -o $(SHAREDIR)/bench_insert.o
demo :
$(CC) -static src/user/demo.c -o $(SHAREDIR)/demo.o
scripts:
# copy scripts
cp scripts/run.sh $(SHAREDIR)
img:
make -C mkfs img
check:
./check/checkpatch.pl -f -q --no-tree src/*.c
debug:
make -C $(KERNELDIR) M=$(PWD) ccflags-y+="-DDEBUG -g" modules
$(call move_files)
clean:
make -C $(KERNELDIR) M=$(PWD) clean
rm -rf *~
.PHONY: all clean check scripts