From 2969a7479ea81eb93fc716e9481c29ebd42cc8ac Mon Sep 17 00:00:00 2001 From: Hadeed Ahmad Date: Thu, 31 Aug 2023 07:33:55 +0500 Subject: [PATCH] Update Makefile --- .gitignore | 5 +++-- Makefile | 20 +++++++++++++++++--- kilo.c => src/kilo.c | 0 3 files changed, 20 insertions(+), 5 deletions(-) rename kilo.c => src/kilo.c (100%) diff --git a/.gitignore b/.gitignore index 50006c7..6d9567d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ -.nvim.lua +build/ kilo -compile_commands.json .ccls-cache +.nvim.lua +compile_commands.json diff --git a/Makefile b/Makefile index a40688c..1127dab 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,21 @@ -CFLAGS := -ggdb -Wall -Wextra -Wstrict-prototypes -std=c99 +SRCS := $(wildcard src/*.c) +OBJS := $(SRCS:src/%.c=build/%.o) +DEPS := $(OBJS:%.o=%.d) -kilo: kilo.c - $(CC) $(CFLAGS) kilo.c -o kilo +WARNING_FLAGS := -Wall -Wextra +INCLUDE_FLAGS := -I headers + +CFLAGS := $(WARNING_FLAGS) $(INCLUDE_FLAGS) -MMD -MP -std=c99 + +kilo: $(OBJS) + $(CC) $(CFLAGS) $^ -o $@ + +$(OBJS): build/%.o: src/%.c + @mkdir -p build + $(CC) $(CFLAGS) -c $< -o $@ clean: + rm -rf build rm -f ./kilo + +-include $(DEPS) diff --git a/kilo.c b/src/kilo.c similarity index 100% rename from kilo.c rename to src/kilo.c