From 8176f6bf93c382dd1a9ca1d549d3a8213ef62f99 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 4 May 2017 14:14:33 -0400 Subject: add init script, systemd service file, Makefile for debug-me server installation Adapted from keysafe --- Makefile | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 Makefile (limited to 'Makefile') 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 -- cgit v1.2.3