2016-04-30 13:10:28 +00:00
|
|
|
|
2016-05-01 18:22:12 +00:00
|
|
|
AS=gcc
|
|
|
|
CC=gcc
|
|
|
|
CXX=g++
|
2016-04-30 13:10:28 +00:00
|
|
|
LD=ld
|
|
|
|
|
2016-05-05 15:06:11 +00:00
|
|
|
IDT_DISPATCH = _ZN3IDT8dispatchEP8CpuState
|
|
|
|
|
2016-05-07 17:55:59 +00:00
|
|
|
FLAGS = -mno-sse -DIDT_DISPATCH=$(IDT_DISPATCH) -ffreestanding -m32 -Werror -Wall -iquote include -iquote lists -I../stdlib/include -O3 -g
|
2016-04-30 13:10:28 +00:00
|
|
|
ASFLAGS = $(FLAGS)
|
2016-05-01 18:22:12 +00:00
|
|
|
CFLAGS = $(FLAGS)
|
|
|
|
CXXFLAGS = $(FLAGS) -std=c++14 -fno-rtti -fno-exceptions -fno-leading-underscore -fno-use-cxa-atexit -nostdlib -fno-builtin
|
2016-04-30 13:10:28 +00:00
|
|
|
|
2016-05-01 18:22:12 +00:00
|
|
|
SRCS = $(shell find -regextype egrep -regex '.*/.*\.(cpp|S|c)')
|
2016-04-30 13:10:28 +00:00
|
|
|
OBJS = $(addsuffix .o, $(notdir $(basename $(SRCS))))
|
|
|
|
|
2016-05-04 15:19:40 +00:00
|
|
|
LIBGCC = $(shell gcc -m32 -print-libgcc-file-name)
|
2016-05-07 17:55:59 +00:00
|
|
|
LIBSTD = ../stdlib/libstd.a
|
2016-05-04 15:19:40 +00:00
|
|
|
|
2016-04-30 13:10:28 +00:00
|
|
|
all: kernel-base.ker
|
|
|
|
|
|
|
|
kernel-base.ker: $(OBJS)
|
2016-05-07 17:55:59 +00:00
|
|
|
$(LD) -melf_i386 -Tlinker.ld -o kernel-base.ker $(addprefix obj/, $^) $(LIBGCC) $(LIBSTD)
|
2016-04-30 13:10:28 +00:00
|
|
|
|
2016-05-01 18:22:12 +00:00
|
|
|
%.o: %.cpp
|
|
|
|
$(CXX) $(CXXFLAGS) -c -o obj/$@ $<
|
|
|
|
|
2016-04-30 13:10:28 +00:00
|
|
|
%.o: %.c
|
|
|
|
$(CC) $(ASFLAGS) -c -o obj/$@ $<
|
|
|
|
|
|
|
|
%.o: %.S
|
|
|
|
$(AS) $(CFLAGS) -c -o obj/$@ $<
|
2016-05-01 18:22:12 +00:00
|
|
|
|
|
|
|
%.o: src/%.cpp
|
|
|
|
$(CXX) $(CXXFLAGS) -c -o obj/$@ $<
|
2016-04-30 13:10:28 +00:00
|
|
|
|
2016-05-01 18:22:12 +00:00
|
|
|
%.o: src/%.c
|
|
|
|
$(CC) $(ASFLAGS) -c -o obj/$@ $<
|
|
|
|
|
|
|
|
%.o: src/%.S
|
|
|
|
$(AS) $(CFLAGS) -c -o obj/$@ $<
|
|
|
|
|
2016-05-04 08:40:11 +00:00
|
|
|
# Linux/Multiboot boot specific:
|
|
|
|
# -kernel bzImage use 'bzImage' as kernel image
|
|
|
|
# -append cmdline use 'cmdline' as kernel command line
|
|
|
|
# -initrd file use 'file' as initial ram disk
|
|
|
|
# -dtb file use 'file' as device tree image
|
|
|
|
|
|
|
|
|
2016-05-01 18:22:12 +00:00
|
|
|
run:
|
2016-05-07 12:10:37 +00:00
|
|
|
qemu-system-i386 \
|
|
|
|
-kernel kernel-base.ker \
|
|
|
|
-m 64 \
|
|
|
|
-d cpu_reset,int \
|
|
|
|
-no-reboot \
|
|
|
|
-no-shutdown \
|
2016-05-07 15:00:08 +00:00
|
|
|
-serial stdio \
|
2016-05-07 17:55:59 +00:00
|
|
|
-initrd ../program0/program
|
2016-05-07 15:00:08 +00:00
|
|
|
|
|
|
|
insight:
|
|
|
|
objdump -d kernel-base.ker | c++filt | less
|
2016-05-01 18:22:12 +00:00
|
|
|
|
2016-05-02 22:43:14 +00:00
|
|
|
bnr: kernel-base.ker run
|
|
|
|
|
|
|
|
deploy: kernel-base.ker
|
|
|
|
cp kernel-base.ker /srv/tftp/kernel-base.ker
|