aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorCharles <sircharlesaze@gmail.com>2020-06-27 13:14:43 +0200
committerCharles <sircharlesaze@gmail.com>2020-06-27 13:14:43 +0200
commite2c1a8b40787516b9f8f3697a73ac406eae05e6f (patch)
tree6eca534ada1e5bbf0c5401d1d7f6bfa8bd914dbd /Makefile
downloadhanoi-e2c1a8b40787516b9f8f3697a73ac406eae05e6f.tar.gz
hanoi-e2c1a8b40787516b9f8f3697a73ac406eae05e6f.tar.bz2
hanoi-e2c1a8b40787516b9f8f3697a73ac406eae05e6f.zip
Initial commit
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile55
1 files changed, 55 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..ba4a74b
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,55 @@
+# ############################################################################ #
+# #
+# . #
+# Makefile / \ #
+# / \ #
+# By: charles <charles.cabergs@gmail.com> /o o \ #
+# / v \ #
+# Created: 2020/06/27 13:12:43 by charles / _ \ #
+# Updated: 2020/06/27 13:12:48 by charles '-----------' #
+# #
+# ############################################################################ #
+
+RM = rm -f
+
+INCDIR = inc
+SRCDIR = src
+OBJDIR = obj
+OBJDIRS = $(shell find $(SRCDIR) -type d | sed 's/src/$(OBJDIR)/')
+
+INC = $(shell find $(INCDIR) -name "*.h")
+SRC = $(shell find $(SRCDIR) -name "*.c")
+OBJ = $(SRC:$(SRCDIR)/%.c=$(OBJDIR)/%.o)
+
+CC = gcc
+CCFLAGS = -I$(INCDIR) -Wall -Wextra #-Werror
+LDFLAGS = -lncurses
+
+NAME = hanoi
+
+all: prebuild $(NAME)
+
+prebuild:
+ @for subdir in $(OBJDIRS); do mkdir -vp $$subdir; done
+
+$(NAME): $(OBJ)
+ @echo "Linking: $@"
+ $(CC) -o $@ $(OBJ) $(LDFLAGS)
+
+$(OBJDIR)/%.o: $(SRCDIR)/%.c $(INC)
+ @echo "Compiling: $@"
+ @$(CC) $(CCFLAGS) -c -o $@ $<
+
+clean:
+ @echo "Removing objects"
+ @$(RM) -r $(OBJDIR)
+
+fclean:
+ @echo "Removing objects"
+ @$(RM) -r $(OBJDIR)
+ @echo "Removing exectable"
+ @$(RM) $(NAME)
+
+re: fclean all
+
+.PHONY: all prebuild clean fclean re