1 # -*- makefile-gmake -*-
5 # CONFIGURE_ARGS :: arguments to be passed to ./Setup configure
6 # default: --disable-optimization
8 # RUN_COMMAND :: command to be run for "make run"
20 CONFIGURE_ARGS ?= --disable-optimization
21 HADDOCK_OPTS ?= --hyperlink-source
23 --hint=Default --hint=Dollar --hint=Generalise \
25 --report=dist/report.html
27 SETUP_FILE := $(wildcard Setup.*hs)
28 CABAL_FILE := $(wildcard *.cabal)
29 PKG_NAME := $(CABAL_FILE:.cabal=)
31 ifeq ($(shell ls configure.ac 2>/dev/null),configure.ac)
32 AUTOCONF_AC_FILE := configure.ac
33 AUTOCONF_FILE := configure
35 ifeq ($(shell ls configure.in 2>/dev/null),configure.in)
36 AUTOCONF_AC_FILE := configure.in
37 AUTOCONF_FILE := configure
44 BUILDINFO_IN_FILE := $(wildcard *.buildinfo.in)
45 BUILDINFO_FILE := $(BUILDINFO_IN_FILE:.in=)
49 build: setup-config build-hook
55 ifeq ($(RUN_COMMAND),)
57 @echo "cabal-package.mk: No command to run."
58 @echo "cabal-package.mk: If you want to run something, define RUN_COMMAND variable."
61 @echo ".:.:. Let's go .:.:."
65 setup-config: dist/setup-config setup-config-hook $(BUILDINFO_FILE)
69 dist/setup-config: $(CABAL_FILE) Setup $(AUTOCONF_FILE)
70 ./Setup configure $(CONFIGURE_ARGS)
72 $(AUTOCONF_FILE): $(AUTOCONF_AC_FILE)
75 $(BUILDINFO_FILE): $(BUILDINFO_IN_FILE) configure
76 ./Setup configure $(CONFIGURE_ARGS)
82 rm -f dist/setup-config
86 $(RM_RF) dist Setup *.o *.hi .setup-config *.buildinfo *.tix .hpc
87 $(FIND) . -name '*~' -exec rm -f {} \;
92 ./Setup haddock $(HADDOCK_OPTS)
95 $(SUDO) ./Setup install
103 if ls *.tix >/dev/null 2>&1; then \
104 $(HPC) sum --output="merged.tix" --union --exclude=Main *.tix; \
105 $(HPC) markup --destdir="dist/hpc" --fun-entry-count "merged.tix"; \
108 # -- Find FIXME Tags ----------------------------------------------------------
111 \( -name 'dist' -or -name '.git' -or -name '_darcs' \) -prune \
113 \( -name '*.c' -or -name '*.h' -or \
114 -name '*.hs' -or -name '*.lhs' -or \
115 -name '*.hsc' -or -name '*.cabal' \) \
116 -exec egrep 'FIXME|THINKME|TODO' {} \+ \
117 || echo 'No FIXME, THINKME, nor TODO found.'
119 # -- HLint --------------------------------------------------------------------
120 HLINT_TARGETS ?= $$(find -E . -type d -name dist -prune -o -regex '.*\.(hsc?|lhs)' -print)
122 $(HLINT) $(HLINT_TARGETS) $(HLINT_OPTS)
124 # -- Ditz the Distributed Issue Tracker ---------------------------------------
125 ifeq (,$(wildcard .ditz-config))
129 $(DITZ) html dist/ditz
133 $(DITZ) releases | awk '{print $$1}' | sort --reverse | while read i; do \
134 $(DITZ) changelog $$i >> $@; \
139 # -- Pushing to remote hosts --------------------------------------------------
140 push: push-repo push-ditz push-doc
143 if [ -d "_darcs" ]; then \
145 elif [ -d ".git" ]; then \
146 git push --all && git push --tags; \
150 if [ -d "dist/ditz" ]; then \
153 www@nem.cielonegro.org:static.cielonegro.org/htdocs/ditz/$(PKG_NAME); \
157 if [ -d "dist/doc" ]; then \
159 dist/doc/html/$(PKG_NAME)/ \
160 www@nem.cielonegro.org:static.cielonegro.org/htdocs/doc/$(PKG_NAME); \
163 # -- Phony Targets ------------------------------------------------------------
164 .PHONY: build build-hook setup-config setup-config-hook run clean clean-hook \
165 install doc sdist test lint push push-repo push-ditz push-doc \