-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
53 lines (47 loc) · 1.64 KB
/
Makefile
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
APP=casdoor
VERSION=1.0.0
GOARCH=amd64
GOPATH=$(shell go env GOPATH)
GOSRC=$(GOPATH)/src
GOFLAGS=-mod=vendor
PREFIX=/usr/local
ifeq ($(TARGET_OS),linux)
GOOS=linux
OUTPUT_FOLDER=bin/linux
else ifeq ($(TARGET_OS),darwin)
GOOS=darwin
OUTPUT_FOLDER=bin/macos
endif
.PHONY: build clean install uninstall
build:
ifndef TARGET_OS
$(error TARGET_OS is not set, please specify TARGET_OS=(linux|darwin))
endif
@mkdir -p $(OUTPUT_FOLDER)
GOOS=$(GOOS) GOARCH=$(GOARCH) go build $(GOFLAGS) -o $(OUTPUT_FOLDER)/$(APP) -ldflags "-X main.version=$(VERSION)" .
clean:
@rm -rf bin
install: build
@cp $(OUTPUT_FOLDER)/$(APP) $(PREFIX)/bin/$(APP)
@echo "Export the binary path by adding the following line to your .bashrc, .bash_profile, or .zshrc:"
@echo "export PATH=\"$(PREFIX)/bin:\$$PATH\""
@echo ""
@echo "For zsh users:"
@echo "echo 'export PATH=\"$(PREFIX)/bin:\$$PATH\"' >> ~/.zshrc"
@echo "source ~/.zshrc"
@echo ""
@echo "For bash users:"
@echo "echo 'export PATH=\"$(PREFIX)/bin:\$$PATH\"' >> ~/.bashrc"
@echo "source ~/.bashrc"
uninstall:
@rm -f $(PREFIX)/bin/$(APP)
@echo "To remove the PATH entry, manually delete the following line in your .bashrc, .bash_profile, or .zshrc:"
@echo "export PATH=\"$(PREFIX)/bin:\$$PATH\""
@echo ""
@echo "For zsh users:"
@echo "Open ~/.zshrc with a text editor, like 'nano ~/.zshrc', and remove the PATH line."
@echo "After editing, reload the configuration with 'source ~/.zshrc'."
@echo ""
@echo "For bash users:"
@echo "Open ~/.bashrc (or ~/.bash_profile) with a text editor, like 'nano ~/.bashrc', and remove the PATH line."
@echo "After editing, reload the configuration with 'source ~/.bashrc'."