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"
24 CONFIGURE_ARGS ?= --disable-optimization
25 HADDOCK_OPTS ?= --hyperlink-source
27 --hint=Default --hint=Dollar --hint=Generalise \
29 --ignore="Parse error" \
30 --report=dist/report.html
32 SETUP_FILE := $(wildcard Setup.*hs)
33 CABAL_FILE := $(wildcard *.cabal)
34 PKG_NAME := $(CABAL_FILE:.cabal=)
36 ifeq ($(shell ls configure.ac 2>/dev/null),configure.ac)
37 AUTOCONF_AC_FILE := configure.ac
38 AUTOCONF_FILE := configure
40 ifeq ($(shell ls configure.in 2>/dev/null),configure.in)
41 AUTOCONF_AC_FILE := configure.in
42 AUTOCONF_FILE := configure
49 BUILDINFO_IN_FILE := $(wildcard *.buildinfo.in)
50 BUILDINFO_FILE := $(BUILDINFO_IN_FILE:.in=)
54 build: setup-config build-hook
60 ifeq ($(RUN_COMMAND),)
62 @echo "cabal-package.mk: No command to run."
63 @echo "cabal-package.mk: If you want to run something, define RUN_COMMAND variable."
66 @echo ".:.:. Let's go .:.:."
70 setup-config: dist/setup-config setup-config-hook $(BUILDINFO_FILE)
74 dist/setup-config: $(CABAL_FILE) Setup $(AUTOCONF_FILE)
75 ./Setup configure $(CONFIGURE_ARGS)
77 $(AUTOCONF_FILE): $(AUTOCONF_AC_FILE)
80 $(BUILDINFO_FILE): $(BUILDINFO_IN_FILE) configure
81 ./Setup configure $(CONFIGURE_ARGS)
87 rm -f dist/setup-config
91 $(RM_RF) dist Setup *.o *.hi .setup-config *.buildinfo *.tix .hpc
92 $(FIND) . -name '*~' -exec rm -f {} \;
97 ./Setup haddock $(HADDOCK_OPTS)
100 $(SUDO) ./Setup install
108 if ls *.tix >/dev/null 2>&1; then \
109 $(HPC) sum --output="merged.tix" --union --exclude=Main *.tix; \
110 $(HPC) markup --destdir="dist/hpc" --fun-entry-count "merged.tix"; \
113 # -- Find FIXME Tags ----------------------------------------------------------
114 ifeq ($(shell ls -d .git 2>/dev/null),.git)
117 -depth 1 -not -name '*.mk' \
118 -exec $(GIT) grep -E 'FIXME|THINKME|TODO' {} + \
119 || echo 'No FIXME, THINKME, nor TODO found.'
123 \( -name 'dist' -or -name '.git' -or -name '_darcs' \) -prune \
125 \( -name '*.c' -or -name '*.h' -or \
126 -name '*.hs' -or -name '*.lhs' -or \
127 -name '*.hsc' -or -name '*.cabal' \) \
128 -exec $(GREP) -n -E 'FIXME|THINKME|TODO' {} + \
129 || echo 'No FIXME, THINKME, nor TODO found.'
132 # -- HLint --------------------------------------------------------------------
133 HLINT_TARGETS ?= $$(find -E . -type d -name dist -prune -o -regex '.*\.(hsc?|lhs)' -print)
135 $(HLINT) $(HLINT_TARGETS) $(HLINT_OPTS)
137 # -- Ditz the Distributed Issue Tracker ---------------------------------------
138 ifeq (,$(wildcard .ditz-config))
142 $(DITZ) html dist/ditz
146 $(DITZ) releases | awk '{print $$1}' | sort --reverse | while read i; do \
147 $(DITZ) changelog $$i >> $@; \
152 # -- Pushing to remote hosts --------------------------------------------------
153 push: push-repo push-ditz push-doc
156 if [ -d "_darcs" ]; then \
158 elif [ -d ".git" ]; then \
159 $(GIT) push --all && git push --tags; \
163 if [ -d "dist/ditz" ]; then \
164 $(RSYNC) -av --delete \
166 www@nem.cielonegro.org:static.cielonegro.org/htdocs/ditz/$(PKG_NAME); \
170 if [ -d "dist/doc" ]; then \
171 $(RSYNC) -av --delete \
172 dist/doc/html/$(PKG_NAME)/ \
173 www@nem.cielonegro.org:static.cielonegro.org/htdocs/doc/$(PKG_NAME); \
176 # -- Phony Targets ------------------------------------------------------------
177 .PHONY: build build-hook setup-config setup-config-hook run clean clean-hook \
178 install doc sdist test lint push push-repo push-ditz push-doc \