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-02 07:25:08 +00:00
|
|
|
FLAGS = -ffreestanding -m32 -Werror -Wall -iquote include
|
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))))
|
|
|
|
|
|
|
|
all: kernel-base.ker
|
|
|
|
|
|
|
|
kernel-base.ker: $(OBJS)
|
2016-05-01 18:22:12 +00:00
|
|
|
$(LD) -melf_i386 -Tlinker.ld -o kernel-base.ker $(addprefix obj/, $^)
|
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/$@ $<
|
|
|
|
|
|
|
|
run:
|
|
|
|
qemu-system-i386 -kernel kernel-base.ker
|
|
|
|
|
|
|
|
bnr: kernel-base.ker run
|