This repository was archived by the owner on Jan 19, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
62 lines (48 loc) · 1.24 KB
/
Makefile
File metadata and controls
62 lines (48 loc) · 1.24 KB
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
# SPDX-License-Identifier: BSD-2-Clause
.POSIX:
ARCH = i386
K = kernel
C = libc
KARCH = $(K)/arch/$(ARCH)
CARCH = $(C)/arch/$(ARCH)
AS = i686-elf-as
AR = i686-elf-ar
CC = i686-elf-cc
C3C = c3c
CFLAGS = -std=c99 -Wall -Wextra -Wpedantic -Werror
C3FLAGS = --obj-out kernel --output-dir kernel --no-headers
LDFLAGS = -ffreestanding -nostdlib -T $(KARCH)/linker.ld -Lkernel -lkernel -lgcc
BIN = kernel.elf
LIB = libc.a
LIBKERNEL = kernel/libkernel.a
OBJS = $(KARCH)/boot.o $(LIBKERNEL)
CRT = $(CARCH)/crti.o $(CARCH)/crtn.o
LIB_OBJS =
all: $(BIN) $(LIB)
$(BIN): $(OBJS)
@echo " LD $@"
@$(CC) $(OBJS) $(LDFLAGS) -o $@
@echo "========== kernel image compiled =========="
$(LIB): $(LIB_OBJS) $(CRT)
@echo " C3C $@"
@$(C3C) build libc --obj-out libc --output-dir libc --no-headers
@rmdir build
@echo " AR $@"
@$(AR) rcs $@ $(LIB_OBJS) libc/*.o
@echo "========== libc.a library compiled =========="
$(LIBKERNEL):
@echo " C3C $@"
@$(C3C) build libkernel $(C3FLAGS) -o $@
@rmdir build
.c.o:
@echo " CC $<"
@$(CC) $(CFLAGS) -c $< -o $@
.s.o:
@echo " AS $<"
@$(AS) -c $< -o $@
clean:
rm -f $(BIN) $(LIB) $(CRT) $(OBJS) $(LIB_OBJS) libc/*.o -r rootfs output.iso
iso: all
./scripts/iso.sh
.PHONY: all clean iso
.SUFFIXES: .c .c3 .s