# Makefile: Compile and link main.asm using nasm and mold, intermediate files in target/ TARGET_DIR := target SRC := src/main.asm src/lib.asm src/int_to_str.asm OBJ := $(addprefix $(TARGET_DIR)/, $(notdir $(SRC:.asm=.o))) BIN := $(TARGET_DIR)/main .PHONY: all clean all: $(BIN) $(TARGET_DIR): mkdir -p $(TARGET_DIR) $(TARGET_DIR)/%.o: src/%.asm | $(TARGET_DIR) nasm -f elf64 -g $< -o $@ $(BIN): $(OBJ) mold -run ld -o $(BIN) $(OBJ) run: $(BIN) $(BIN) clean: rm -rf $(TARGET_DIR)