From 6f7be667e2658e3413a5c489611d25e7afc64f0d Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Thu, 25 Jul 2024 21:05:54 +0100 Subject: Hello, world! --- Makefile | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 Makefile (limited to 'Makefile') diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..d3bbe54 --- /dev/null +++ b/Makefile @@ -0,0 +1,50 @@ +CC=g++ +OUT=cwtree.out +LIBS= +ARGS= + +RELEASE=0 +GFLAGS=-Wall -Wextra -Wswitch-enum -std=c++17 +DFLAGS=-ggdb -fsanitize=address -fsanitize=undefined +RFLAGS=-O3 +DEPFLAGS=-MT $@ -MMD -MP -MF + +ifeq ($(RELEASE), 1) +CFLAGS=$(GFLAGS) $(RFLAGS) +else +CFLAGS=$(GFLAGS) $(DFLAGS) +endif + +SRC=src +DIST=build +CODE=$(addprefix $(SRC)/, ) # add source files here +OBJECTS=$(CODE:$(SRC)/%.cpp=$(DIST)/%.o) +DEPDIR:=$(DIST)/dependencies +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) -- cgit v1.2.3-13-gbd6f