File tree Expand file tree Collapse file tree 1 file changed +26
-8
lines changed
Expand file tree Collapse file tree 1 file changed +26
-8
lines changed Original file line number Diff line number Diff line change 11# Variables
2- BIN_DIR = $(HOME ) /.local/bin
3- TARGET = bluecpprint
4- SRC = cmd/main.go
2+ BIN_DIR := $(HOME ) /.local/bin
3+ TARGET := bluecpprint
4+ SRC := cmd/main.go
5+
6+ # Check for Go at the start
7+ ifndef GO
8+ GO := $(shell command -v go 2>/dev/null)
9+ endif
10+
11+ ifeq ($(GO ) ,)
12+ $(error "Go is not installed or not in PATH. Please install Go to proceed.")
13+ endif
14+
15+ .PHONY : all build run install uninstall clean check
516
617all : build
718
8- build :
19+ check :
20+ @command -v go > /dev/null 2>&1 || { echo >&2 " Go is not installed. Aborting." ; exit 1; }
21+
22+ build : check
923 @echo " Building..."
1024 @go build -o $(TARGET ) $(SRC ) 2>&1
1125
12- run :
26+ run : check
1327 @go run $(SRC )
1428
1529install : build
1630 @echo " Installing..."
1731 @mkdir -p $(BIN_DIR )
1832 @if [ -f $( BIN_DIR) /$( TARGET) ]; then \
19- echo " File $( BIN_DIR) /$( TARGET) already exists. Replacing..." ; \
33+ echo " File $( BIN_DIR) /$( TARGET) already exists." ; \
34+ read -p " Do you want to replace it? [y/N] " ans; \
35+ if [ " $$ ans" != " y" ] && [ " $$ ans" != " Y" ]; then \
36+ echo " Installation aborted." ; \
37+ exit 1; \
38+ fi ; \
39+ echo " Replacing existing file..." ; \
2040 rm -f $(BIN_DIR ) /$(TARGET ) ; \
2141 fi
2242 @cp $(TARGET ) $(BIN_DIR ) /
3656 @rm -f $(TARGET )
3757 @rm -rf test
3858 @echo " Clean complete."
39-
40- .PHONY : all build run install uninstall clean watch
You can’t perform that action at this time.
0 commit comments