#
# 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)
all: build
build: setup-config build-hook
- ./Setup build
+ $(SETUP_CMD) build
$(RM_RF) *.tix
build-hook:
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
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 \
\( -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)
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