Newer
Older
SHELL := /usr/bin/env bash -euo pipefail
.DEFAULT_GOAL := default
MKFILE_DIR = $(abspath $(dir $(abspath $(lastword $(MAKEFILE_LIST)))))
LOCAL_DIR := $(abspath $(MKFILE_DIR)/.local)
BIN_DIR := $(LOCAL_DIR)/bin
TMP_DIR := $(LOCAL_DIR)/tmp
SRC_DIR := $(MKFILE_DIR)
export PATH := $(BIN_DIR):$(PATH)
export GOMODCACHE = $(LOCAL_DIR)/cache/go
export GOTMPDIR = $(TMP_DIR)/go
default: clean install build run
.PHONY: install
install:
mkdir -p $(GOTMPDIR)
cd $(SRC_DIR) \
.PHONY: run
run:
cd $(SRC_DIR) \
&& go run .
.PHONY: build $(BIN_DIR)/artifact.bin
build: $(BIN_DIR)/artifact.bin
$(BIN_DIR)/artifact.bin:
cd $(SRC_DIR) \
&& go build \
-o $(@) \
-ldflags "-X webservice/configuration.version=0.0.1" \
.PHONY: build-linux
build-linux: export GOOS := linux
build-linux: export GOARCH := amd64
build-linux: export CGO_ENABLED := 0
build-linux: $(BIN_DIR)/artifact.bin
sha256sum $(BIN_DIR)/artifact.bin