summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile38
1 files changed, 21 insertions, 17 deletions
diff --git a/Makefile b/Makefile
index f96eb32..a571f6c 100644
--- a/Makefile
+++ b/Makefile
@@ -14,33 +14,37 @@
## with this program; if not, write to the Free Software Foundation, Inc.,
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-CC ?= gcc
-CFLAGS += -W -Wall -std=gnu99 -Wextra
-LDFLAGS +=
-NAME = god_hands_solver
-SRC = god_hands.c
+NAME = god_hands_solver
+SRC = $(wildcard *.c)
-all: depend $(NAME)
+CPPFLAGS =
+LDFLAGS =
+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 depend clean fclean all re
+.PHONY: all clean mrproper distclean