forked from i1i1/lampos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
61 lines (45 loc) · 1.43 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
KERNEL_LD = src/link-kernel.ld
STAGE2 = build/stage2_eltorito
GENISOIMAGE = genisoimage
CC = gcc
CFLAGS = -Wall -Iinclude -nostdlib -ffreestanding -m32 -std=gnu90
src = $(wildcard src/*.c)
hdr = $(wildcard include/*.h)
obj = $(subst src, build, $(src:.c=.o))
dep = $(subst src, build, $(src:.c=.d))
all: default
debug: CFLAGS += -DDEBUG
debug: make boot.iso test
default: CFLAGS += -Werror
default: make boot.iso
test: boot.iso
@qemu-system-i386 -kernel boot.bin -m 128M
boot.bin: src/boot.S $(obj)
$(CC) $(CFLAGS) -T $(KERNEL_LD) -o $@ $^ -lgcc
boot.iso: boot.bin
mkdir -p iso/boot/grub
cp $(STAGE2) iso/boot/grub/stage2_eltorito
cp boot.bin iso/boot/boot.bin
echo "default 0" > iso/boot/grub/menu.lst
echo "timeout 5" >> iso/boot/grub/menu.lst
echo "title LAMPOS Dev Starter Kit Kernel" >> iso/boot/grub/menu.lst
echo "kernel /boot/boot.bin" >> iso/boot/grub/menu.lst
$(GENISOIMAGE) -R -b boot/grub/stage2_eltorito -no-emul-boot\
-boot-load-size 4 -boot-info-table -quiet -o boot.iso iso/
build/%.o: src/%.c build/%.d
$(CC) $(CFLAGS) -c -T $(KERNEL_LD) -nostdlib -ffreestanding -o $@ $<
make: $(dep)
build/%.d: src/%.c
./makedeps.awk -v inc=include -v build=build $< > $@
# $(CC) $(CFLAGS) -MM $< | sed -e "s/^[^ \t]\+\.o:/build\/&/" > $@
clean:
rm -rf iso/
rm -rf boot.bin boot.iso
rm -rf $(obj)
cleandeps:
rm -rf $(dep)
.PHONY: clean debug test make
.SECONDARY: $(dep)
ifneq "$(MAKECMDGOALS)" "clean"
-include $(dep)
endif