DIR_SRC := src DIR_BLD := build DIR_BIN := $(DIR_BLD)/bin OBJS := $(DIR_BLD)/tests.o \ $(DIR_BLD)/_initializor.o \ $(DIR_BLD)/constants.o \ $(DIR_BLD)/core.o \ $(DIR_BLD)/console.o \ $(DIR_BLD)/string.o \ $(DIR_BLD)/convert.o \ $(DIR_BLD)/perror.o \ $(DIR_BLD)/file.o OBJS_LST := false SRCS := $(patsubst $(DIR_BLD)/%.o,$(SRC_DIR)/%.asm,$(OBJS)) ASSEMBLER := nasm ASSEMBLER_FLAGS := -f elf64 ASSEMBLER_FLAGS_D := -f elf64 -g -F dwarf LINKER := ld LINKER_FLAGS := -no-pie -z noexecstack -Ox STRIP := strip -s .PHONY: all clean debug all: $(DIR_BIN)/tests $(DIR_BIN)/tests: $(OBJS) @mkdir -p $(DIR_BIN) $(LINKER) $^ -o $@ $(LINKER_FLAGS) $(STRIP) $@ ln -sf $@ tests $(DIR_BLD)/%.o: $(DIR_SRC)/%.asm @mkdir -p $(DIR_BLD) @LST=$(basename $@).lst; \ if [ "$(OBJS_LST)" = "true" ]; then \ $(ASSEMBLER) $< $(ASSEMBLER_FLAGS) -l $$LST -o $@; \ echo $(ASSEMBLER) $< $(ASSEMBLER_FLAGS) -l $$LST -o $@; \ else \ $(ASSEMBLER) $< $(ASSEMBLER_FLAGS) -o $@; \ echo $(ASSEMBLER) $< $(ASSEMBLER_FLAGS) -o $@; \ fi clean: rm -rf $(DIR_BLD) tests *.txt debug: ASSEMBLER_FLAGS = $(ASSEMBLER_FLAGS_D) debug: OBJS_LST := true debug: clean $(OBJS) @mkdir -p $(DIR_BIN) $(LINKER) $(OBJS) -o $(DIR_BIN)/tests $(LINKER_FLAGS) ln -sf $(DIR_BIN)/tests tests