-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
38 lines (28 loc) · 877 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
36
37
38
CC ?= gcc
LD ?= ld
CFLAGS := -g -m64 -mno-red-zone -mno-mmx -mno-sse -mno-sse2 -ffreestanding \
-mcmodel=kernel -Wall -Wextra -Werror -pedantic -std=c99 \
-Wframe-larger-than=1024 -Wstack-usage=1024 \
-Wno-unknown-warning-option $(if $(DEBUG),-DDEBUG)
LFLAGS := -nostdlib -z max-page-size=0x1000
INC := ./inc
SRC := ./src
C_SOURCES := $(wildcard $(SRC)/*.c)
C_OBJECTS := $(C_SOURCES:.c=.o)
C_DEPS := $(C_SOURCES:.c=.d)
S_SOURCES := $(wildcard $(SRC)/*.S)
S_OBJECTS := $(S_SOURCES:.S=.o)
S_DEPS := $(S_SOURCES:.S=.d)
OBJ := $(C_OBJECTS) $(S_OBJECTS)
DEP := $(C_DEPS) $(S_DEPS)
all: kernel
kernel: $(OBJ) kernel.ld
$(LD) $(LFLAGS) -T kernel.ld -o $@ $(OBJ)
$(S_OBJECTS): %.o: %.S
$(CC) -D__ASM_FILE__ -I$(INC) -g -MMD -c $< -o $@
$(C_OBJECTS): %.o: %.c
$(CC) $(CFLAGS) -I$(INC) -g -MMD -c $< -o $@
-include $(DEP)
.PHONY: clean
clean:
rm -f kernel $(OBJ) $(DEP)