-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
78 lines (61 loc) · 2.12 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
77
78
# Makefile for EvoOS Kernel
# Compiler and flags
CC := gcc
CFLAGS := -Wall -Wextra -O2 -I/usr/src/linux-headers-6.2.0-1018-aws/include -I/usr/src/linux-headers-6.2.0-1018-aws/arch/x86/include/generated -I/usr/src/linux-headers-6.2.0-1018-aws/arch/x86/include
# Directories
SRCDIR := src
INCDIR := include
OBJDIR := obj
SECDIR := security
# Source files
CORE_SRC := $(wildcard $(SRCDIR)/core/*.c)
FS_SRC := $(wildcard $(SRCDIR)/fs/*.c)
MM_SRC := $(wildcard $(SRCDIR)/mm/*.c)
PM_SRC := $(wildcard $(SRCDIR)/pm/*.c)
DD_SRC := $(wildcard $(SRCDIR)/drivers/*.c)
SEC_SRC := $(wildcard $(SECDIR)/*/*.c)
UI_SRC := $(wildcard $(SRCDIR)/ui/*.c)
# Object files
CORE_OBJ := $(patsubst $(SRCDIR)/core/%.c,$(OBJDIR)/core/%.o,$(CORE_SRC))
FS_OBJ := $(patsubst $(SRCDIR)/fs/%.c,$(OBJDIR)/fs/%.o,$(FS_SRC))
MM_OBJ := $(patsubst $(SRCDIR)/mm/%.c,$(OBJDIR)/mm/%.o,$(MM_SRC))
PM_OBJ := $(patsubst $(SRCDIR)/pm/%.c,$(OBJDIR)/pm/%.o,$(PM_SRC))
DD_OBJ := $(patsubst $(SRCDIR)/drivers/%.c,$(OBJDIR)/drivers/%.o,$(DD_SRC))
SEC_OBJ := $(patsubst $(SECDIR)/%.c,$(OBJDIR)/security/%.o,$(SEC_SRC))
UI_OBJ := $(patsubst $(SRCDIR)/ui/%.c,$(OBJDIR)/ui/%.o,$(UI_SRC))
# All object files
OBJ := $(CORE_OBJ) $(FS_OBJ) $(MM_OBJ) $(PM_OBJ) $(DD_OBJ) $(SEC_OBJ) $(UI_OBJ)
# Kernel image
KERNEL := evoos_kernel
# Phony targets
.PHONY: all clean
# Default target
all: $(KERNEL)
# Kernel image
$(KERNEL): $(OBJ)
$(CC) $(CFLAGS) -o $@ $^
# Object files
$(OBJDIR)/core/%.o: $(SRCDIR)/core/%.c
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) -I$(INCDIR) -c -o $@ $<
$(OBJDIR)/fs/%.o: $(SRCDIR)/fs/%.c
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) -I$(INCDIR) -c -o $@ $<
$(OBJDIR)/mm/%.o: $(SRCDIR)/mm/%.c
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) -I$(INCDIR) -c -o $@ $<
$(OBJDIR)/pm/%.o: $(SRCDIR)/pm/%.c
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) -I$(INCDIR) -c -o $@ $<
$(OBJDIR)/drivers/%.o: $(SRCDIR)/drivers/%.c
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) -I$(INCDIR) -c -o $@ $<
$(OBJDIR)/security/%.o: $(SECDIR)/%.c
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) -I$(INCDIR) -c -o $@ $<
$(OBJDIR)/ui/%.o: $(SRCDIR)/ui/%.c
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) -I$(INCDIR) -c -o $@ $<
# Clean
clean:
rm -rf $(OBJDIR) $(KERNEL)