diff --git a/.gitignore b/.gitignore index 6a144ce..71be9d7 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ a.out example *.swp *.o +*.d diff --git a/Makefile b/Makefile index 407baf3..70e2836 100644 --- a/Makefile +++ b/Makefile @@ -1,14 +1,19 @@ +CFLAGS += -Wall -Wextra -pedantic -Werror -std=c23 SOURCES = $(wildcard *.c) OBJECTS = $(SOURCES:.c=.o) +DEPENDS = $(SOURCES:.c=.d) +DEPFLAGS = -MMD -MP example: $(OBJECTS) $(CC) $(OBJECTS) -o $@ %.o: %.c - $(CC) -c $< -o $@ + $(CC) $(CFLAGS) $(DEPFLAGS) -c $< -o $@ + +-include $(DEPENDS) .PHONY: clean clean: - rm -f example $(OBJECTS) + rm -f example $(OBJECTS) $(DEPENDS)