2017-08-08 05:57:57 +00:00
PROJNAME = github.com/namecoin/ncdns
2015-12-06 05:28:47 +00:00
BINARIES = $( PROJNAME) $( PROJNAME) /ncdt $( PROJNAME) /ncdumpzone
###############################################################################
2016-11-12 12:04:41 +00:00
# v1.14 NNSC:github.com/hlandau/degoutils/_stdenv/Makefile.ref
2015-12-06 05:28:47 +00:00
# This is a standard Makefile for building Go code designed to be copied into
# other projects. Code below this line is not intended to be modified.
2016-11-12 11:44:14 +00:00
#
# NOTE: Use of this Makefile is not mandatory. People familiar with the use
# of the "go" command who have a GOPATH setup can use go get/go install.
2015-12-06 05:28:47 +00:00
2015-12-06 05:59:54 +00:00
# XXX: prebuild-checks needs bash, fix this at some point
2016-11-12 11:44:14 +00:00
SHELL := $( shell which bash)
2015-12-06 05:59:54 +00:00
2015-12-06 05:28:47 +00:00
- i n c l u d e M a k e f i l e . e x t r a
- i n c l u d e M a k e f i l e . a s s e t s
## Paths
i f e q ( $( GOPATH ) , )
# for some reason export is necessary for FreeBSD's gmake
export GOPATH := $( shell pwd )
e n d i f
i f e q ( $( GOBIN ) , )
export GOBIN := $( GOPATH) /bin
e n d i f
i f e q ( $( PREFIX ) , )
export PREFIX := /usr/local
e n d i f
DIRS = src bin public
## Quieting
Q = @
QI = @echo -e " \t[ $( 1) ]\t $( 2) " ;
i f e q ( $( V ) , 1 )
Q =
QI =
e n d i f
## Buildinfo
2016-11-12 12:04:41 +00:00
USE_BUILDINFO ?= 1
2015-12-06 05:28:47 +00:00
i f e q ( $( USE_BUILDINFO ) , 1 )
2016-11-12 11:44:14 +00:00
BUILDINFO_FLAG = -ldflags " $$ ( $$ GOPATH/src/github.com/hlandau/buildinfo/gen $( 1) ) "
2015-12-06 05:28:47 +00:00
e n d i f
## Standard Rules
all : prebuild -checks $( DIRS )
$( call QI,GO-INSTALL,$( BINARIES) ) go install $( BUILDFLAGS) $( call BUILDINFO_FLAG,$( BINARIES) ) $( BINARIES)
prebuild-checks :
$( call QI,RELOCATE) if [ ` find . -iname '*.go' | grep -v ./src/ | wc -l` != 0 ] ; then \
if [ -e " $( GOPATH) /src/ $( PROJNAME) / " ] ; then \
echo " $$ GOPATH/src/ $( PROJNAME) / already exists, can't auto-relocate. Since you appear to have a GOPATH configured, just use go get -u ' $( PROJNAME) /...; go install $( BINARIES) '. Alternatively, move this Makefile to either GOPATH or an empty directory outside GOPATH (preferred) and run it. Or delete ' $$ GOPATH/src/ $( PROJNAME) /'. " ; \
exit 1; \
fi ; \
mkdir -p " $( GOPATH) /src/ $( PROJNAME) / " ; \
for x in ./* ./.*; do \
[ " $$ x " = = "./src" ] && continue ; \
mv -n " $$ x " " $( GOPATH) /src/ $( PROJNAME) / " ; \
done ; \
ln -s " $( GOPATH) /src/ $( PROJNAME) /Makefile " ; \
[ -e " $( GOPATH) /src/ $( PROJNAME) /_doc " ] && ln -s " $( GOPATH) /src/ $( PROJNAME) /_doc " doc; \
2015-12-06 05:42:24 +00:00
[ -e " $( GOPATH) /src/ $( PROJNAME) /_tpl " ] && ln -s " $( GOPATH) /src/ $( PROJNAME) /_tpl " tpl; \
2015-12-06 05:28:47 +00:00
fi ; \
2016-02-11 15:35:30 +00:00
exit 0
2015-12-06 05:28:47 +00:00
$(DIRS) : | .gotten
$( call QI,DIRS) mkdir -p $( GOPATH) /src $( GOBIN) ; \
2016-11-12 11:44:14 +00:00
if [ ! -e "src" ] ; then \
2015-12-06 05:28:47 +00:00
ln -s $( GOPATH) /src src; \
fi ; \
if [ ! -e "bin" ] ; then \
ln -s $( GOBIN) bin; \
fi
.gotten :
2016-11-12 11:44:14 +00:00
$( call QI,GO-GET,$( PROJNAME) ) go get $( PROJNAME) /...
2015-12-06 05:28:47 +00:00
$( Q) touch .gotten
.NOTPARALLEL : prebuild -checks $( DIRS )
.PHONY : all test install prebuild -checks
test :
$( call QI,GO-TEST,$( PROJNAME) ) for x in $( PROJNAME) ; do go test -cover -v $$ x/...; done
install : all
$( call QI,INSTALL,$( BINARIES) ) for x in $( BINARIES) ; do \
install -Dp $( GOBIN) /` basename " $$ x " ` $( DESTDIR) $( PREFIX) /bin; \
done
2016-11-12 11:44:14 +00:00
update : | .gotten
$( call QI,GO-GET,$( PROJNAME) ) go get -u $( PROJNAME) /...