aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorBobby <[email protected]>2024-09-08 02:32:17 -0400
committerBobby <[email protected]>2024-09-08 02:32:17 -0400
commit61bc5b38044bc52442415f83390ba72ed3b27491 (patch)
tree73b727180897573d6a13c0a84ac4e1bb617f33ed /Makefile
downloadyato-61bc5b38044bc52442415f83390ba72ed3b27491.tar.xz
yato-61bc5b38044bc52442415f83390ba72ed3b27491.zip
Initial Commit with MAL Auth
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile40
1 files changed, 40 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..638d13d
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,40 @@
+# Makefile for Yato
+
+# Check for .env file
+ifneq ($(wildcard .env),)
+ include .env
+ export $(shell sed 's/=.*//' .env)
+endif
+
+# Ensure required environment variables are set
+ifndef MAL_CLIENT_ID
+$(error MAL_CLIENT_ID is not set. Please check your .env file)
+endif
+ifndef MAL_CLIENT_SECRET
+$(error MAL_CLIENT_SECRET is not set. Please check your .env file)
+endif
+
+# Variables
+BUILD_DIR=build
+BINARY_NAME=yato
+MAIN_FILE=main.go
+ENCODED_CLIENT_ID=$(shell printf '%s' "$(MAL_CLIENT_ID)" | base64)
+ENCODED_CLIENT_SECRET=$(shell printf '%s' "$(MAL_CLIENT_SECRET)" | base64)
+
+.PHONY: build run clean
+
+build:
+ @echo "Building Yato..."
+ @echo "Encoded Client ID: $(ENCODED_CLIENT_ID)"
+ @echo "Encoded Client Secret: $(ENCODED_CLIENT_SECRET)"
+ @go build -ldflags '-X "yato/config.encodedClientID=$(ENCODED_CLIENT_ID)" -X "yato/config.encodedClientSecret=$(ENCODED_CLIENT_SECRET)"' -o $(BUILD_DIR)/$(BINARY_NAME) $(MAIN_FILE)
+ @echo "Build complete. Binary '$(BINARY_NAME)' created."
+
+run:
+ @echo "Running Yato..."
+ @go run .
+
+clean:
+ @echo "Cleaning up..."
+ @rm -rf $(BUILD_DIR)
+ @echo "Cleanup complete." \ No newline at end of file