bindist fixes
[ghc-hetmet.git] / ghc / Makefile
1
2 TOP=..
3 include $(TOP)/mk/boilerplate.mk
4 include $(TOP)/mk/cabal-flags.mk
5
6 ifeq "$(stage)" ""
7 stage=1
8 endif
9
10 ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
11 INSTALL_FLAGS =
12 else
13 INSTALL_FLAGS = --enable-shell-wrappers
14 endif
15
16 # Don't strip the inplace versions, we might need to debug them
17 INPLACE_INSTALL_FLAGS += --disable-executable-stripping
18
19 boot:: boot.stage.$(stage)
20
21 all:: build.stage.$(stage)
22
23 rebuild ::
24         -$(CABAL) clean --distpref dist-stage$(stage)
25         $(RM) -rf stage$(stage)-inplace
26         $(MAKE) boot all
27
28 stage1 ::
29         $(MAKE) stage=1
30
31 stage2 ::
32         $(MAKE) stage=2
33
34 stage3 ::
35         $(MAKE) stage=3
36
37 clean distclean::
38         -$(CABAL) clean --distpref dist-stage1
39         -$(CABAL) clean --distpref dist-stage2
40         -$(CABAL) clean --distpref dist-stage3
41         $(RM) -rf stage1-inplace
42         $(RM) -rf stage2-inplace
43         $(RM) -rf stage3-inplace
44
45 # XXX This should be defined somewhere more central
46 INPLACE_DATA_DIR = $(FPTOOLS_TOP_ABS)/inplace-datadir
47
48 CONFIGURE_FLAGS_STAGE1 += --flags=-ghci
49
50 ifeq "$(GhcWithInterpreter)" "YES"
51 CONFIGURE_FLAGS_STAGE2 += --flags=ghci
52 else
53 CONFIGURE_FLAGS_STAGE2 += --flags=-ghci
54 endif
55
56 ifeq "$(GhcProfiled)" "YES"
57 CONFIGURE_FLAGS_STAGE2 += --enable-executable-profiling
58 endif
59 ifeq "$(GhcDebugged)" "YES"
60 CONFIGURE_FLAGS_STAGE2 += --ghc-option=-debug
61 endif
62 ifeq "$(GhcThreaded)" "YES"
63 # Use threaded RTS with GHCi, so threads don't get blocked at the prompt.
64 CONFIGURE_FLAGS_STAGE2 += --ghc-option=-threaded
65 endif
66
67 ifeq "$(BuildSharedLibs)" "YES"
68 CONFIGURE_FLAGS_STAGE2 += --ghc-option=-dynamic
69 endif
70
71 CONFIGURE_FLAGS_STAGE3 = $(CONFIGURE_FLAGS_STAGE2)
72
73 CONFIGURE_FLAGS_STAGE1 += $(USE_BOOT_CONFIGURE_FLAGS)
74 CONFIGURE_FLAGS_STAGE2 += $(USE_STAGE1_CONFIGURE_FLAGS)
75 CONFIGURE_FLAGS_STAGE3 += $(USE_STAGE2_CONFIGURE_FLAGS)
76
77 # Allow EXTRA_HC_OPTS to be used from the command line to add options 
78 # when building (e.g. -v)
79 BUILD_FLAGS=$(patsubst %, --ghc-option=%, $(EXTRA_HC_OPTS))
80
81 # XXX In stage2+ we should really use the inplace ghc-pkg
82 # It works because installPackage doesn't actually use ghc-pkg, as there's
83 # no library to register
84
85 ifeq "$(stage)" "1"
86 # GHC 6.9+ can handle cross-package recompilation checking, but
87 # we don't rely on the bootstrapping compiler being able to do this.
88 TOUCH_MAIN = $(RM) dist-stage1/build/ghc/ghc-tmp/Main.o
89 endif
90
91 boot.stage.%:
92         $(CABAL) configure --distpref dist-stage$*         \
93                            $(INSTALL_DIRS_CONFIGURE_FLAGS) \
94                            $(CONFIGURE_FLAGS_STAGE$*)      \
95                            $(COMMON_CONFIGURE_FLAGS)       \
96                            --libsubdir=.                   \
97                            --datadir='$$libdir'            \
98                            --datasubdir=.
99
100 build.stage.%:
101         $(TOUCH_MAIN)
102         $(CABAL) build     --distpref dist-stage$* $(BUILD_FLAGS)
103         $(INSTALL_PACKAGE) install '$(GHC_PKG_PROG)' 'XXX/package.conf' "" \
104                            $(FPTOOLS_TOP_ABS)/ghc/stage$*-inplace          \
105                            $(FPTOOLS_TOP_ABS)/ghc/stage$*-inplace          \
106                            '$$prefix'                                      \
107                            '$(INPLACE_DATA_DIR)'                           \
108                            '$$prefix/libexec'                              \
109                            '$$prefix/dynlib'                               \
110                            '$(INPLACE_DATA_DIR)'                           \
111                            '$$prefix/doc'                                  \
112                            '$$prefix/html'                                 \
113                            '$$prefix/haddock'                              \
114                            --distpref dist-stage$*                         \
115                            $(INPLACE_INSTALL_FLAGS)                        \
116                            $(INSTALL_FLAGS)
117
118 # XXX For now we always install the stage 2 compiler
119 install:
120         $(INSTALL_PACKAGE) install UNUSED UNUSED '$(DESTDIR)' '$(prefix)' \
121                            '$(prefix)' '$(bindir)' '$(libdir)'            \
122                        '$(libexecdir)' '$(dynlibdir)' '$(datadir)'    \
123                        '$(docdir)' '$(htmldir)' '$(haddockdir)'       \
124                            --distpref dist-stage2                         \
125                            $(INSTALL_FLAGS)
126
127 include $(TOP)/mk/bindist.mk
128 EXE_DIST_DIR = dist-stage$(stage)
129