# 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