-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMakefile
More file actions
60 lines (51 loc) · 1.3 KB
/
Copy pathMakefile
File metadata and controls
60 lines (51 loc) · 1.3 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
GO_VERSION ?= 1.24.1
APPNAME ?= nvcat
BUILD_DIR := ./build
OS := $(shell uname -s | tr '[:upper:]' '[:lower:]')
ARCH := $(shell uname -m)
ifeq ($(ARCH),x86_64)
ARCH = amd64
endif
ifeq ($(OS),windows)
EXT = zip
else
EXT = tar.gz
endif
GO_ARCHIVE = go$(GO_VERSION).$(OS)-$(ARCH).$(EXT)
URL = https://go.dev/dl/$(GO_ARCHIVE)
ifeq ($(OS),windows)
INSTALL_DIR = $(shell echo $$WINDIR)\System32
APP_EXE = $(APPNAME).exe
CP = copy
GO_BIN = go/bin/go.exe # relative to BUILD_DIR
else
CP = install -m 0755
INSTALL_DIR = /usr/local/bin
APP_EXE = $(APPNAME)
GO_BIN = go/bin/go # relative to BUILD_DIR
endif
.PHONY: install clean
install:
@echo "Creating build directory..."
@mkdir -p $(BUILD_DIR)
@echo "Downloading Go..."
@curl -L $(URL) -o $(BUILD_DIR)/$(GO_ARCHIVE)
@echo "Extracting..."
ifeq ($(OS),windows)
@cd $(BUILD_DIR) && unzip -q $(GO_ARCHIVE)
else
@cd $(BUILD_DIR) && tar -xzf $(GO_ARCHIVE)
endif
@echo "Building $(APP_EXE)..."
@$(BUILD_DIR)/go/bin/go build -o $(BUILD_DIR)/$(APP_EXE)
@echo "Installing to $(INSTALL_DIR)..."
ifeq ($(OS),windows)
@$(CP) $(BUILD_DIR)/$(APP_EXE) "$(INSTALL_DIR)\$(APP_EXE)"
else
@$(CP) $(BUILD_DIR)/$(APP_EXE) $(INSTALL_DIR)/$(APP_EXE)
endif
@echo "Cleaning up..."
@rm -rf $(BUILD_DIR)
@echo "$(APP_EXE) installed successfully."
clean:
@rm -rf $(BUILD_DIR)