From dc13d3811ae4db8dacb140ff8c48789f74602a46 Mon Sep 17 00:00:00 2001
From: Wittano Bonarotti <radoslaw.ratyna@gmail.com>
Date: Fri, 12 Apr 2024 16:44:17 +0200
Subject: [PATCH] feat(Makefile): added web build task

---
 Makefile | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/Makefile b/Makefile
index 92dba7d..cea63b1 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,6 @@
 DEST_DIR = /opt/komputer
 ARCH = $(shell uname -m)
+OUTPUT_DIR=./build
 
 ifeq ($(ARCH), x86_64)
 	GOARCH="amd64"
@@ -8,10 +9,13 @@ else
 endif
 
 dev:
-	CGO_ENABLED=1 GOOS=linux GOARCH=$(GOARCH) go build -tags dev -o ./build/komputer ./cmd/komputer/main.go
+	CGO_ENABLED=1 GOOS=linux GOARCH=$(GOARCH) go build -tags dev -o $(OUTPUT_DIR)/komputer ./cmd/komputer/main.go
 
 prod:
-	CGO_ENABLED=1 GOOS=linux GOARCH=$(GOARCH) go build -o ./build/komputer ./cmd/komputer/main.go
+	CGO_ENABLED=1 GOOS=linux GOARCH=$(GOARCH) go build -o $(OUTPUT_DIR)/komputer ./cmd/komputer/main.go
+
+api:
+	GOARCH=$(GOARCH) go build -o $(OUTPUT_DIR)/api ./cmd/web/main.go
 
 test-bot:
 	go test ./bot/...
@@ -31,10 +35,14 @@ endif
 install: prod
 	mkdir -p $(DEST_DIR)
 	cp -r assets $(DEST_DIR)
-	cp build/komputer $(DEST_DIR)
+	cp $(OUTPUT_DIR)/komputer $(DEST_DIR)
 
 uninstall:
+ifneq ("$(wildcard $(DEST_DIR))", "")
 	rm -r $(DEST_DIR)
+endif
 
 clean:
-	rm -r build
\ No newline at end of file
+ifneq ("$(wildcard $(OUTPUT_DIR))", "")
+	rm -r build
+endif
\ No newline at end of file