boucane/src/Makefile

32 lines
968 B
Makefile
Raw Normal View History

2021-04-19 19:06:28 +02:00
EXEC := boucane
2021-04-21 12:23:54 +02:00
CC := g++ -nostdlib -nostdinc -no-pie -fno-builtin -fno-stack-protector -I ./ -I include
2021-04-19 19:06:28 +02:00
LD_SCRIPT := linker.ld
# Note that BOOT_OBJ do not match boot.S
# Indeed boot.o generated by boot.S should appear
# first in the kernel binary (thus it must be linked first, cf the $(EXEC) rule)
BOOT_OBJ := $(addsuffix .o,$(basename $(shell find ./boot -name '*.cc' -o -name '*.S' ! -name "boot.S")))
2021-04-21 12:23:54 +02:00
DRIVERS_OBJ := $(addsuffix .o,$(basename $(shell find ./drivers -name '*.cc' -o -name '*.S')))
LIBS_OBJ := $(addsuffix .o,$(basename $(shell find ./libs -name '*.cc' -o -name '*.S')))
2021-04-21 18:54:50 +02:00
CORE_OBJ := $(addsuffix .o,$(basename $(shell find ./core -name '*.cc' -o -name '*.S')))
2021-04-19 19:06:28 +02:00
all: $(EXEC)
2021-04-21 18:54:50 +02:00
$(EXEC): boot/boot.o $(BOOT_OBJ) $(DRIVERS_OBJ) $(LIBS_OBJ) $(CORE_OBJ) boucane.o
echo $(BOOT_OBJ)
2021-04-21 12:23:54 +02:00
$(CC) -n -T $(LD_SCRIPT) -nostdlib -o $@ $^
2021-04-19 19:06:28 +02:00
%.o: %.S
as -o $@ $^
2021-04-21 12:23:54 +02:00
%.o: %.cc
$(CC) -c -o $@ $^
2021-04-19 19:06:28 +02:00
clean:
rm -f $(EXEC)
find ./ -name "*.o" -delete
.PHONY: clean cdrom