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-04 15:19:40 +00:00
|
|
|
FLAGS = -ffreestanding -m32 -Werror -Wall -iquote include -O3
|
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-04-30 13:10:28 +00:00
|
|
|
all: kernel-base.ker
|
|
|
|
|
|
|
|
kernel-base.ker: $(OBJS)
|
2016-05-04 15:19:40 +00:00
|
|
|
$(LD) -melf_i386 -Tlinker.ld -o kernel-base.ker $(addprefix obj/, $^) $(LIBGCC)
|
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:
|
|
|
|
qemu-system-i386 -kernel kernel-base.ker
|
|
|
|
|
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
|