prefix = /usr/local bindir = $(prefix)/bin libdir = $(prefix)/lib systemddir = $(libdir)/systemd GOPATH := $(realpath $(dir $(lastword $(MAKEFILE_LIST)))) deps = gopkg.in/yaml.v2 subdirs = src/nslcd_proto all: build include $(addsuffix /Makefile,$(subdirs)) secondary += download += $(addprefix src/,$(deps)) generate += build += bin/nshd install += $(addprefix $(DESTDIR),$(bindir)/nshd $(systemddir)/system/nshd.socket $(systemddir)/system/nshd.service) download: $(download) generate: $(generate) build: $(build) install: $(install) .PHONY: download generate build install clean: rm -rf -- pkg bin src/*.*/ rm -f -- $(generate) $(build) $(secondary) .PHONY: clean uninstall: rm -f -- $(install) rmdir -p -- $(sort $(dir $(install))) 2>/dev/null || true .PHONY: uninstall $(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) GOPATH='$(GOPATH)' go install nshd $(DESTDIR)$(bindir)/%: bin/% install -Dm755 $< $@ $(DESTDIR)$(systemddir)/system/%.socket: %.socket install -Dm644 $< $@ $(DESTDIR)$(systemddir)/system/%.service: %.service install -Dm644 $< $@ .SECONDARY: .DELETE_ON_ERROR: