From c9067d21d4fd93f7469b92e198b6a2fffe57f699 Mon Sep 17 00:00:00 2001 From: Bobby Date: Thu, 27 Mar 2025 10:53:55 +0530 Subject: Initialised Bare Bones --- Makefile | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 Makefile (limited to 'Makefile') diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..8417dbf --- /dev/null +++ b/Makefile @@ -0,0 +1,45 @@ +BINARY_NAME=ai +BUILD_PATH=bin/$(BINARY_NAME) +MAIN_PATH=$(BINARY_NAME)/main.go +ENV_PATH=.env + +.PHONY: setup clean build run dev all + +define ensure_setup + @if [ ! -f $(ENV_PATH) ]; then \ + echo "Running setup first..."; \ + $(MAKE) -s setup; \ + fi +endef + +setup: + @echo "Setting up environment..." + @go mod download + @if [ ! -f $(ENV_PATH) ]; then cp .env.example $(ENV_PATH); fi + @echo "Environment setup complete." + +clean: + @echo "Cleaning up..." + @rm -rf bin + @echo "Cleanup complete." + +build: + $(call ensure_setup) + @echo "Building..." + @go build -o $(BUILD_PATH) $(MAIN_PATH) || true + @echo "Build complete." + +run: + $(call ensure_setup) + @if [ ! -f $(BUILD_PATH) ]; then echo "Binary not found. Building binary..."; $(MAKE) -s build; fi + @echo "Running..." + @$(BUILD_PATH) || true + +dev: + $(call ensure_setup) + @echo "Running in development mode..." + @go run $(MAIN_PATH) || true + +all: setup clean build run + +.SILENT: \ No newline at end of file -- cgit v1.2.3