-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
53 lines (39 loc) · 1.18 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
CC = x86_64-elf-gcc
LD = x86_64-elf-gcc
AS = x86_64-elf-as
RM = rm -rf
OUTPUT_DIR = build
CPPFLAGS += -I"/home/pascal/Dokumente/YourOS/src/Bootloader/kernel" -I"/home/pascal/Dokumente/YourOS/src/Bootloader/kernel/boott"
CFLAGS += -nostdinc -g3 -gdwarf-4 -Wall -Wextra -fmessage-length=0 -m32 -ffreestanding -std=gnu99 -mno-sse
LDFLAGS += -nostartfiles -nodefaultlibs -nostdlib -static -T./bootloader.ld -z max-page-size=0x1000
C_SRCS = $(shell find -name '*.c')
S_SRCS = ./kernel/boott/boot.S
C_OBJS = $(patsubst ./%,$(OUTPUT_DIR)/%,$(C_SRCS:.c=.o))
S_OBJS = $(patsubst ./%,$(OUTPUT_DIR)/%,$(S_SRCS:.S=.o))
OBJS := $(C_OBJS) $(S_OBJS)
DEPS := $(OBJS:.o=.d)
ifeq ($(BUILD_CONFIG), release)
CFLAGS += -O3
else
CFLAGS += -Og
endif
.PHONY: all
all: bootloader
.PHONY: release
release:
$(MAKE) BUILD_CONFIG=$@
.PHONY: bootloader
bootloader: $(OUTPUT_DIR)/bootloader
#Pull in dependency info for *existing* .o files
-include $(DEPS)
$(OUTPUT_DIR)/bootloader: $(OBJS)
$(LD) $(LDFLAGS) -o $@ $^
$(OUTPUT_DIR)/%.o: %.c
@mkdir -p $(@D)
$(CC) $(CFLAGS) $(CPPFLAGS) -MMD -MP -MT $@ -c $< -o $@
$(OUTPUT_DIR)/%.o: %.S
@mkdir -p $(@D)
$(AS) -32 -o $@ $<
.PHONY: clean
clean:
-$(RM) $(OUTPUT_DIR)