summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile39
1 files changed, 22 insertions, 17 deletions
diff --git a/Makefile b/Makefile
index e01cd74..6c561a4 100644
--- a/Makefile
+++ b/Makefile
@@ -1,30 +1,35 @@
-CC ?= gcc
-CFLAGS += -W -Wall -std=c99 -Wextra $(shell sdl-config --cflags)
-LDFLAGS += $(shell sdl-config --libs) -lSDL_image -lSDL_ttf
-NAME = rpg
-SRC = $(wildcard *.c)
+NAME = rpg
+SRC = $(wildcard *.c)
-all: depend $(NAME)
+CPPFLAGS += $(shell sdl-config --cflags)
+LDFLAGS += $(shell sdl-config --libs) -lSDL_image -lSDL_ttf
+CFLAGS += -W -Wall -Wextra -std=gnu99
-depend: .depend
+CC = gcc
-.depend: $(SRC)
- @$(RM) .depend
- @$(CC) $(CFLAGS) -MM $^ > .depend
+OBJ = $(SRC:.c=.o)
+DEP = $(SRC:.c=.d)
-include .depend
-
-OBJ = $(SRC:.c=.o)
+all: $(NAME)
$(NAME): $(OBJ)
$(CC) -o $@ $^ $(LDFLAGS)
+-include $(DEP)
+
+%.d: %.c
+ $(CC) -MM $(CPPFLAGS) $(CFLAGS) $< -MF $@ -MT "$*.o $@"
+
clean:
$(RM) $(OBJ)
-
-fclean: clean
$(RM) $(NAME)
-re: fclean all
+mrproper: clean
+ $(RM) $(DEP)
+
+distclean: mrproper
+ $(RM) $(addsuffix ~,$(SRC))
+ $(RM) $(wildcard $(addsuffix .sw*,$(addprefix .,$(SRC))))
+
+.PHONY: all clean mrproper distclean
-.PHONY: all depend clean fclean all re