2014-09-19 18:46:04 +00:00
|
|
|
.SILENT :
|
2014-09-25 12:18:20 +00:00
|
|
|
|
2018-01-02 16:11:59 +00:00
|
|
|
# Author
|
|
|
|
AUTHOR=github.com/ncarlier
|
2014-09-19 18:46:04 +00:00
|
|
|
|
2018-01-02 16:11:59 +00:00
|
|
|
# App name
|
|
|
|
APPNAME=webhookd
|
2014-09-23 18:16:50 +00:00
|
|
|
|
2018-01-02 16:11:59 +00:00
|
|
|
# Go configuration
|
|
|
|
GOOS?=linux
|
|
|
|
GOARCH?=amd64
|
2014-09-25 12:18:20 +00:00
|
|
|
|
2018-01-02 16:11:59 +00:00
|
|
|
# Add exe extension if windows target
|
|
|
|
is_windows:=$(filter windows,$(GOOS))
|
|
|
|
EXT:=$(if $(is_windows),".exe","")
|
2014-09-19 18:46:04 +00:00
|
|
|
|
2018-01-02 16:11:59 +00:00
|
|
|
# Go app path
|
|
|
|
APPBASE=${GOPATH}/src/$(AUTHOR)
|
2015-03-24 19:52:35 +00:00
|
|
|
|
2018-01-02 16:11:59 +00:00
|
|
|
# Artefact name
|
|
|
|
ARTEFACT=release/$(APPNAME)-$(GOOS)-$(GOARCH)$(EXT)
|
2014-09-23 18:16:50 +00:00
|
|
|
|
2018-01-02 16:11:59 +00:00
|
|
|
# Extract version infos
|
|
|
|
VERSION:=`git describe --tags`
|
|
|
|
LDFLAGS=-ldflags "-X $(AUTHOR)/$(APPNAME)/version.App=${VERSION}"
|
2014-10-31 23:18:38 +00:00
|
|
|
|
2018-01-02 16:11:59 +00:00
|
|
|
all: build
|
2014-09-19 18:46:04 +00:00
|
|
|
|
2018-01-02 16:11:59 +00:00
|
|
|
# Include common Make tasks
|
|
|
|
root_dir:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
|
|
|
|
makefiles:=$(root_dir)/makefiles
|
|
|
|
include $(makefiles)/help.Makefile
|
2014-09-19 18:46:04 +00:00
|
|
|
|
2018-01-02 16:11:59 +00:00
|
|
|
$(APPBASE)/$(APPNAME):
|
|
|
|
echo "Creating GO src link: $(APPBASE)/$(APPNAME) ..."
|
|
|
|
mkdir -p $(APPBASE)
|
|
|
|
ln -s $(root_dir) $(APPBASE)/$(APPNAME)
|
2014-09-25 12:18:20 +00:00
|
|
|
|
2018-01-02 16:11:59 +00:00
|
|
|
## Clean built files
|
|
|
|
clean:
|
|
|
|
-rm -rf release
|
|
|
|
.PHONY: clean
|
2014-11-10 16:37:54 +00:00
|
|
|
|
2018-01-02 16:11:59 +00:00
|
|
|
## Build executable
|
|
|
|
build: $(APPBASE)/$(APPNAME)
|
|
|
|
-mkdir -p release
|
|
|
|
echo "Building: $(ARTEFACT) ..."
|
|
|
|
GOOS=$(GOOS) GOARCH=$(GOARCH) go build $(LDFLAGS) -o $(ARTEFACT)
|
|
|
|
.PHONY: build
|
2014-11-10 16:37:54 +00:00
|
|
|
|
2018-01-02 16:11:59 +00:00
|
|
|
$(ARTEFACT): build
|
2014-09-25 12:18:20 +00:00
|
|
|
|
2018-01-02 16:11:59 +00:00
|
|
|
## Run tests
|
2014-09-25 12:18:20 +00:00
|
|
|
test:
|
2018-01-02 16:11:59 +00:00
|
|
|
go test
|
|
|
|
.PHONY: test
|
|
|
|
|
|
|
|
## Install executable
|
|
|
|
install: $(ARTEFACT)
|
|
|
|
echo "Installing $(ARTEFACT) to ${HOME}/.local/bin/$(APPNAME) ..."
|
|
|
|
cp $(ARTEFACT) ${HOME}/.local/bin/$(APPNAME)
|
|
|
|
.PHONY: install
|
|
|
|
|
|
|
|
## Create Docker image
|
|
|
|
image:
|
|
|
|
echo "Building Docker inage ..."
|
|
|
|
docker build --rm -t ncarlier/$(APPNAME) .
|
|
|
|
.PHONY: image
|
2014-09-25 12:18:20 +00:00
|
|
|
|