summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Gayot <duskcoder@gmail.com>2014-03-05 18:33:58 +0100
committerOlivier Gayot <duskcoder@gmail.com>2014-03-05 18:39:20 +0100
commit52d3c1ee76061fc6ca767ac7a5521a12f6ec84b1 (patch)
treeb317fbb09ae438e474fdb68ca99a86d7d4fcd33c
parentc14c190414c1336643cd7d0c29f0626ccc7dea6d (diff)
Rewrite the Makefile to make it more reusable
-rw-r--r--Makefile32
1 files changed, 27 insertions, 5 deletions
diff --git a/Makefile b/Makefile
index fa5f19a..7c9868b 100644
--- a/Makefile
+++ b/Makefile
@@ -1,9 +1,31 @@
-CC = gcc
-CFLAGS = -Wall -W -std=c99 -g
-god_hands_solver: god_hands.o
+CC ?= gcc
+CFLAGS += -W -Wall -std=gnu99 -Wextra
+LDFLAGS +=
+NAME = god_hands_solver
+SRC = god_hands.c
+
+all: depend $(NAME)
+
+depend: .depend
+
+.depend: $(SRC)
+ @$(RM) .depend
+ @$(CC) $(CFLAGS) -MM $^ > .depend
+
+include .depend
+
+OBJ = $(SRC:.c=.o)
+
+$(NAME): $(OBJ)
$(CC) -o $@ $^ $(LDFLAGS)
-god_hands.o: god_hands.c
- $(CC) -o $@ -c $< $(CFLAGS)
+clean:
+ $(RM) $(OBJ)
+
+fclean: clean
+ $(RM) $(NAME)
+
+re: fclean all
+.PHONY: all depend clean fclean all re