webhookd/Makefile

70 lines
1.4 KiB
Makefile
Raw Normal View History

2014-09-19 18:46:04 +00:00
.SILENT :
# Author
AUTHOR=github.com/ncarlier
2014-09-19 18:46:04 +00:00
# App name
APPNAME=webhookd
# Go configuration
GOOS?=linux
GOARCH?=amd64
# Add exe extension if windows target
is_windows:=$(filter windows,$(GOOS))
EXT:=$(if $(is_windows),".exe","")
2014-09-19 18:46:04 +00:00
# Go app path
APPBASE=${GOPATH}/src/$(AUTHOR)
# Artefact name
ARTEFACT=release/$(APPNAME)-$(GOOS)-$(GOARCH)$(EXT)
# Extract version infos
VERSION:=`git describe --tags`
LDFLAGS=-ldflags "-X $(AUTHOR)/$(APPNAME)/version.App=${VERSION}"
2014-10-31 23:18:38 +00:00
all: build
2014-09-19 18:46:04 +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
$(APPBASE)/$(APPNAME):
echo "Creating GO src link: $(APPBASE)/$(APPNAME) ..."
mkdir -p $(APPBASE)
ln -s $(root_dir) $(APPBASE)/$(APPNAME)
## Clean built files
clean:
-rm -rf release
.PHONY: clean
2014-11-10 16:37:54 +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
$(ARTEFACT): build
## Run tests
test:
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