42 lines
918 B
Makefile
42 lines
918 B
Makefile
|
|
MAKEFLAGS += -j16
|
|
|
|
CXXFLAGS := -std=c++23 -Wall -Wextra -pedantic-errors -fsanitize=address -g -ggdb
|
|
LDFLAGS :=
|
|
|
|
CXXFLAGS += $(shell pkgconf sdl2 --cflags)
|
|
CXXFLAGS += $(shell pkgconf sdl2 --libs)
|
|
|
|
build_dir = build
|
|
obj_dir = $(build_dir)/obj
|
|
|
|
sources := $(shell find src/ -name *.cpp -and -not -name *main.cpp)
|
|
|
|
vm_bin = $(build_dir)/vm
|
|
vm_sources := $(sources) src/vm_main.cpp
|
|
|
|
asm_bin = $(build_dir)/asm
|
|
asm_sources := $(sources) src/asm_main.cpp
|
|
|
|
all: $(vm_bin) $(asm_bin) $(build_dir)/boot.bin
|
|
|
|
$(vm_bin): $(vm_sources:%.cpp=$(obj_dir)/%.o)
|
|
g++ $^ -o $@ $(CXXFLAGS) $(LDFLAGS)
|
|
|
|
$(asm_bin): $(asm_sources:%.cpp=$(obj_dir)/%.o)
|
|
g++ $^ -o $@ $(CXXFLAGS) $(LDFLAGS)
|
|
|
|
$(obj_dir)/%.o: %.cpp
|
|
@mkdir -p $(dir $@)
|
|
g++ $< -c -o $@ -MMD -MP $(CXXFLAGS)
|
|
|
|
$(build_dir)/boot.bin: programs/boot.vc5asm $(asm_bin)
|
|
./$(asm_bin) $< -o $@
|
|
|
|
.PHONY: clean
|
|
clean:
|
|
rm -rf $(build_dir)
|
|
|
|
-include $(sources:%.cpp=$(obj_dir)/%.d)
|
|
|