From: Michael Orlitzky Date: Sat, 1 Feb 2020 22:57:18 +0000 (-0500) Subject: makefile: move ghc-options from the cabal file into the makefile. X-Git-Tag: 0.5.2~1 X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=9ea7693021b2286f07d29ac72761f31a10bef39d;p=haeredes.git makefile: move ghc-options from the cabal file into the makefile. We shouldn't be hard-coding user preferences into the cabal file that everyone uses. Instead, GHC should support a variable like CFLAGS that lets users and developers specify what warnings and optimizations they would like to use. Instead, we have to fake it: I've standardized the Gentoo HCFLAGS variable within the makefile, so that a few warnings will be appended to the (exported) environment variable but otherwise no flags will be forced by the cabal file. This should work for me when I'm developing, because the warnings will be appended to the HCFLAGS="-O2" that I have set in my environment. It will work on Gentoo, because HCFLAGS are already passed to the cabal build system in Gentoo. It will work(ish) everywhere else, because nothing will get passed to the cabal build system, and that's okay. --- diff --git a/haeredes.cabal b/haeredes.cabal index fac5582..f656773 100644 --- a/haeredes.cabal +++ b/haeredes.cabal @@ -86,17 +86,6 @@ executable haeredes Paths_haeredes Timeout - ghc-options: - -Weverything - -Wno-implicit-prelude - -Wno-safe - -Wno-unsafe - -Wno-all-missed-specialisations - -rtsopts - -threaded - -optc-O3 - -optc-march=native - test-suite doctests type: exitcode-stdio-1.0 @@ -108,18 +97,6 @@ test-suite doctests doctest >= 0.9, filemanip >= 0.3.6 - -- It's not entirely clear to me why I have to reproduce all of this. - ghc-options: - -Weverything - -Wno-implicit-prelude - -Wno-safe - -Wno-unsafe - -Wno-all-missed-specialisations - -rtsopts - -threaded - -optc-O3 - -optc-march=native - -- These won't work without shelltestrunner installed in your -- $PATH. Maybe there is some way to tell Cabal that. @@ -132,18 +109,6 @@ test-suite shelltests base == 4.*, process >= 1.1 - -- It's not entirely clear to me why I have to reproduce all of this. - ghc-options: - -Weverything - -Wno-implicit-prelude - -Wno-safe - -Wno-unsafe - -Wno-all-missed-specialisations - -rtsopts - -threaded - -optc-O3 - -optc-march=native - source-repository head type: git diff --git a/makefile b/makefile index f67f8a5..049fe55 100644 --- a/makefile +++ b/makefile @@ -2,11 +2,22 @@ PN = haeredes BIN = dist/build/$(PN)/$(PN) SRCS = $(shell find src/ -type f -name '*.hs') +# Append these warnings to the HCFLAGS environment variable that gets +# passed as options to GHC. We want to see the warnings while developing +# but don't want them hard-coded in the cabal file for end users. +HCFLAGS += -Weverything \ + -Wno-implicit-prelude \ + -Wno-safe \ + -Wno-unsafe \ + -Wno-all-missed-specialisations \ + -rtsopts \ + -threaded + .PHONY : dist hlint $(BIN): $(PN).cabal $(SRCS) runghc Setup.hs configure --user - runghc Setup.hs build + runghc Setup.hs build --ghc-options="${HCFLAGS}" doc: $(PN).cabal $(SRCS) runghc Setup.hs haddock --all \ @@ -23,12 +34,12 @@ TEST_SRCS := $(shell find test/ -type f -name '*.hs') $(TESTSUITE_BIN): $(PN).cabal $(SRCS) $(TEST_SRCS) runghc Setup.hs configure --user --enable-tests --prefix=/ - runghc Setup.hs build + runghc Setup.hs build --ghc-options="${HCFLAGS}" $(DOCTESTS_BIN): $(PN).cabal $(SRCS) $(TEST_SRCS) runghc Setup.hs configure --user --enable-tests - runghc Setup.hs build + runghc Setup.hs build --ghc-options="${HCFLAGS}" check: $(BIN) $(TESTSUITE_BIN) $(DOCTESTS_BIN) runghc Setup.hs test