-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile32
42 lines (32 loc) · 1.1 KB
/
Makefile32
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
KERNELNAME = os351
TOP = $(shell pwd)
OBJECTS_BOOT = boot/loader32.o
OBJECTS_KERN = kern/main.o kern/io.o kern/terminal.o
OBJECTS_LIBK = libk/stdio.o libk/string.o
OBJECTS_ALL = $(OBJECTS_BOOT) $(OBJECTS_KERN) $(OBJECTS_LIBK)
MAKE = make
CC_DEBUG = -g
AS_DEBUG = -g
export CC = gcc
export CFLAGS = -I$(TOP) -I$(TOP)/boot -I$(TOP)/kern -I$(TOP)/libk $(CC_DEBUG) -m32 -nostdinc -nostdlib -fno-builtin -fno-stack-protector -nostartfiles -nodefaultlibs -Wall -Wextra
export LD = ld
export LDFLAGS = -T link32.ld -z max-page-size=4096
export AS = nasm
export ASFLAGS = $(AS_DEBUG) -felf32
$(KERNELNAME).elf: $(OBJECTS_ALL)
$(MAKE) -f Makefile32 -C boot loader32.o
$(MAKE) -C kern main.o io.o terminal.o
$(MAKE) -C libk stdio.o string.o
$(LD) $(LDFLAGS) $(OBJECTS_ALL) -o $(KERNELNAME).elf
cp $(KERNELNAME).elf ISO/boot
grub-mkrescue -o $(KERNELNAME).iso ISO/
run: $(KERNELNAME).elf
$(QEMU) $(QEMU_FLAGS) -kernel $(KERNELNAME).elf
clean:
$(MAKE) -f Makefile32 -C boot clean
$(MAKE) -C kern clean
$(MAKE) -C libk clean
rm -f ISO/boot/$(KERNELNAME).elf
rm -f $(KERNELNAME).elf
rm -f $(KERNELNAME).iso
rm -f *.o