summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorBobby <[email protected]>2025-03-27 10:53:55 +0530
committerBobby <[email protected]>2025-03-27 10:53:55 +0530
commitc9067d21d4fd93f7469b92e198b6a2fffe57f699 (patch)
treef603a218c36bb74431bf11360487971747d877aa /Makefile
downloadai-c9067d21d4fd93f7469b92e198b6a2fffe57f699.tar.xz
ai-c9067d21d4fd93f7469b92e198b6a2fffe57f699.zip
Initialised Bare Bones
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile45
1 files changed, 45 insertions, 0 deletions
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