don't strip the inplace GHC executables (for debugging)
[ghc.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 boot.stage.%:
86 $(CABAL) configure --distpref dist-stage$* \
87 $(INSTALL_DIRS_CONFIGURE_FLAGS) \
88 $(CONFIGURE_FLAGS_STAGE$*) \
89 $(COMMON_CONFIGURE_FLAGS) \
90 --libsubdir=. \
91 --datadir='$$libdir' \
92 --datasubdir=.
93
94 build.stage.%:
95 $(CABAL) build --distpref dist-stage$* $(BUILD_FLAGS)
96 $(INSTALL_PACKAGE) install '$(GHC_PKG_PROG)' 'XXX/package.conf' "" \
97 $(FPTOOLS_TOP_ABS)/ghc/stage$*-inplace \
98 $(FPTOOLS_TOP_ABS)/ghc/stage$*-inplace \
99 '$$prefix' \
100 '$(INPLACE_DATA_DIR)' \
101 '$$prefix/libexec' \
102 '$$prefix/dynlib' \
103 '$(INPLACE_DATA_DIR)' \
104 '$$prefix/doc' \
105 '$$prefix/html' \
106 '$$prefix/haddock' \
107 --distpref dist-stage$* \
108 $(INPLACE_INSTALL_FLAGS) \
109 $(INSTALL_FLAGS)
110
111 # XXX For now we always install the stage 2 compiler
112 install:
113 $(INSTALL_PACKAGE) install UNUSED UNUSED '$(DESTDIR)' '$(prefix)' \
114 '$(prefix)' '$(bindir)' '$(libdir)' \
115 '$(libexecdir)' '$(dynlibdir)' '$(libdir)' \
116 '$(docdir)' '$(htmldir)' '$(haddockdir)' \
117 --distpref dist-stage2 \
118 $(INSTALL_FLAGS)
119
120 # XXX fix:
121 #binary-dist:
122 # $(INSTALL_DIR) $(BIN_DIST_DIR)/utils/hsc2hs
123 # $(INSTALL_DATA) Makefile $(BIN_DIST_DIR)/utils/hsc2hs/
124 # $(INSTALL_DATA) hsc2hs.sh $(BIN_DIST_DIR)/utils/hsc2hs/
125 # $(INSTALL_DATA) $(INSTALL_DATAS) $(BIN_DIST_DIR)/utils/hsc2hs/
126 # $(INSTALL_PROGRAM) $(HS_PROG) $(BIN_DIST_DIR)/utils/hsc2hs/
127