summaryrefslogtreecommitdiffhomepage
path: root/Makefile
diff options
context:
space:
mode:
authorJoey Hess <joeyh@joeyh.name>2016-10-22 19:00:56 -0400
committerJoey Hess <joeyh@joeyh.name>2016-10-22 19:00:56 -0400
commit63faaf6ccf624c59293245302cde2e1ddba76f1a (patch)
tree295dc143b0ee3c34ccacd2984c685f800727e905 /Makefile
parent62e4db20e12949487b43dc6e3a8f4c1182fb4abc (diff)
downloadkeysafe-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.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile29
1 files changed, 26 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index 3752e24..9b2fcaa 100644
--- a/Makefile
+++ b/Makefile
@@ -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