summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile20
1 files changed, 9 insertions, 11 deletions
diff --git a/Makefile b/Makefile
index 873d745..f408ba9 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-# Copyright 2015-2017 Luke Shumaker <lukeshu@sbcglobal.net>.
+# Copyright 2015-2018 Luke Shumaker <lukeshu@sbcglobal.net>.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
@@ -36,13 +36,11 @@ bins = $(bins_c) $(bins_go) $(bins_lib) $(bins_script)
#
# Go language noise
-CGO_CPPFLAGS = $(CPPFLAGS) -U_FORTIFY_SOURCE
-CGO_CFLAGS = $(CFLAGS) -O0 -Wno-unused-parameter
-CGO_ENABLED = 1
+GOPATH = $(abspath $(topoutdir)/go)
-cgo_variables = CGO_ENABLED CGO_CFLAGS CGO_CPPFLAGS CGO_CXXFLAGS CGO_LDFLAGS CC CXX
-$(foreach v,$(cgo_variables),$(eval $v ?=))
-export $(cgo_variables)
+go_variables := $(shell go env|cut -d= -f1)
+$(foreach v,$(go_variables),$(if $(filter GO% CGO%,$v),$(eval $v ?=),$(eval go_$v ?=)))
+go_env = $(foreach v,$(go_variables),$(if $(go_$v),$v='$(go_$v)',$(if $($v),$v='$($v)')))
#
# Generate (pre-tarball)
@@ -64,11 +62,11 @@ nested.subdirs += $(dir $(filter %/Makefile,$(_gitfiles.all)))
# Build (post-tarball)
files.out.all += $(addprefix bin/,$(filter-out $(bins_script),$(bins))) nshd.service nshd.sysusers
-files.out.int += go/pkg/ go/bin/ go/bin/*
+files.out.int += go/pkg/ go/bin/ go/cache/ go/bin/*
# Go
-$(addprefix %/bin/,$(bins_go)): %/src
- GOPATH=$(abspath $*) go install $(bins_go)
+$(addprefix %/bin/,$(bins_go)): %/src FORCE
+ $(go_env) go install $(bins_go)
$(outdir)/bin/%: $(outdir)/go/bin/%
cp -T $< $@
# C
@@ -94,7 +92,7 @@ go_os_arch = $(word 4,$(shell go version))
go_race_os_arch = $(shell go help build | sed -n '/^\s*-race/,/^\s*-/p'| grep -oE '[a-z0-9]+/[a-z0-9]+')
go_test_flags = $(if $(filter $(go_os_arch),$(go_race_os_arch)),-race)
$(outdir)/check:
- GOPATH=$$PWD/go go test $(go_test_flags) $$(GOPATH=$$PWD/go go list -f '{{.ImportPath}}{{"\n"}}{{join .Deps "\n"}}' $(bins_go) | sort -u | grep -e ^nshd -e '\.[^/]*/')
+ $(go_env) go test $(go_test_flags) $$($(go_env) go list -f '{{.ImportPath}}{{"\n"}}{{join .Deps "\n"}}' $(bins_go) | sort -u | grep -e ^nshd -e '\.[^/]*/')
.PHONY: $(outdir)/check
at.targets += $(outdir)/check