#
# 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
#
#
AUTOCONF ?= autoconf
+CABAL ?= cabal
DARCS ?= darcs
DITZ ?= ditz
FIND ?= find
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 ?= \
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"; \