summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile22
1 files changed, 15 insertions, 7 deletions
diff --git a/Makefile b/Makefile
index 15c1c43..688a695 100644
--- a/Makefile
+++ b/Makefile
@@ -3,14 +3,20 @@ bindir = $(prefix)/bin
libdir = $(prefix)/lib
systemddir = $(libdir)/systemd
-GOPATH := $(realpath $(dir $(lastword $(MAKEFILE_LIST))))
+user = nshd
+group = nshd
CFLAGS = -std=c99 -Wall -Wextra -Werror -pedantic
CGO_CFLAGS = $(CFLAGS) -Wno-unused-parameter
-export CGO_ENABLED = 1
-
+CGO_ENABLED = 1
+export CGO_ENABLED
+
cgo_variables = CGO_ENABLED CGO_CFLAGS CGO_CPPFLAGS CGO_CXXFLAGS CGO_LDFLAGS CC CXX
+GOPATH := $(realpath $(dir $(lastword $(MAKEFILE_LIST))))
+
+vp = .Makefile.var.%
+
deps = gopkg.in/yaml.v2
subdirs = src/nslcd_proto
@@ -21,7 +27,7 @@ include $(addsuffix /Makefile,$(subdirs))
secondary +=
download += $(addprefix src/,$(deps))
generate +=
-build += bin/nshd nshd.service
+build += bin/nshd nshd.service nshd.socket
install += $(addprefix $(DESTDIR),$(bindir)/nshd $(systemddir)/system/nshd.socket $(systemddir)/system/nshd.service)
download: $(download)
@@ -44,11 +50,13 @@ $(foreach d,$(deps),$(eval src/$d: NET; GOPATH='$(GOPATH)' go get -d -u $d))
.PHONY: NET
bin/nshd: $(download) $(generate) $(shell find src -name .git -prune -o -print) $(addprefix .Makefile.var.,$(cgo_variables))
- @true $(foreach f,$(filter .Makefile.var.%,$^), && test $@ -nt $f ) || rm -rf -- bin pkg
+ @true $(foreach f,$(filter $(vp),$^), && test $@ -nt $f ) || rm -rf -- bin pkg
GOPATH='$(GOPATH)' CGO_CFLAGS='$(CGO_CFLAGS)' go install nshd
-nshd.service: nshd.service.in .Makefile.var.bindir
- < $< sed 's|@bindir@|$(bindir)|g' > $@
+%: %.in
+ < $< sed $(foreach v,$(patsubst $(vp),%,$(filter $(vp),$^)), -e 's|@$v@|$($v)|g' ) > $@
+nshd.service: .Makefile.var.bindir .Makefile.var.user .Makefile.var.group
+nshd.socket: .Makefile.var.user .Makefile.var.group
$(DESTDIR)$(bindir)/%: bin/%
install -Dm755 $< $@