1
0
mirror of https://github.com/pcvolkmer/docker-pps.git synced 2025-04-19 09:46:50 +00:00

Add makefile and build script

Binary will be build in corresponding GOOS-GOARCH folder.

Install command will build and install binary for current platform until
GOOS and/or GOARCH env var is set.
This commit is contained in:
Paul-Christian Volkmer 2022-03-04 11:08:48 +01:00
parent 71af908d16
commit e4850f270d
2 changed files with 53 additions and 0 deletions

21
Makefile Normal file
View File

@ -0,0 +1,21 @@
ifndef VERBOSE
.SILENT:
endif
all: binary
.PHONY: fmt
fmt:
sh ./scripts/build.sh fmt
.PHONY: clean
clean:
sh ./scripts/build.sh clean
.PHONY: binary
binary:
sh ./scripts/build.sh build
.PHONY: install
install:
sh ./scripts/build.sh install

32
scripts/build.sh Normal file
View File

@ -0,0 +1,32 @@
#!/bin/sh
set -eu
TARGET=${TARGET:-"target"}
GOOS="$(go env GOOS)"
GOARCH="$(go env GOARCH)"
TARGET="$TARGET/${GOOS}-${GOARCH}/docker-pps"
if [ "${GOOS}" = "windows" ]; then
TARGET="${TARGET}.exe"
fi
case "$1" in
fmt)
go fmt $(go list)
;;
clean)
rm -rf ./target
;;
build)
go build -o "${TARGET}"
;;
install)
go install
;;
*)
echo "Usage: $0 {fmt|clean|build|install}"
exit 1
esac