-CABAL := $(shell find . -name '*.cabal' -print -quit)
-HS := $(shell find . -name '*.hs')
+cabal := $(shell find . -name '*.cabal' -print -quit)
+package := $(notdir ./$(cabal:.cabal=))
all: build
.PHONY: test
test:
- ! grep -q '^Test-Suite\>' $(CABAL) || \
+ ! grep -q '^Test-Suite\>' $(cabal) || \
{ stack $(STACK_FLAGS) test $(STACK_TEST_FLAGS); }
+GHCID_TEST_ARGS ?=
+#GHCID_TEST ?= System.Environment.setEnv \"LANG\" \"$(LANG)\"$$(printf "\\n:")main $(GHCID_TEST_ARGS)
+GHCID_TEST ?= :main $(GHCID_TEST_ARGS)
+ghcid:
+ ghcid \
+ --warnings \
+ --command "stack $(STACK_FLAGS) $(GHCID_STACK_FLAGS) ghci $(GHCID_GHCI_FLAGS) \
+ $(shell 2>&1 stack ide targets | grep -v :test:) \
+ --ghci-options=-fobject-code" \
+ --test "$(GHCID_TEST)" \
+ $(GHCID_FLAGS)
+
clean:
stack $(STACK_FLAGS) clean $(STACK_CLEAN_FLAGS)
cleaner:
%/fast: %
+%/debug: override STACK_BUILD_FLAGS+=--flag $(cabal:.cabal=):debug
+%/debug: override STACK_TEST_FLAGS+=--flag $(cabal:.cabal=):debug
+%/debug: %
+
+
doc:
stack $(STACK_FLAGS) haddock $(STACK_HADDOCK_FLAGS)
%.html: %.md
%.html/view: %.html
sensible-browser $*.html
-HLint.hs: $(HS)
+HLint.hs: $(shell find . -name '*.hs' -not -name 'HLint.hs')
sed -i -e '/^-- BEGIN: generated hints/,/^-- END: Generated by hlint/d' HLint.hs
echo '-- BEGIN: generated hints' >> HLint.hs
- hlint --find . | grep '^'infix | sort -u >> HLint.hs
+ hlint --find . | sed -ne 's/^- infix: \(.*\)/\1/p' | sort -u >>HLint.hs
echo '-- END: generated hints' >> HLint.hs
-lint: HLint.hs $(HS)
+lint: HLint.hs
if hlint --quiet --report=hlint.html -XNoCPP \
- $(shell cabal-cargs --format=ghc --only=default_extensions --sourcefile=$(CABAL)) $(HLINT_FLAGS) .; \
+ $(shell cabal-cargs --format=ghc --only=default_extensions --sourcefile=$(cabal)) $(HLINT_FLAGS) .; \
then rm -f hlint.html; \
- else sensible-browser hlint.html & fi
+ else sensible-browser ./hlint.html & fi
tag:
- name=$$(sed -ne 's/^name: *\(.*\)/\1/p' "$(CABAL)"); \
- version=$$(sed -ne 's/^version: *\(.*\)/\1/p' "$(CABAL)"); \
+ name=$$(sed -ne 's/^name: *\(.*\)/\1/p' "$(cabal)"); \
+ version=$$(sed -ne 's/^version: *\(.*\)/\1/p' "$(cabal)"); \
git tag --merged | grep -Fqx "$$name-$$version" || \
git tag -f -s -m "$$name v$$version" $$name-$$version