11# NOTE: `cabal test` will take care to build the local `alex`
2- # executable and place it into $PATH for us to pick up.
3- #
2+ # executable and place it into $PATH for us to pick up.
3+ #
44# If it doesn't look like the alex binary in $PATH comes from the
55# build tree, then we'll fall back to pointing to
66# ../dist/build/alex/alex to support running tests via "runghc
1313
1414# NOTE: This assumes that a working `ghc` is on $PATH; this may not necessarily be the same GHC used by `cabal` for building `alex`.
1515HC =ghc
16- HC_OPTS =-Wall -fwarn-incomplete-uni-patterns -fno-warn-missing-signatures -fno-warn-unused-imports -fno-warn-tabs -Werror
16+
17+ # Some GHC warnings are only available from a certain version on
18+ # Get the GHC version
19+ GHC_VERSION: =$(shell ghc --numeric-version)
20+ GHC_VERSION_WORDS =$(subst ., ,$(GHC_VERSION ) )
21+ GHC_MAJOR_VERSION =$(word 1,$(GHC_VERSION_WORDS ) )
22+ GHC_MINOR_VERSION =$(word 2,$(GHC_VERSION_WORDS ) )
23+ # -fwarn-incomplete-uni-patterns only from 7.4
24+ WARNS_FOR_GHC_GTEQ_7_4 =-fwarn-incomplete-uni-patterns
25+ WARNS_FOR_GHC_LT_7_4 =-fno-warn-lazy-unlifted-bindings
26+ WARNS_DEP_GHC_GTEQ_7_4: =$(shell if [ $(GHC_MAJOR_VERSION ) -gt 7 -o $(GHC_MAJOR_VERSION ) -ge 7 -a $(GHC_MINOR_VERSION ) -ge 4 ]; then echo "$(WARNS_FOR_GHC_GTEQ_7_4 ) "; else echo "$(WARNS_FOR_GHC_LT_7_4 ) "; fi)
27+
28+ HC_OPTS =-Wall $(WARNS_DEP_GHC_GTEQ_7_4 ) -fno-warn-missing-signatures -fno-warn-unused-imports -fno-warn-tabs -Werror
1729
1830.PRECIOUS : % .n.hs % .g.hs % .o % .exe % .bin
1931
@@ -73,7 +85,8 @@ ALL_TESTS = $(patsubst %.hs, %.run, $(ALL_TEST_HS))
7385
7486all :: $(ALL_TESTS )
7587
76- .PHONY : clean
88+ .PHONY : clean debug
89+
7790clean :
7891 rm -f $(CLEAN_FILES )
7992
@@ -82,3 +95,8 @@ interact:
8295 ghci -cpp -i../src -i../dist/build/autogen -i../dist/build/alex/alex-tmp Main -fbreak-on-exception
8396# -args='--template=.. simple.x -o simple.n.hs'
8497# :set args --template=.. simple.x -o simple.n.hs
98+
99+ debug :
100+ @echo HC_OPTS=$(HC_OPTS )
101+
102+ # EOF
0 commit comments