From 63faaf6ccf624c59293245302cde2e1ddba76f1a Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 22 Oct 2016 19:00:56 -0400 Subject: makefile improvements * Makefile: Propigate LDFLAGS, CFLAGS, and CPPFLAGS through ghc. * Makefile: Allow setting BUILDER=./Setup to build w/o cabal or stack. --- CHANGELOG | 2 ++ Makefile | 29 ++++++++++++++++++++++++++--- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 9a48ae5..f67553e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -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 Sat, 22 Oct 2016 18:14:32 -0400 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 -- cgit v1.2.3