]> gitweb @ CieloNegro.org - time-w3c.git/blob - cabal-package.mk
Fix breakage on newer GHC and other libraries.
[time-w3c.git] / cabal-package.mk
1 # -*- makefile-gmake -*-
2 #
3 # Variables:
4 #
5 #   CONFIGURE_ARGS :: arguments to be passed to ./Setup configure
6 #     default: --disable-optimization
7 #
8 #   RUN_COMMAND :: command to be run for "make run"
9 #
10
11 GHC      ?= ghc
12 FIND     ?= find
13 RM_RF    ?= rm -rf
14 SUDO     ?= sudo
15 AUTOCONF ?= autoconf
16 HLINT    ?= hlint
17 HPC      ?= hpc
18 DITZ     ?= ditz
19
20 CONFIGURE_ARGS ?= --disable-optimization
21
22 SETUP_FILE := $(wildcard Setup.*hs)
23 CABAL_FILE := $(wildcard *.cabal)
24 PKG_NAME   := $(CABAL_FILE:.cabal=)
25
26 ifeq ($(shell ls configure.ac 2>/dev/null),configure.ac)
27   AUTOCONF_AC_FILE := configure.ac
28   AUTOCONF_FILE    := configure
29 else
30   ifeq ($(shell ls configure.in 2>/dev/null),configure.in)
31     AUTOCONF_AC_FILE := configure.in
32     AUTOCONF_FILE    := configure
33   else
34     AUTOCONF_AC_FILE :=
35     AUTOCONF_FILE    :=
36   endif
37 endif
38
39 BUILDINFO_IN_FILE := $(wildcard *.buildinfo.in)
40 BUILDINFO_FILE    := $(BUILDINFO_IN_FILE:.in=)
41
42 all: build
43
44 build: setup-config build-hook
45         ./Setup build
46         $(RM_RF) *.tix
47
48 build-hook:
49
50 ifeq ($(RUN_COMMAND),)
51 run:
52         @echo "cabal-package.mk: No command to run."
53         @echo "cabal-package.mk: If you want to run something, define RUN_COMMAND variable."
54 else
55 run: build
56         @echo ".:.:. Let's go .:.:."
57         $(RUN_COMMAND)
58 endif
59
60 setup-config: dist/setup-config setup-config-hook $(BUILDINFO_FILE)
61
62 setup-config-hook:
63
64 dist/setup-config: $(CABAL_FILE) Setup $(AUTOCONF_FILE)
65         ./Setup configure $(CONFIGURE_ARGS)
66
67 $(AUTOCONF_FILE): $(AUTOCONF_AC_FILE)
68         $(AUTOCONF)
69
70 $(BUILDINFO_FILE): $(BUILDINFO_IN_FILE) configure
71         ./Setup configure $(CONFIGURE_ARGS)
72
73 Setup: $(SETUP_FILE)
74         $(GHC) --make Setup
75
76 clean: clean-hook
77         $(RM_RF) dist Setup *.o *.hi .setup-config *.buildinfo *.tix .hpc
78         $(FIND) . -name '*~' -exec rm -f {} \;
79
80 clean-hook:
81
82 doc: setup-config
83         ./Setup haddock
84
85 install: build
86         $(SUDO) ./Setup install
87
88 sdist: setup-config
89         ./Setup sdist
90
91 test: build
92         $(RM_RF) dist/test
93         ./Setup test
94         if ls *.tix >/dev/null 2>&1; then \
95                 $(HPC) sum --output="merged.tix" --union --exclude=Main *.tix; \
96                 $(HPC) markup --destdir="dist/hpc" --fun-entry-count "merged.tix"; \
97         fi
98
99 ditz:
100         $(DITZ) html dist/ditz
101
102 fixme:
103         @$(FIND) . \
104                 \( -name 'dist' -or -name '.git' -or -name '_darcs' \) -prune \
105                 -or \
106                 \( -name '*.c'   -or -name '*.h'   -or \
107                    -name '*.hs'  -or -name '*.lhs' -or \
108                    -name '*.hsc' -or -name '*.cabal' \) \
109                 -exec egrep -i '(fixme|thinkme)' {} \+ \
110                 || echo 'No FIXME or THINKME found.'
111
112 lint:
113         $(HLINT) . --report
114 #       $(HLINT) . --report \
115 #               --ignore="Use string literal" \
116 #               --ignore="Use concatMap"
117
118 push: doc ditz
119         if [ -d "_darcs" ]; then \
120                 darcs push; \
121         elif [ -d ".git" ]; then \
122                 git push --all && git push --tags; \
123         fi
124         rsync -av --delete \
125                 dist/doc/html/$(PKG_NAME)/ \
126                 www@nem.cielonegro.org:static.cielonegro.org/htdocs/doc/$(PKG_NAME)
127         rsync -av --delete \
128                 dist/ditz/ \
129                 www@nem.cielonegro.org:static.cielonegro.org/htdocs/ditz/$(PKG_NAME)
130
131 .PHONY: build build-hook setup-config setup-config-hook run clean clean-hook install doc sdist test lint push