]> gitweb @ CieloNegro.org - Lucu.git/blob - cabal-package.mk
Fixed build failure on recent GHC and other libraries
[Lucu.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
25 ifeq ($(shell ls configure.ac 2>/dev/null),configure.ac)
26   AUTOCONF_AC_FILE := configure.ac
27   AUTOCONF_FILE    := configure
28 else
29   ifeq ($(shell ls configure.in 2>/dev/null),configure.in)
30     AUTOCONF_AC_FILE := configure.in
31     AUTOCONF_FILE    := configure
32   else
33     AUTOCONF_AC_FILE :=
34     AUTOCONF_FILE    :=
35   endif
36 endif
37
38 BUILDINFO_IN_FILE := $(wildcard *.buildinfo.in)
39 BUILDINFO_FILE    := $(BUILDINFO_IN_FILE:.in=)
40
41 all: build
42
43 build: setup-config build-hook
44         ./Setup build
45         $(RM_RF) *.tix
46
47 build-hook:
48
49 ifeq ($(RUN_COMMAND),)
50 run:
51         @echo "cabal-package.mk: No command to run."
52         @echo "cabal-package.mk: If you want to run something, define RUN_COMMAND variable."
53 else
54 run: build
55         @echo ".:.:. Let's go .:.:."
56         $(RUN_COMMAND)
57 endif
58
59 setup-config: dist/setup-config setup-config-hook $(BUILDINFO_FILE)
60
61 setup-config-hook:
62
63 dist/setup-config: $(CABAL_FILE) Setup $(AUTOCONF_FILE)
64         ./Setup configure $(CONFIGURE_ARGS)
65
66 $(AUTOCONF_FILE): $(AUTOCONF_AC_FILE)
67         $(AUTOCONF)
68
69 $(BUILDINFO_FILE): $(BUILDINFO_IN_FILE) configure
70         ./Setup configure $(CONFIGURE_ARGS)
71
72 Setup: $(SETUP_FILE)
73         $(GHC) --make Setup
74
75 clean: clean-hook
76         $(RM_RF) dist Setup *.o *.hi .setup-config *.buildinfo *.tix .hpc
77         $(FIND) . -name '*~' -exec rm -f {} \;
78
79 clean-hook:
80
81 doc: setup-config
82         ./Setup haddock
83
84 install: build
85         $(SUDO) ./Setup install
86
87 sdist: setup-config
88         ./Setup sdist
89
90 test: build
91         $(RM_RF) dist/test
92         ./Setup test
93         if ls *.tix >/dev/null 2>&1; then \
94                 $(HPC) sum --output="merged.tix" --union --exclude=Main *.tix; \
95                 $(HPC) markup --destdir="dist/hpc" --fun-entry-count "merged.tix"; \
96         fi
97
98 ditz:
99         $(DITZ) html dist/ditz
100
101 fixme:
102         @$(FIND) . \
103                 \( -name 'dist' -or -name '.git' -or -name '_darcs' \) -prune \
104                 -or \
105                 \( -name '*.c'   -or -name '*.h'   -or \
106                    -name '*.hs'  -or -name '*.lhs' -or \
107                    -name '*.hsc' -or -name '*.cabal' \) \
108                 -exec egrep -i '(fixme|thinkme)' {} \+ \
109                 || echo 'No FIXME or THINKME found.'
110
111 lint:
112         $(HLINT) . --report
113 #       $(HLINT) . --report \
114 #               --ignore="Use string literal" \
115 #               --ignore="Use concatMap"
116
117 .PHONY: build build-hook setup-config setup-config-hook run clean clean-hook install doc sdist test lint