blob: e65ead282f90a763a8e9c4bdf7ecc2ed4e5bb979 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
BINARY_NAME=shrine
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
@go mod tidy
# Later when we have .env.example
# @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:
|