fixup! Add PairAt, TokenAt and PlainAt.
[doclang.git] / GNUmakefile
index dabdab471232408d4be1a4714f8161afa8c8c76c..50b13d621f859c5f2584c99d72197cbcdfeeb8cc 100644 (file)
@@ -1,4 +1,5 @@
-CABAL := $(shell find . -maxdepth 1 -name '*.cabal' -printf %f -quit)
+cabal := $(shell find . -name '*.cabal' -print -quit)
+package := $(notdir ./$(cabal:.cabal=))
 
 all: build
 
@@ -7,9 +8,21 @@ 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 ?= ":main $(GHCID_TEST_ARGS)"
+ghcid:
+       ghcid \
+        --warnings \
+        --command "stack ghci \
+          $(package):lib \
+          $(package):$(package) \
+          --ghci-options=-fobject-code" \
+        --test $(GHCID_TEST) \
+        $(GHCID_FLAGS)
+
 clean:
        stack $(STACK_FLAGS) clean $(STACK_CLEAN_FLAGS)
 cleaner:
@@ -21,8 +34,8 @@ cleaner:
 %/fast: %
        
 
-%/debug: override STACK_BUILD_FLAGS+=--flag $(CABAL:.cabal=):debug
-%/debug: override STACK_TEST_FLAGS+=--flag $(CABAL:.cabal=):debug
+%/debug: override STACK_BUILD_FLAGS+=--flag $(cabal:.cabal=):debug
+%/debug: override STACK_TEST_FLAGS+=--flag $(cabal:.cabal=):debug
 %/debug: %
        
 
@@ -33,7 +46,7 @@ doc:
 %.html/view: %.html
        sensible-browser $*.html
 
-HLint.hs: $(shell find . -name '*.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
@@ -41,13 +54,13 @@ HLint.hs: $(shell find . -name '*.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