aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2024-05-08 01:50:14 +0530
committerAryadev Chavali <aryadev@aryadevchavali.com>2024-05-08 01:50:14 +0530
commitea046912c778dc64ac1dcc25bbc7a1e58f89b196 (patch)
tree186a0a5e1663ef8949d72917183d7b9e6685f0c7 /Makefile
downloadsnek-ea046912c778dc64ac1dcc25bbc7a1e58f89b196.tar.gz
snek-ea046912c778dc64ac1dcc25bbc7a1e58f89b196.tar.bz2
snek-ea046912c778dc64ac1dcc25bbc7a1e58f89b196.zip
First commit!
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile41
1 files changed, 41 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..13ab15e
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,41 @@
+CC=g++
+CFLAGS=-Wall -Wextra -Werror -Wswitch-enum -ggdb -fsanitize=address -fsanitize=undefined -std=c++17
+LIBS=
+
+ARGS=
+OUT=main.out
+
+SRC=src
+DIST=build
+CODE=$(addprefix $(SRC)/, ) # add source files here
+OBJECTS=$(CODE:$(SRC)/%.cpp=$(DIST)/%.o)
+DEPDIR:=$(DIST)/dependencies
+DEPFLAGS=-MT $@ -MMD -MP -MF
+DEPS:=$(CODE:$(SRC)/%.cpp=$(DEPDIR):%.d) $(DEPDIR)/main.d
+
+.PHONY: all
+all: $(OUT)
+
+$(OUT): $(DIST)/$(OUT)
+
+$(DIST)/$(OUT): $(OBJECTS) $(DIST)/main.o | $(DIST)
+ $(CC) $(CFLAGS) $^ -o $@ $(LIBS)
+
+$(DIST)/%.o: $(SRC)/%.cpp | $(DIST) $(DEPDIR)
+ $(CC) $(CFLAGS) $(DEPFLAGS) $(DEPDIR)/$*.d -c $< -o $@ $(LIBS)
+
+.PHONY: run
+run: $(DIST)/$(OUT)
+ ./$^ $(ARGS)
+
+.PHONY:
+clean:
+ rm -rfv $(DIST)/*
+
+$(DIST):
+ mkdir -p $(DIST)
+
+$(DEPDIR):
+ mkdir -p $(DEPDIR)
+
+-include $(DEPS)