From e0f96e02d6277f92b24ea3afaa49d6c0a7a6731c Mon Sep 17 00:00:00 2001 From: Johnny Richard Date: Fri, 14 Apr 2023 20:55:38 +0200 Subject: build: Move *.c to src folder We want to have different folders for src and objs files. Signed-off-by: Johnny Richard --- Makefile | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 280c0e0..9c840cd 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,18 @@ -all: pipac +TARGET := pipac +SRC_DIR := src +BUILD_DIR := build -pipac: pipac.c - $(CC) pipac.c -o pipac +SRCS := $(wildcard $(SRC_DIR)/*.c) +OBJS := $(patsubst $(SRC_DIR)/%.c, $(BUILD_DIR)/%.o, $(SRCS)) + +.PHONY: all +all: $(TARGET) + +$(TARGET): $(BUILD_DIR) $(OBJS) + $(CC) $(OBJS) -o $(TARGET) $(CFLAGS) + +$(BUILD_DIR): + @mkdir -p $@ + +$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c + $(CC) $(CFLAGS) -c $< -o $@ -- cgit v1.2.3