-GHC_WARNINGS := -Wall
-GHC_WARNINGS += -fwarn-hi-shadowing
-GHC_WARNINGS += -fwarn-missing-signatures
-GHC_WARNINGS += -fwarn-name-shadowing
-GHC_WARNINGS += -fwarn-orphans
-GHC_WARNINGS += -fwarn-type-defaults
-
-BIN := spline3
-
-.PHONY : test doc src_html hlint
-
-$(BIN): src/*.hs
- ghc -O2 $(GHC_WARNINGS) --make -o bin/${BIN} src/*.hs
-
-all: $(BIN) test_src
-
-test_src: src/Tests/*.hs
- ghc -O2 $(GHC_WARNINGS) --make -o bin/${BIN} src/*.hs src/Tests/*.hs
-
-profile: src/*.hs
- ghc -O2 $(GHC_WARNINGS) -prof -auto-all --make -o bin/$(BIN) src/*.hs
+PN = spline3
+BIN = dist/build/$(PN)/$(PN)
+SRCS := $(shell find src/ -type f -name '*.hs')
+
+BIN = dist/build/spline3/spline3
+DOCTESTS_BIN = dist/build/doctests/doctests
+TESTSUITE_BIN = dist/build/testsuite/testsuite
+
+# 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 \
+ -Wno-prepositive-qualified-module \
+ -Wno-missing-safe-haskell-mode \
+ -Wno-missing-deriving-strategies \
+ -rtsopts \
+ -threaded
+
+.PHONY : test doc dist hlint
+
+$(BIN): $(PN).cabal $(SRCS)
+ runghc Setup.hs configure --user --prefix=/
+ runghc Setup.hs build --ghc-options="${HCFLAGS}"
+
+$(DOCTESTS_BIN): $(SRCS) test/Doctests.hs
+ runghc Setup.hs configure --user --prefix=/ --enable-tests
+ runghc Setup.hs build --ghc-options="${HCFLAGS}"
+
+$(TESTSUITE_BIN): $(SRCS) test/TestSuite.hs
+ runghc Setup.hs configure --user --prefix=/ --enable-tests
+ runghc Setup.hs build --ghc-options="${HCFLAGS}"
clean:
- rm -f bin/$(BIN)
- rm -f src/*.hi
- rm -f src/*.o
- rm -f src/Tests/*.hi
- rm -f src/Tests/*.o
+ runghc Setup.hs clean
+ rm -rf dist/
rm -f *.prof
- rm -rf doc/html/*
-
-test:
- runghc -i"src" test/TestSuite.hs
-
+ rm -f .hpc
-src_html:
- util/hscolour_srcs
+check: $(PN).cabal $(TESTSUITE_BIN) $(DOCTESTS_BIN) $(BIN)
+ runghc Setup.hs test
+dist:
+ runghc Setup.hs configure --prefix=/
+ TAR_OPTIONS="--format=ustar" runghc Setup.hs sdist
-DOCS := -i /usr/share/doc/ghc-6.12.3/html/libraries/base-4.2.0.2/base.haddock
-DOCS += -i /usr/share/doc/storable-complex-0.2.1/html/storable-complex.haddock
-DOCS += -i /usr/share/doc/hmatrix-0.10.0.1/html/hmatrix.haddock
+doc: dist/doc
-doc: src_html
- haddock $(DOCS) --html --use-unicode \
- --odir=doc/html/ --title="spline3" \
- --source-module="src/%{MODULE/.//}.html" \
- --source-entity="src/%{MODULE/.//}.html#%{NAME}" \
- src/*.hs src/Tests/*.hs
+dist/doc: $(PN).cabal $(SRCS)
+ runghc Setup.hs configure --user --prefix=/
+ runghc Setup.hs haddock --all \
+ --hyperlink-source \
+ --haddock-options="--ignore-all-exports"
hlint:
hlint --ignore="Use camelCase" \
- --ignore="Redundant bracket" \
- --color \
- src
+ --ignore="Redundant bracket" \
+ --color \
+ src