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