From 380405edfe5e9fc55875322e071fa429dfba4b56 Mon Sep 17 00:00:00 2001 From: Robert Jacob Date: Sun, 21 Jun 2020 15:09:49 +0200 Subject: [PATCH] Extend Makefile for selecting architecture --- Makefile | 4 +++- README.md | 15 +++++++++++---- build-arm.sh | 9 --------- 3 files changed, 14 insertions(+), 14 deletions(-) delete mode 100755 build-arm.sh diff --git a/Makefile b/Makefile index ed6a0e5..e93cf56 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,8 @@ .PHONY: all test build-binary install clean GO ?= go +GO_OS ?= linux +GO_ARCH ?= amd64 GO_CMD := CGO_ENABLED=0 $(GO) GIT_VERSION := $(shell git describe --tags --dirty) VERSION := $(GIT_VERSION:v%=%) @@ -12,7 +14,7 @@ test: $(GO_CMD) test -cover ./... build-binary: - $(GO_CMD) build -tags netgo -ldflags "-w -X main.Version=$(VERSION) -X main.GitCommit=$(GIT_COMMIT)" -o netatmo-exporter . + GOOS=$(GO_OS) GOARCH=$(GO_ARCH) $(GO_CMD) build -tags netgo -ldflags "-w -X main.Version=$(VERSION) -X main.GitCommit=$(GIT_COMMIT)" -o netatmo-exporter . clean: rm -f netatmo-exporter diff --git a/README.md b/README.md index 7b90a0f..5cc2192 100644 --- a/README.md +++ b/README.md @@ -19,14 +19,21 @@ If you have a working Go installation, getting the binary should be as simple as ```bash git clone https://github.com/xperimental/netatmo-exporter cd netatmo-exporter -go build . +make ``` -There is also a `build-arm.sh` script if you want to run the exporter on an ARMv7 device. +If you want to build the exporter for a different OS or architecture, you can specify arguments to the Makefile: + +```bash +# For 32-bit ARM on Linux +make GO_ARCH=arm +# For 64-bit ARM on Linux +make GO_ARCH=arm64 +``` ## NetAtmo client credentials -This application tries to get data from the NetAtmo API. For that to work you will need to create an application in the [NetAtmo developer console](https://dev.netatmo.com/dev/myaccount), so that you can get a Client ID and secret. +This application tries to get data from the NetAtmo API. For that to work you will need to create an application in the [NetAtmo developer console](https://dev.netatmo.com/apps/), so that you can get a Client ID and secret. ## Usage @@ -62,4 +69,4 @@ scrape_configs: scrape_interval: 90s static_configs: - targets: ['localhost:9210'] -``` \ No newline at end of file +``` diff --git a/build-arm.sh b/build-arm.sh deleted file mode 100755 index 3e51ed1..0000000 --- a/build-arm.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash -e - -echo "Build binary..." -GOOS=linux GOARCH=arm go build -v -ldflags="-s -w" . - -type upx && { - echo "Packing using upx..." - upx -9 netatmo-exporter -} || echo "upx not available"