summaryrefslogtreecommitdiffhomepage
path: root/Makefile
diff options
context:
space:
mode:
authorJoey Hess <joeyh@joeyh.name>2017-05-04 14:14:33 -0400
committerJoey Hess <joeyh@joeyh.name>2017-05-04 14:16:19 -0400
commit8176f6bf93c382dd1a9ca1d549d3a8213ef62f99 (patch)
tree2b8b8b31354fe7e15cfa66a7c08704c004ac6cd8 /Makefile
parent0aebedadd392e495ffc8f7c2fa74d712f16c2d7d (diff)
downloaddebug-me-8176f6bf93c382dd1a9ca1d549d3a8213ef62f99.tar.gz
add init script, systemd service file, Makefile
for debug-me server installation Adapted from keysafe
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile62
1 files changed, 62 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..ca07972
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,62 @@
+# The install target will add this before all paths it writes to.
+PREFIX?=
+
+# Can be "stack" or "cabal", or "./Setup" to build and use Setup.hs
+BUILDER?=stack
+
+# Options to pass to the BUILDER.
+# Using -j1 may result in a reproducible build.
+BUILDEROPTIONS?=
+
+# Propigate flags through ghc to linker and compiler.
+ghc_options=$(shell \
+ for w in $(LDFLAGS); do \
+ printf -- "-optl%s\n" "$$w"; \
+ done; \
+ for w in $(CFLAGS); do \
+ printf -- "-optc%s\n" "$$w"; \
+ done; \
+ for w in $(CPPFLAGS); do \
+ printf -- "-optc-Wp,%s\n" "$$w"; \
+ done; \
+ )
+
+build:
+ rm -f debug-me
+ $(MAKE) debug-me
+
+debug-me:
+ if [ "$(BUILDER)" = ./Setup ]; then ghc --make Setup; fi
+ if [ "$(BUILDER)" = stack ]; then \
+ $(BUILDER) build --ghc-options="$(ghc_options)" $(BUILDEROPTIONS); \
+ else \
+ $(BUILDER) configure --ghc-options="$(ghc_options)"; \
+ $(BUILDER) build $(BUILDEROPTIONS); \
+ fi
+ if [ "$(BUILDER)" = stack ]; then \
+ ln -sf $$(find .stack-work/ -name debug-me -type f | grep build/debug-me/debug-me | tail -n 1) debug-me; \
+ else \
+ ln -sf dist/build/debug-me/debug-me debug-me; \
+ fi
+
+clean:
+ if [ "$(BUILDER)" != ./Setup ] && [ "$(BUILDER)" != cabal ]; then $(BUILDER) clean; fi
+ rm -rf debug-me dist .stack-work Setup Setup.hi Setup.o
+
+install: install-files
+ useradd --system debug-me
+ chmod 700 $(PREFIX)/var/log/debug-me
+ chown debug-me:debug-me $(PREFIX)/var/log/debug-me
+
+install-files: debug-me
+ install -d $(PREFIX)/var/log/debug-me
+ install -d $(PREFIX)/usr/bin
+ install -s -m 0755 debug-me $(PREFIX)/usr/bin/debug-me
+ install -d $(PREFIX)/usr/share/man/man1
+ install -m 0644 debug-me.1 $(PREFIX)/usr/share/man/man1/debug-me.1
+ install -d $(PREFIX)/lib/systemd/system
+ install -m 0644 debug-me.service $(PREFIX)/lib/systemd/system/debug-me.service
+ install -d $(PREFIX)/etc/init.d
+ install -m 0755 debug-me.init $(PREFIX)/etc/init.d/debug-me
+ install -d $(PREFIX)/etc/default
+ install -m 0644 debug-me.default $(PREFIX)/etc/default/debug-me