-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
+PN = spline3
+BIN = dist/build/$(PN)/$(PN)
+SRCS := $(shell find src/ -type f -name '*.hs')
-BIN := spline
+BIN = dist/build/spline3/spline3
+DOCTESTS_BIN = dist/build/doctests/doctests
+TESTSUITE_BIN = dist/build/testsuite/testsuite
-.PHONY : test doc src_html
+.PHONY : test doc dist hlint
-$(BIN): src/*.hs
- ghc -O2 $(GHC_WARNINGS) --make -o bin/${BIN} src/*.hs
+$(BIN): $(PN).cabal $(SRCS)
+ runghc Setup.hs configure \
+ --user \
+ --prefix=/ \
+ --flags=${FLAGS}
+ runghc Setup.hs build
-all: $(BIN) test_src
+$(DOCTESTS_BIN): $(SRCS) test/Doctests.hs
+ runghc Setup.hs configure \
+ --user \
+ --prefix=/ \
+ --flags=${FLAGS} \
+ --enable-tests
+ runghc Setup.hs build
-test_src: src/Tests/*.hs
- ghc -O2 $(GHC_WARNINGS) --make -o bin/${BIN} src/*.hs src/Tests/*.hs
+$(TESTSUITE_BIN): $(SRCS) test/TestSuite.hs
+ runghc Setup.hs configure \
+ --user \
+ --prefix=/ \
+ --flags=${FLAGS} \
+ --enable-tests
+ runghc Setup.hs build
-profile: src/*.hs
- ghc -O2 $(GHC_WARNINGS) -prof -auto-all --make -o bin/$(BIN) src/*.hs
+llvm: $(PN).cabal $(SRCS)
+ FLAGS="llvm" make
+
+profile: $(SRCS)
+ runghc Setup.hs configure \
+ --user \
+ --prefix=/ \
+ --enable-executable-profiling
+ runghc Setup.hs build
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/*
-
-test:
- runghc -i"src" test/TestSuite.hs
+ rm -f .hpc
+test: $(PN).cabal $(TESTSUITE_BIN) $(DOCTESTS_BIN) $(BIN)
+ runghc Setup.hs test
-src_html:
- util/hscolour_srcs
+dist:
+ runghc Setup.hs configure --prefix=/
+ TAR_OPTIONS="--format=ustar" runghc Setup.hs sdist
+doc: dist/doc
-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
+dist/doc: $(PN).cabal $(SRCS)
+ runghc Setup.hs configure --user --prefix=/ --flags=${FLAGS}
+ runghc Setup.hs hscolour --all
+ runghc Setup.hs haddock --all \
+ --hyperlink-source \
+ --haddock-options="--ignore-all-exports"
-doc: src_html
- haddock $(DOCS) --html --use-unicode \
- --odir=doc/ --title="spline3" \
- --source-module="src/%{MODULE/.//}.html" \
- --source-entity="src/%{MODULE/.//}.html#%{NAME}" \
- src/*.hs src/Tests/*.hs
+hlint:
+ hlint --ignore="Use camelCase" \
+ --ignore="Redundant bracket" \
+ --color \
+ src