X-Git-Url: http://git.cielonegro.org/gitweb.cgi?p=cabal-shared-makefile.git;a=blobdiff_plain;f=cabal-package.mk;h=65404dc96eb9d0fc6a689a1bb08db8edbf60a9df;hp=bec1d1419da2a391f41db8acf50c6422ae8ed693;hb=HEAD;hpb=6763d10d661f388d4029a3631c2bccdadc667915 diff --git a/cabal-package.mk b/cabal-package.mk index bec1d14..65404dc 100644 --- a/cabal-package.mk +++ b/cabal-package.mk @@ -2,26 +2,50 @@ # # 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) @@ -47,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: @@ -66,14 +90,14 @@ 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 @@ -89,23 +113,30 @@ clean: clean-hook clean-hook: doc: setup-config - ./Setup haddock $(HADDOCK_OPTS) + $(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 # -- 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 \ @@ -113,8 +144,9 @@ fixme: \( -name '*.c' -or -name '*.h' -or \ -name '*.hs' -or -name '*.lhs' -or \ -name '*.hsc' -or -name '*.cabal' \) \ - -exec egrep 'FIXME|THINKME|TODO' {} \+ \ + -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) @@ -141,21 +173,21 @@ 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 \ + $(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