summaryrefslogtreecommitdiffhomepage
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile32
1 files changed, 29 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index 3752e24..58def76 100644
--- a/Makefile
+++ b/Makefile
@@ -1,13 +1,38 @@
+# 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
+# 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 keysafe
$(MAKE) keysafe
keysafe:
- $(BUILDER) build
+ 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 keysafe -type f | grep build/keysafe/keysafe | tail -n 1) keysafe; \
else \
@@ -15,7 +40,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 Setup.hi Setup.o
install: install-files
useradd --system keysafe