From b30453cc09a05b37a37b65ba375d8f1839226596 Mon Sep 17 00:00:00 2001 From: Malachi Soord Date: Thu, 11 Feb 2021 21:21:22 +0100 Subject: [PATCH] Add basic Makefile --- .gitignore | 4 ++++ Makefile | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 Makefile diff --git a/.gitignore b/.gitignore index 525ab5b..ba2597d 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,7 @@ main # Dependency directories (remove the comment below to include it) # vendor/ + +# Build + +/bin diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..3c02029 --- /dev/null +++ b/Makefile @@ -0,0 +1,21 @@ +PROJECT?=github.com/edgebox-iot/sysctl + +RELEASE ?= dev +COMMIT := $(shell git rev-parse --short HEAD) +BUILD_DATE := $(shell date -u '+%Y-%m-%d_%H:%M:%S') +BUILD_DIR = bin + +build-all: + GOOS=linux GOARCH=amd64 make build + +build: + @echo "Building ${GOOS}-${GOARCH}" + GOOS=${GOOS} GOARCH=${GOARCH} go build \ + -trimpath -ldflags "-s -w -X ${PROJECT}/internal/diagnostics.Version=${RELEASE} \ + -X ${PROJECT}/internal/diagnostics.Commit=${COMMIT} \ + -X ${PROJECT}/internal/diagnostics.BuildDate=${BUILD_DATE}" \ + -o bin/sysctl-${GOOS}-${GOARCH} ${PROJECT} + +clean: + rm -rf ${BUILD_DIR} ${DIST_DIR} + go clean