2022-10-17 16:32:31 +08:00
|
|
|
GOCMD=go
|
|
|
|
GOBUILD=$(GOCMD) build
|
|
|
|
GOCLEAN=$(GOCMD) clean
|
2023-02-28 14:51:42 +08:00
|
|
|
GOARCH=$(shell go env GOARCH)
|
|
|
|
GOOS=$(shell go env GOOS )
|
2022-10-17 16:32:31 +08:00
|
|
|
|
|
|
|
BASE_PAH := $(shell pwd)
|
|
|
|
BUILD_PATH = $(BASE_PAH)/build
|
|
|
|
WEB_PATH=$(BASE_PAH)/frontend
|
|
|
|
SERVER_PATH=$(BASE_PAH)/backend
|
|
|
|
MAIN= $(BASE_PAH)/cmd/server/main.go
|
|
|
|
APP_NAME=1panel
|
|
|
|
|
2023-04-10 10:35:53 +08:00
|
|
|
build_frontend:
|
2022-10-17 16:32:31 +08:00
|
|
|
cd $(WEB_PATH) && npm install && npm run build:dev
|
|
|
|
|
2023-04-10 10:35:53 +08:00
|
|
|
build_backend_on_linux:
|
2022-10-17 16:32:31 +08:00
|
|
|
cd $(SERVER_PATH) \
|
2023-03-30 15:08:13 +08:00
|
|
|
&& CGO_ENABLED=1 GOOS=$(GOOS) GOARCH=$(GOARCH) $(GOBUILD) -trimpath -ldflags '-s -w --extldflags "-static -fpic"' -tags 'osusergo,netgo' -o $(BUILD_PATH)/$(APP_NAME) $(MAIN)
|
2023-02-28 14:51:42 +08:00
|
|
|
|
2023-04-10 10:35:53 +08:00
|
|
|
build_backend_on_darwin:
|
2023-02-28 14:51:42 +08:00
|
|
|
cd $(SERVER_PATH) \
|
2023-03-08 18:30:50 +08:00
|
|
|
&& CGO_ENABLED=1 GOOS=linux GOARCH=amd64 CC=x86_64-linux-musl-gcc CXX=x86_64-linux-musl-g++ $(GOBUILD) -trimpath -ldflags '-s -w --extldflags "-static -fpic"' -o $(BUILD_PATH)/$(APP_NAME) $(MAIN)
|
2022-10-17 16:32:31 +08:00
|
|
|
|
2023-04-10 10:35:53 +08:00
|
|
|
build_backend_on_archlinux:
|
2023-04-02 16:54:00 +08:00
|
|
|
cd $(SERVER_PATH) \
|
|
|
|
&& CGO_ENABLED=1 GOOS=$(GOOS) GOARCH=$(GOARCH) $(GOBUILD) -trimpath -ldflags '-s -w --extldflags "-fpic"' -tags osusergo -o $(BUILD_PATH)/$(APP_NAME) $(MAIN)
|
|
|
|
|
2023-04-10 10:35:53 +08:00
|
|
|
build_all: build_frontend build_backend_on_linux
|