From 52d3c1ee76061fc6ca767ac7a5521a12f6ec84b1 Mon Sep 17 00:00:00 2001 From: Olivier Gayot Date: Wed, 5 Mar 2014 18:33:58 +0100 Subject: Rewrite the Makefile to make it more reusable --- Makefile | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) (limited to 'Makefile') 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 -- cgit v1.2.3