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 --ignore="Parse error" \
26 --report=dist/report.html
28 SETUP_FILE := $(wildcard Setup.*hs)
29 CABAL_FILE := $(wildcard *.cabal)
30 PKG_NAME := $(CABAL_FILE:.cabal=)
32 ifeq ($(shell ls configure.ac 2>/dev/null),configure.ac)
33 AUTOCONF_AC_FILE := configure.ac
34 AUTOCONF_FILE := configure
36 ifeq ($(shell ls configure.in 2>/dev/null),configure.in)
37 AUTOCONF_AC_FILE := configure.in
38 AUTOCONF_FILE := configure
45 BUILDINFO_IN_FILE := $(wildcard *.buildinfo.in)
46 BUILDINFO_FILE := $(BUILDINFO_IN_FILE:.in=)
50 build: setup-config build-hook
56 ifeq ($(RUN_COMMAND),)
58 @echo "cabal-package.mk: No command to run."
59 @echo "cabal-package.mk: If you want to run something, define RUN_COMMAND variable."
62 @echo ".:.:. Let's go .:.:."
66 setup-config: dist/setup-config setup-config-hook $(BUILDINFO_FILE)
70 dist/setup-config: $(CABAL_FILE) Setup $(AUTOCONF_FILE)
71 ./Setup configure $(CONFIGURE_ARGS)
73 $(AUTOCONF_FILE): $(AUTOCONF_AC_FILE)
76 $(BUILDINFO_FILE): $(BUILDINFO_IN_FILE) configure
77 ./Setup configure $(CONFIGURE_ARGS)
83 rm -f dist/setup-config
87 $(RM_RF) dist Setup *.o *.hi .setup-config *.buildinfo *.tix .hpc
88 $(FIND) . -name '*~' -exec rm -f {} \;
93 ./Setup haddock $(HADDOCK_OPTS)
96 $(SUDO) ./Setup install
104 if ls *.tix >/dev/null 2>&1; then \
105 $(HPC) sum --output="merged.tix" --union --exclude=Main *.tix; \
106 $(HPC) markup --destdir="dist/hpc" --fun-entry-count "merged.tix"; \
109 # -- Find FIXME Tags ----------------------------------------------------------
112 \( -name 'dist' -or -name '.git' -or -name '_darcs' \) -prune \
114 \( -name '*.c' -or -name '*.h' -or \
115 -name '*.hs' -or -name '*.lhs' -or \
116 -name '*.hsc' -or -name '*.cabal' \) \
117 -exec egrep 'FIXME|THINKME|TODO' {} \+ \
118 || echo 'No FIXME, THINKME, nor TODO found.'
120 # -- HLint --------------------------------------------------------------------
121 HLINT_TARGETS ?= $$(find -E . -type d -name dist -prune -o -regex '.*\.(hsc?|lhs)' -print)
123 $(HLINT) $(HLINT_TARGETS) $(HLINT_OPTS)
125 # -- Ditz the Distributed Issue Tracker ---------------------------------------
126 ifeq (,$(wildcard .ditz-config))
130 $(DITZ) html dist/ditz
134 $(DITZ) releases | awk '{print $$1}' | sort --reverse | while read i; do \
135 $(DITZ) changelog $$i >> $@; \
140 # -- Pushing to remote hosts --------------------------------------------------
141 push: push-repo push-ditz push-doc
144 if [ -d "_darcs" ]; then \
146 elif [ -d ".git" ]; then \
147 git push --all && git push --tags; \
151 if [ -d "dist/ditz" ]; then \
154 www@nem.cielonegro.org:static.cielonegro.org/htdocs/ditz/$(PKG_NAME); \
158 if [ -d "dist/doc" ]; then \
160 dist/doc/html/$(PKG_NAME)/ \
161 www@nem.cielonegro.org:static.cielonegro.org/htdocs/doc/$(PKG_NAME); \
164 # -- Phony Targets ------------------------------------------------------------
165 .PHONY: build build-hook setup-config setup-config-hook run clean clean-hook \
166 install doc sdist test lint push push-repo push-ditz push-doc \