From c6359302b2efae2d0d45c8fbd2e56cceb3b9e85d Mon Sep 17 00:00:00 2001 From: mithe24 Date: Wed, 8 Oct 2025 13:36:18 +0200 Subject: chore(Makrfile): Generalized maekfile --- Makefile | 42 +++++++++++++++++++----------------------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/Makefile b/Makefile index c22f059..4a8d66f 100644 --- a/Makefile +++ b/Makefile @@ -1,29 +1,25 @@ -# SRCDIR = "src/" -# SRCFILES = coordinateManager.s insertion_sort.s sorter.s main.s file_parser.s -# SRC = $(foreach program, $(SRCFILES), $(SRCDIR)$(program)) -# -# SNIPDIR = "snippets/" -# SNIPFILES = allocate.s fileHandling.s parsing.s utils.s -# SNIP = $(foreach program, $(SNIPFILES), $(SNIPDIR)$(program)) +TARGET := sorter +SRC_DIR := ./src +BUILD_DIR := ./build -OBJS = coordinateManager.o insertion_sort.o sorter.o main.o file_parser.o allocate.o fileHandling.o parsing.o utils.o +AS := as +LD := ld +ASFLAGS := -g +LDFLAGS := -g -ASFLAGS = -g +SRCS := $(shell find $(SRC_DIR) -name '*.s') +OBJS := $(patsubst %.s,%.o,$(SRCS:$(SRC_DIR)/%=$(BUILD_DIR)/%)) -main: $(OBJS) - ld -o main $^ +all: $(TARGET) + +$(TARGET): $(OBJS) + $(LD) $(LDFLAGS) $(OBJS) -o $@ + +$(BUILD_DIR)/%.o: $(SRC_DIR)/%.s + @mkdir -p $(dir $@) + $(AS) $(ASFLAGS) $< -o $@ -.PHONY: clean clean: - rm *.o main + rm -r $(BUILD_DIR) $(TARGET) -# as src/coordinateManager.s -o obj/coordinateManager.o -g -# as src/insertion_sort.s -o obj/insertion_sort.o -g -# as src/sorter.s -o obj/sorter.o -g -# as src/main.s -o obj/main.o -g -# as src/file_parser.s -o obj/file_parser.o -g -# as snippets/allocate.s -o obj/allocate.o -g -# as snippets/fileHandling.s -o obj/fileHandling.o -g -# as snippets/parsing.s -o obj/parsing.o -g -# as snippets/utils.s -o obj/utils.o -g -# ld obj/coordinateManager.o obj/insertion_sort.o obj/sorter.o obj/main.o obj/allocate.o obj/fileHandling.o obj/parsing.o obj/utils.o obj/file_parser.o -o main -g +.PHONY: all clean -- cgit v1.2.3-70-g09d2