pretty close to first fully working version
This commit is contained in:
77
Makefile
Normal file
77
Makefile
Normal file
@@ -0,0 +1,77 @@
|
||||
## Standard Makefile preamble
|
||||
## according to https://tech.davis-hansson.com/p/make/
|
||||
|
||||
## Specify a shell
|
||||
SHELL := bash
|
||||
|
||||
## set shell options
|
||||
.SHELLFLAGS := -eu -o pipefail -c
|
||||
|
||||
## Makefile defaults
|
||||
.ONESHELL:
|
||||
.DELETE_ON_ERROR:
|
||||
|
||||
MAKEFLAGS += --warn-undefined-variables
|
||||
MAKEFLAGS += --no-builtin-rules
|
||||
|
||||
## Modify Makefile parsing
|
||||
ifeq ($(origin .RECIPEPREFIX), undefined)
|
||||
$(error This Make does not support .RECIPEPREFIX. Please use GNU Make 4.0 or later)
|
||||
endif
|
||||
.RECIPEPREFIX = >
|
||||
|
||||
#----------------------------------------------------------------
|
||||
# Variables
|
||||
#----------------------------------------------------------------
|
||||
progName = scaffold
|
||||
|
||||
#----------------------------------------------------------------
|
||||
# Helpers
|
||||
#----------------------------------------------------------------
|
||||
|
||||
## help: print this help message
|
||||
|
||||
help:
|
||||
> @echo 'Usage:'
|
||||
> @sed -n 's/^##//p' ${MAKEFILE_LIST} | column -t -s ':' | sed -e 's/^/ /'
|
||||
|
||||
## confirm: a helper script to check your intent
|
||||
confirm:
|
||||
> @echo -n 'Are you sure? [y/N] ' && read ans && [ $${ans:-N} = y ]
|
||||
|
||||
## clean: clears temp files
|
||||
clean:
|
||||
> @echo 'Cleaning temp files ...'
|
||||
> @echo '' > buildTime.txt
|
||||
> @echo '' > buildVersion.txt
|
||||
> @echo 'Done cleaning.'
|
||||
|
||||
#----------------------------------------------------------------
|
||||
# Build
|
||||
#----------------------------------------------------------------
|
||||
|
||||
# build strips debugging info from binary
|
||||
linkerflags = '-s'
|
||||
|
||||
prep: clean
|
||||
> date +"%F %a %T %Z" > buildTime.txt
|
||||
> git describe --always --tags --dirty --long > buildVersion.txt
|
||||
|
||||
build: prep
|
||||
> @go build -o build/$(progName) . && echo "Build success" || echo "[FAILED] go build"
|
||||
|
||||
build-production: prep
|
||||
> @go build -ldflags=${linkerflags} -o build/$(progName) . && echo "production build success" || echo "[FAILED] production build"
|
||||
|
||||
#-------------------------------------------------------------
|
||||
# Install - same as build, but places binary on system path
|
||||
#-------------------------------------------------------------
|
||||
|
||||
install: prep
|
||||
> @go install . && echo "Build and Install success" || echo "[FAILED] go install"
|
||||
|
||||
install-production: prep
|
||||
> @go install -ldflags=${linkerflags} . && echo "production build and install success" || echo "[FAILED] production install"
|
||||
|
||||
## Commands that don't relate to a specific file
|
||||
.PHONY: help confirm clean prep build build-production
|
||||
Reference in New Issue
Block a user