2
0
mirror of https://github.com/namecoin/ncdns synced 2024-11-16 00:13:01 +00:00
ncdns/Makefile

93 lines
2.8 KiB
Makefile
Raw Normal View History

PROJNAME=github.com/namecoin/ncdns
2015-12-06 05:28:47 +00:00
BINARIES=$(PROJNAME) $(PROJNAME)/ncdt $(PROJNAME)/ncdumpzone
###############################################################################
# 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.
#
# 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
SHELL := $(shell which bash)
2015-12-06 05:59:54 +00:00
2015-12-06 05:28:47 +00:00
-include Makefile.extra
-include Makefile.assets
## Paths
ifeq ($(GOPATH),)
# for some reason export is necessary for FreeBSD's gmake
export GOPATH := $(shell pwd)
endif
ifeq ($(GOBIN),)
export GOBIN := $(GOPATH)/bin
endif
ifeq ($(PREFIX),)
export PREFIX := /usr/local
endif
DIRS=src bin public
## Quieting
Q=@
QI=@echo -e "\t[$(1)]\t $(2)";
ifeq ($(V),1)
Q=
QI=
endif
## Buildinfo
USE_BUILDINFO ?= 1
2015-12-06 05:28:47 +00:00
ifeq ($(USE_BUILDINFO),1)
BUILDINFO_FLAG=-ldflags "$$($$GOPATH/src/github.com/hlandau/buildinfo/gen $(1))"
2015-12-06 05:28:47 +00:00
endif
## 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; \
exit 0
2015-12-06 05:28:47 +00:00
$(DIRS): | .gotten
$(call QI,DIRS)mkdir -p $(GOPATH)/src $(GOBIN); \
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:
$(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
update: | .gotten
$(call QI,GO-GET,$(PROJNAME))go get -u $(PROJNAME)/...