summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2016-01-22 15:28:56 -0500
committerLuke Shumaker <lukeshu@sbcglobal.net>2016-01-22 15:28:56 -0500
commitc80e4036fbac53039b607c4bb8a5489d016a009f (patch)
tree71890b78ecfa239b2f3e272b501f63c87ab3ec32 /Makefile
initial commit
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile43
1 files changed, 43 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..5f50812
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,43 @@
+#!/usr/bin/env bash
+# Copyright 2016 Luke Shumaker
+# License: WTFPLv2
+
+prefix = /usr/local
+bindir = $(prefix)/bin
+systemddir = $(prefix)/lib/systemd/system
+DESTDIR =
+Q = @
+
+########################################################################
+
+MAKEFLAGS += -r
+vars = $(patsubst .var.%,%,$(filter .var.%,$^))
+build_targets = httpconnectd httpconnectd@.service httpconnectd.socket
+install_targets = $(DESTDIR)$(bindir)/httpconnectd $(DESTDIR)$(systemddir)/httpconnectd@.service $(DESTDIR)$(systemddir)/httpconnectd.socket
+
+all: $(build_targets)
+install: $(install_targets)
+clean:
+ rm -f -- httpconnectd httpconnectd@.service
+uninstall:
+ rm -f -- $(install_targets)
+ rmdir -p -- $(dir $(install_targets))
+.PHONY: all install clean uninstall
+
+%: %.sh
+ install -m755 $< $@
+
+%: %.in
+ $(if $(Q),$(Q)echo 'EDIT < $< > $@';)$(if $(vars),sed $(foreach v,$(vars), -e 's|$(v)|$($(v))|g' ),cat) < $< > $@
+
+$(DESTDIR)$(bindir)/%: %
+ install -Dm755 $< $@
+$(DESTDIR)$(systemddir)/%: %
+ install -Dm644 $< $@
+
+.var.%: FORCE
+ $(Q)printf '%s' '$($*)' > .tmp$@ && { cmp -s .tmp$@ $@ && rm -f -- .tmp$@ || mv -Tf .tmp$@ $@; } || { rm -f -- .tmp$@; false; }
+
+.DELETE_ON_ERROR:
+.SECONDARY:
+.PHONY: FORCE