Some "install" and "clean" 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 boot:: boot.stage.$(stage)
17
18 all:: build.stage.$(stage)
19
20 stage1 ::
21         $(MAKE) stage=1
22
23 stage2 ::
24         $(MAKE) stage=2
25
26 stage3 ::
27         $(MAKE) stage=3
28
29 clean distclean::
30         -$(CABAL) clean --distpref dist-stage1
31         -$(CABAL) clean --distpref dist-stage2
32         $(RM) -rf stage1-inplace
33         $(RM) -rf stage2-inplace
34
35 # XXX This should be defined somewhere more central
36 INPLACE_DATA_DIR = $(FPTOOLS_TOP_ABS)/inplace-datadir
37
38 CONFIGURE_FLAGS_STAGE1 += --flags=-ghci
39
40 ifeq "$(GhcWithInterpreter)" "YES"
41 CONFIGURE_FLAGS_STAGE2 += --flags=ghci
42 else
43 CONFIGURE_FLAGS_STAGE2 += --flags=-ghci
44 endif
45
46 ifeq "$(GhcProfiled)" "YES"
47 CONFIGURE_FLAGS_STAGE2 += --enable-executable-profiling
48 endif
49 ifeq "$(GhcDebugged)" "YES"
50 CONFIGURE_FLAGS_STAGE2 += --ghc-option=-debug
51 endif
52 ifeq "$(GhcThreaded)" "YES"
53 # Use threaded RTS with GHCi, so threads don't get blocked at the prompt.
54 CONFIGURE_FLAGS_STAGE2 += --ghc-option=-threaded
55 endif
56
57 CONFIGURE_FLAGS_STAGE3 = $(CONFIGURE_FLAGS_STAGE2)
58
59 CONFIGURE_FLAGS_STAGE1 += $(USE_BOOT_CONFIGURE_FLAGS)
60 CONFIGURE_FLAGS_STAGE2 += $(USE_STAGE1_CONFIGURE_FLAGS)
61 CONFIGURE_FLAGS_STAGE3 += $(USE_STAGE2_CONFIGURE_FLAGS)
62
63 # XXX In stage2+ we should really use the inplace ghc-pkg
64 # It works because installPackage doesn't actually use ghc-pkg, as there's
65 # no library to register
66
67 boot.stage.%:
68         $(CABAL) configure --distpref dist-stage$*         \
69                            $(INSTALL_DIRS_CONFIGURE_FLAGS) \
70                            $(CONFIGURE_FLAGS_STAGE$*)      \
71                            $(COMMON_CONFIGURE_FLAGS)       \
72                            --libsubdir=.                   \
73                            --datadir='$$libdir'            \
74                            --datasubdir=.
75
76 build.stage.%:
77         $(CABAL) build     --distpref dist-stage$* $(BUILD_FLAGS)
78         $(INSTALL_PACKAGE) install '$(GHC_PKG_PROG)' 'XXX/package.conf' "" \
79                            $(FPTOOLS_TOP_ABS)/ghc/stage$*-inplace          \
80                            $(FPTOOLS_TOP_ABS)/ghc/stage$*-inplace          \
81                            '$$prefix/bin'                                  \
82                            '$(INPLACE_DATA_DIR)'                           \
83                            '$$prefix/libexec'                              \
84                            '$$prefix/dynlib'                               \
85                            '$(INPLACE_DATA_DIR)'                           \
86                            '$$prefix/doc'                                  \
87                            '$$prefix/html'                                 \
88                            '$$prefix/haddock'                              \
89                            --distpref dist-stage$*                         \
90                            $(INSTALL_FLAGS)
91
92 # XXX For now we always install the stage 2 compiler
93 install:
94         $(INSTALL_PACKAGE) install UNUSED UNUSED '$(DESTDIR)' '$(prefix)' \
95                            '$(prefix)' '$(bindir)' '$(libdir)'            \
96                        '$(libexecdir)' '$(dynlibdir)' '$(libdir)'     \
97                        '$(docdir)' '$(htmldir)' '$(haddockdir)'       \
98                            --distpref dist-stage2                         \
99                            $(INSTALL_FLAGS)
100
101 # XXX fix:
102 #binary-dist:
103 #       $(INSTALL_DIR)                      $(BIN_DIST_DIR)/utils/hsc2hs
104 #       $(INSTALL_DATA)    Makefile         $(BIN_DIST_DIR)/utils/hsc2hs/
105 #       $(INSTALL_DATA)    hsc2hs.sh        $(BIN_DIST_DIR)/utils/hsc2hs/
106 #       $(INSTALL_DATA)    $(INSTALL_DATAS) $(BIN_DIST_DIR)/utils/hsc2hs/
107 #       $(INSTALL_PROGRAM) $(HS_PROG)       $(BIN_DIST_DIR)/utils/hsc2hs/
108