Initial commit
This commit is contained in:
67
Makefile
Normal file
67
Makefile
Normal file
@@ -0,0 +1,67 @@
|
||||
SHELL = /bin/bash
|
||||
VERSION = $(shell cat hestiacp-php-selector.spec | grep Version: | cut -d":" -f2 | xargs)
|
||||
PKG_NAME = $(shell cat hestiacp-php-selector.spec | grep Name: | cut -d":" -f2 | xargs)
|
||||
BIN_INSTALL_DIR = $(DESTDIR)/usr/bin
|
||||
GOLDFLAGS=-ldflags "-X main.LSCTL_VERSION=$(VERSION) -compressdwarf=false"
|
||||
|
||||
help:
|
||||
echo "Commands list:"
|
||||
echo "make build - build project"
|
||||
echo "make targz - prepare tar.gz of project sources"
|
||||
echo "make help | all - help"
|
||||
echo "make clean - clean all"
|
||||
echo "make install - install binaries"
|
||||
|
||||
install:
|
||||
cd _build && \
|
||||
install -d $(BIN_INSTALL_DIR) && \
|
||||
install -m 755 hestiacp-php-selector $(BIN_INSTALL_DIR)
|
||||
|
||||
targz:
|
||||
mkdir $(PKG_NAME)-$(VERSION) && \
|
||||
git rev-parse --abbrev-ref HEAD > $(PKG_NAME)-$(VERSION)/version
|
||||
cp -r LICENSE src Makefile *.spec go.mod.prepare.sh go.* $(PKG_NAME)-$(VERSION)/ && \
|
||||
tar zcvf $(PKG_NAME)-$(VERSION).tar.gz $(PKG_NAME)-$(VERSION) && \
|
||||
rm -rf $(PKG_NAME)-$(VERSION)
|
||||
|
||||
targzvendor:
|
||||
mkdir $(PKG_NAME)-$(VERSION) && \
|
||||
cp -r LICENSE src Makefile *.spec go.mod.prepare.sh go.* $(PKG_NAME)-$(VERSION)/ && \
|
||||
pushd $(PKG_NAME)-$(VERSION) && \
|
||||
$(GOENV) go mod vendor && \
|
||||
popd && \
|
||||
tar zcvf $(PKG_NAME)-$(VERSION).tar.gz $(PKG_NAME)-$(VERSION) && \
|
||||
rm -rf $(PKG_NAME)-$(VERSION)
|
||||
|
||||
|
||||
build:
|
||||
{ [ ! -e _build ] || rm -rf _build; } && \
|
||||
mkdir _build && \
|
||||
{ [ ! -e _src ] || rm -rf _src; } && \
|
||||
mkdir _src && cp -rf src go.* _src && \
|
||||
{ [ ! -e vendor ] || cp -rf vendor _src; } && \
|
||||
bash go.mod.prepare.sh && \
|
||||
cd _src && \
|
||||
{ [ -e vendor ] || $(GOENV) go mod tidy; } && \
|
||||
{ [ -e vendor ] || $(GOENV) go build -buildvcs=false $(GOLDFLAGS) -o ../_build/hestiacp-php-selector src/main/*.go; } && \
|
||||
{ [ ! -e vendor ] || GO111MODULE=on GOPROXY=off go build -mod=vendor -buildvcs=false $(GOLDFLAGS) -o ../_build/hestiacp-php-selector src/main/*.go; }
|
||||
|
||||
check:
|
||||
{ [ ! -e _src ] || rm -rf _src; } && \
|
||||
mkdir _src && cp -rf src go.* _src && \
|
||||
{ [ ! -e vendor ] || cp -rf vendor _src; } && \
|
||||
bash go.mod.prepare.sh && \
|
||||
cd _src && \
|
||||
{ [ -e vendor ] || $(GOENV) go mod tidy; } && \
|
||||
{ [ -e vendor ] || $(GOENV) go test src/main/*.go; } && \
|
||||
{ [ ! -e vendor ] || GO111MODULE=on GOPROXY=off go test -mod=vendor -buildvcs=false src/main/*.go; }
|
||||
|
||||
all: help
|
||||
|
||||
.PHONY: all help clean build targz
|
||||
|
||||
clean:
|
||||
rm -rf _build
|
||||
rm -rf _src
|
||||
rm -rf *.tar.gz
|
||||
rm -rf $(PKG_NAME)-$(VERSION)
|
||||
Reference in New Issue
Block a user