X-Git-Url: http://git.cielonegro.org/gitweb.cgi?p=cabal-shared-makefile.git;a=blobdiff_plain;f=cabal-package.mk;h=65404dc96eb9d0fc6a689a1bb08db8edbf60a9df;hp=2363b98c6d4f6d38725bc0352c8cf6de2a08b9cf;hb=HEAD;hpb=36cf77fc0a6e09dc2e76c522fc05ef51d72c23ce diff --git a/cabal-package.mk b/cabal-package.mk index 2363b98..65404dc 100644 --- a/cabal-package.mk +++ b/cabal-package.mk @@ -2,22 +2,51 @@ # # Variables: # +# USE_CABAL_COMMAND :: whether to use the cabal(1) command instead +# of ./Setup +# default: "YES" if it's in the PATH, "NO" otherwise. +# # CONFIGURE_ARGS :: arguments to be passed to ./Setup configure # default: --disable-optimization # # RUN_COMMAND :: command to be run for "make run" # -GHC ?= ghc -FIND ?= find -RM_RF ?= rm -rf -SUDO ?= sudo AUTOCONF ?= autoconf +CABAL ?= cabal +DARCS ?= darcs +DITZ ?= ditz +FIND ?= find +GREP ?= grep +GHC ?= ghc +GIT ?= git HLINT ?= hlint HPC ?= hpc -DITZ ?= ditz +RM_RF ?= rm -rf +RSYNC ?= rsync +SUDO ?= sudo + +ifndef USE_CABAL_COMMAND +ifeq ($(shell which $(CABAL) >/dev/null 2>&1; echo $$?),0) +USE_CABAL_COMMAND := YES +else +USE_CABAL_COMMAND := NO +endif +endif + +ifeq ($(strip $(USE_CABAL_COMMAND)),YES) +SETUP_CMD := $(shell which $(CABAL)) +else +SETUP_CMD := ./Setup +endif CONFIGURE_ARGS ?= --disable-optimization +HADDOCK_OPTS ?= --hyperlink-source +HLINT_OPTS ?= \ + --hint=Default --hint=Dollar --hint=Generalise \ + --cross \ + --ignore="Parse error" \ + --report=dist/report.html SETUP_FILE := $(wildcard Setup.*hs) CABAL_FILE := $(wildcard *.cabal) @@ -42,7 +71,7 @@ BUILDINFO_FILE := $(BUILDINFO_IN_FILE:.in=) all: build build: setup-config build-hook - ./Setup build + $(SETUP_CMD) build $(RM_RF) *.tix build-hook: @@ -61,18 +90,22 @@ setup-config: dist/setup-config setup-config-hook $(BUILDINFO_FILE) setup-config-hook: -dist/setup-config: $(CABAL_FILE) Setup $(AUTOCONF_FILE) - ./Setup configure $(CONFIGURE_ARGS) +dist/setup-config: $(CABAL_FILE) $(SETUP_CMD) $(AUTOCONF_FILE) + $(SETUP_CMD) configure $(CONFIGURE_ARGS) $(AUTOCONF_FILE): $(AUTOCONF_AC_FILE) $(AUTOCONF) $(BUILDINFO_FILE): $(BUILDINFO_IN_FILE) configure - ./Setup configure $(CONFIGURE_ARGS) + $(SETUP_CMD) configure $(CONFIGURE_ARGS) Setup: $(SETUP_FILE) $(GHC) --make Setup +reconfigure: + rm -f dist/setup-config + $(MAKE) setup-config + clean: clean-hook $(RM_RF) dist Setup *.o *.hi .setup-config *.buildinfo *.tix .hpc $(FIND) . -name '*~' -exec rm -f {} \; @@ -80,25 +113,30 @@ clean: clean-hook clean-hook: doc: setup-config - ./Setup haddock + $(SETUP_CMD) haddock $(HADDOCK_OPTS) install: build - $(SUDO) ./Setup install + $(SUDO) $(SETUP_CMD) install sdist: setup-config - ./Setup sdist + $(SETUP_CMD) sdist test: build $(RM_RF) dist/test - ./Setup test + $(SETUP_CMD) test if ls *.tix >/dev/null 2>&1; then \ $(HPC) sum --output="merged.tix" --union --exclude=Main *.tix; \ $(HPC) markup --destdir="dist/hpc" --fun-entry-count "merged.tix"; \ fi -ditz: - $(DITZ) html dist/ditz - +# -- Find FIXME Tags ---------------------------------------------------------- +ifeq ($(shell ls -d .git 2>/dev/null),.git) +fixme: + @$(FIND) . \ + -depth 1 -not -name '*.mk' \ + -exec $(GIT) grep -E 'FIXME|THINKME|TODO' {} + \ + || echo 'No FIXME, THINKME, nor TODO found.' +else fixme: @$(FIND) . \ \( -name 'dist' -or -name '.git' -or -name '_darcs' \) -prune \ @@ -106,25 +144,55 @@ fixme: \( -name '*.c' -or -name '*.h' -or \ -name '*.hs' -or -name '*.lhs' -or \ -name '*.hsc' -or -name '*.cabal' \) \ - -exec egrep -i '(fixme|thinkme)' {} \+ \ - || echo 'No FIXME or THINKME found.' + -exec $(GREP) -n -E 'FIXME|THINKME|TODO' {} + \ + || echo 'No FIXME, THINKME, nor TODO found.' +endif +# -- HLint -------------------------------------------------------------------- +HLINT_TARGETS ?= $$(find -E . -type d -name dist -prune -o -regex '.*\.(hsc?|lhs)' -print) lint: - $(HLINT) . --report + $(HLINT) $(HLINT_TARGETS) $(HLINT_OPTS) + +# -- Ditz the Distributed Issue Tracker --------------------------------------- +ifeq (,$(wildcard .ditz-config)) +ditz: +else +ditz: + $(DITZ) html dist/ditz + +ChangeLog: + rm -f $@ + $(DITZ) releases | awk '{print $$1}' | sort --reverse | while read i; do \ + $(DITZ) changelog $$i >> $@; \ + done + head $@ +endif -push: doc ditz +# -- Pushing to remote hosts -------------------------------------------------- +push: push-repo push-ditz push-doc + +push-repo: if [ -d "_darcs" ]; then \ - darcs push; \ + $(DARCS) push; \ elif [ -d ".git" ]; then \ - git push --all && git push --tags; \ + $(GIT) push --all && git push --tags; \ + fi + +push-ditz: ditz + if [ -d "dist/ditz" ]; then \ + $(RSYNC) -av --delete \ + dist/ditz/ \ + www@nem.cielonegro.org:static.cielonegro.org/htdocs/ditz/$(PKG_NAME); \ fi + +push-doc: doc if [ -d "dist/doc" ]; then \ - rsync -av --delete \ + $(RSYNC) -av --delete \ dist/doc/html/$(PKG_NAME)/ \ www@nem.cielonegro.org:static.cielonegro.org/htdocs/doc/$(PKG_NAME); \ fi - rsync -av --delete \ - dist/ditz/ \ - www@nem.cielonegro.org:static.cielonegro.org/htdocs/ditz/$(PKG_NAME) -.PHONY: build build-hook setup-config setup-config-hook run clean clean-hook install doc sdist test lint push +# -- Phony Targets ------------------------------------------------------------ +.PHONY: build build-hook setup-config setup-config-hook run clean clean-hook \ + install doc sdist test lint push push-repo push-ditz push-doc \ + ChangeLog