diff options
author | Joey Hess <joeyh@joeyh.name> | 2016-10-22 19:00:56 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2016-10-22 19:00:56 -0400 |
commit | 63faaf6ccf624c59293245302cde2e1ddba76f1a (patch) | |
tree | 295dc143b0ee3c34ccacd2984c685f800727e905 | |
parent | 62e4db20e12949487b43dc6e3a8f4c1182fb4abc (diff) | |
download | keysafe-63faaf6ccf624c59293245302cde2e1ddba76f1a.tar.gz |
makefile improvements
* Makefile: Propigate LDFLAGS, CFLAGS, and CPPFLAGS through ghc.
* Makefile: Allow setting BUILDER=./Setup to build w/o cabal or stack.
-rw-r--r-- | CHANGELOG | 2 | ||||
-rw-r--r-- | Makefile | 29 |
2 files changed, 28 insertions, 3 deletions
@@ -6,6 +6,8 @@ keysafe (0.20161008) UNRELEASED; urgency=medium Thanks, Sean Whitton * Fix some mispellings. Thanks, Sean Whitton + * Makefile: Propigate LDFLAGS, CFLAGS, and CPPFLAGS through ghc. + * Makefile: Allow setting BUILDER=./Setup to build w/o cabal or stack. -- Joey Hess <id@joeyh.name> Sat, 22 Oct 2016 18:14:32 -0400 @@ -1,13 +1,35 @@ +# The install target will add this before all paths it writes to. PREFIX?= -# Can be stack or cabal + +# Can be "stack" or "cabal", or "./Setup" to build and use Setup.hs BUILDER?=stack +# 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 keysafe $(MAKE) keysafe keysafe: - $(BUILDER) build + if [ "$(BUILDER)" = ./Setup ]; then ghc --make Setup; fi + if [ "$(BUILDER)" = stack ]; then \ + $(BUILDER) build --ghc-options="$(ghc_options)"; \ + else \ + $(BUILDER) configure --ghc-options="$(ghc_options)"; \ + $(BUILDER) build; \ + fi + $(BUILDER) build --ghc-options="$(ghc_options)" if [ "$(BUILDER)" = stack ]; then \ ln -sf $$(find .stack-work/ -name keysafe -type f | grep build/keysafe/keysafe | tail -n 1) keysafe; \ else \ @@ -15,7 +37,8 @@ keysafe: fi clean: - rm -rf keysafe dist .stack-work + if [ "$(BUILDER)" != ./Setup ] && [ "$(BUILDER)" != cabal ]; then $(BUILDER) clean; fi + rm -rf keysafe dist .stack-work Setup install: install-files useradd --system keysafe |