Manually control more of the Cabal flags for the compiler and ghc packages
[ghc-hetmet.git] / ghc / ghc.mk
1 # -----------------------------------------------------------------------------
2 #
3 # (c) 2009 The University of Glasgow
4 #
5 # This file is part of the GHC build system.
6 #
7 # To understand how the build system works and how to modify it, see
8 #      http://hackage.haskell.org/trac/ghc/wiki/Building/Architecture
9 #      http://hackage.haskell.org/trac/ghc/wiki/Building/Modifying
10 #
11 # -----------------------------------------------------------------------------
12
13 # ToDo
14 ghc_USES_CABAL = YES
15 ghc_PACKAGE = ghc-bin
16
17 ghc_stage1_CONFIGURE_OPTS += --flags=stage1
18 ghc_stage2_CONFIGURE_OPTS += --flags=stage2
19 ghc_stage3_CONFIGURE_OPTS += --flags=stage3
20
21 ifeq "$(GhcWithInterpreter)" "YES"
22 ghc_stage2_CONFIGURE_OPTS += --flags=ghci
23 endif
24
25 ghc_stage1_MORE_HC_OPTS = $(GhcStage1HcOpts)
26 ghc_stage2_MORE_HC_OPTS = $(GhcStage2HcOpts)
27 ghc_stage3_MORE_HC_OPTS = $(GhcStage3HcOpts)
28
29 ghc_stage2_CC_OPTS = -Iincludes
30 ghc_stage3_CC_OPTS = -Iincludes
31
32 ghc_stage1_C_FILES_NODEPS = ghc/hschooks.c
33
34 ghc_stage2_MKDEPENDC_OPTS = -DMAKING_GHC_BUILD_SYSTEM_DEPENDENCIES
35 ghc_stage3_MKDEPENDC_OPTS = -DMAKING_GHC_BUILD_SYSTEM_DEPENDENCIES
36
37 ifeq "$(GhcWithInterpreter)" "YES"
38 ghc_stage2_MORE_HC_OPTS += -DGHCI
39 ghc_stage3_MORE_HC_OPTS += -DGHCI
40 endif
41
42 ifeq "$(GhcDebugged)" "YES"
43 ghc_stage1_MORE_HC_OPTS += -debug
44 ghc_stage2_MORE_HC_OPTS += -debug
45 ghc_stage3_MORE_HC_OPTS += -debug
46 endif
47
48 ifeq "$(GhcDynamic)" "YES"
49 ghc_stage2_MORE_HC_OPTS += -dynamic
50 ghc_stage3_MORE_HC_OPTS += -dynamic
51 endif
52
53 ifeq "$(GhcThreaded)" "YES"
54 # Use threaded RTS with GHCi, so threads don't get blocked at the prompt.
55 ghc_stage2_MORE_HC_OPTS += -threaded
56 ghc_stage3_MORE_HC_OPTS += -threaded
57 endif
58
59 ifeq "$(GhcProfiled)" "YES"
60 ghc_stage2_MORE_HC_OPTS += -prof
61 endif
62
63 ghc_stage1_PROG = ghc-stage1$(exeext)
64 ghc_stage2_PROG = ghc-stage2$(exeext)
65 ghc_stage3_PROG = ghc-stage3$(exeext)
66
67 ghc_stage1_SHELL_WRAPPER = YES
68 ghc_stage2_SHELL_WRAPPER = YES
69 ghc_stage3_SHELL_WRAPPER = YES
70 ghc_stage1_SHELL_WRAPPER_NAME = ghc/ghc.wrapper
71 ghc_stage2_SHELL_WRAPPER_NAME = ghc/ghc.wrapper
72 ghc_stage3_SHELL_WRAPPER_NAME = ghc/ghc.wrapper
73
74 ghc_stage$(INSTALL_GHC_STAGE)_INSTALL_SHELL_WRAPPER = YES
75 ghc_stage$(INSTALL_GHC_STAGE)_INSTALL_SHELL_WRAPPER_NAME = ghc-$(ProjectVersion)
76
77 # We override the program name to be ghc, rather than ghc-stage2.
78 # This means the right program name is used in error messages etc.
79 define ghc_stage$(INSTALL_GHC_STAGE)_INSTALL_SHELL_WRAPPER_EXTRA
80 echo 'executablename="$$exedir/ghc"' >> "$(WRAPPER)"
81 endef
82
83 # if stage is set to something other than "1" or "", disable stage 1
84 ifneq "$(filter-out 1,$(stage))" ""
85 ghc_stage1_NOT_NEEDED = YES
86 endif
87 # if stage is set to something other than "2" or "", disable stage 2
88 ifneq "$(filter-out 2,$(stage))" ""
89 ghc_stage2_NOT_NEEDED = YES
90 endif
91 # stage 3 has to be requested explicitly with stage=3
92 ifneq "$(stage)" "3"
93 ghc_stage3_NOT_NEEDED = YES
94 endif
95 $(eval $(call build-prog,ghc,stage1,0))
96 $(eval $(call build-prog,ghc,stage2,1))
97 $(eval $(call build-prog,ghc,stage3,2))
98
99 ifneq "$(BINDIST)" "YES"
100
101 ifeq "$(GhcProfiled)" "YES"
102 ghc/stage2/build/tmp/$(ghc_stage2_PROG) : $(compiler_stage2_p_LIB)
103 ghc/stage2/build/tmp/$(ghc_stage2_PROG) : $(foreach lib,$(PACKAGES),$(libraries/$(lib)_dist-install_p_LIB))
104 endif
105
106 # Modules here import HsVersions.h, so we need ghc_boot_platform.h
107 $(ghc_stage1_depfile_haskell) : compiler/stage1/$(PLATFORM_H)
108 $(ghc_stage2_depfile_haskell) : compiler/stage2/$(PLATFORM_H)
109 $(ghc_stage3_depfile_haskell) : compiler/stage3/$(PLATFORM_H)
110
111 all_ghc_stage1 : $(GHC_STAGE1)
112 all_ghc_stage2 : $(GHC_STAGE2)
113 all_ghc_stage3 : $(GHC_STAGE3)
114
115 $(INPLACE_LIB)/extra-gcc-opts : extra-gcc-opts
116         "$(CP)" $< $@
117
118 # The GHC programs need to depend on all the helper programs they might call
119 ifeq "$(GhcUnregisterised)" "NO"
120 $(GHC_STAGE1) : $(MANGLER) $(SPLIT)
121 $(GHC_STAGE2) : $(MANGLER) $(SPLIT)
122 $(GHC_STAGE3) : $(MANGLER) $(SPLIT)
123 endif
124
125 $(GHC_STAGE1) : $(INPLACE_LIB)/extra-gcc-opts
126 $(GHC_STAGE2) : $(INPLACE_LIB)/extra-gcc-opts
127 $(GHC_STAGE3) : $(INPLACE_LIB)/extra-gcc-opts
128
129 ifeq "$(Windows)" "YES"
130 $(GHC_STAGE1) : $(TOUCHY)
131 $(GHC_STAGE2) : $(TOUCHY)
132 $(GHC_STAGE3) : $(TOUCHY)
133 endif
134
135 ifeq "$(BootingFromHc)" "YES"
136 $(GHC_STAGE2) : $(ALL_STAGE1_LIBS)
137 ghc_stage2_OTHER_OBJS += $(compiler_stage2_v_LIB) $(ALL_STAGE1_LIBS) $(ALL_STAGE1_LIBS) $(ALL_STAGE1_LIBS) $(ALL_RTS_LIBS) $(libffi_STATIC_LIB)
138 endif
139
140 endif
141
142 INSTALL_LIBS += extra-gcc-opts
143
144 ifeq "$(Windows)" "NO"
145 install: install_ghc_link
146 .PNONY: install_ghc_link
147 install_ghc_link: 
148         "$(RM)" $(RM_OPTS) "$(DESTDIR)$(bindir)/ghc"
149         $(LN_S) ghc-$(ProjectVersion) "$(DESTDIR)$(bindir)/ghc"
150 else
151 # On Windows we install the main binary as $(bindir)/ghc.exe
152 # To get ghc-<version>.exe we have a little C program in driver/ghc
153 install: install_ghc_post
154 .PHONY: install_ghc_post
155 install_ghc_post: install_bins
156         "$(RM)" $(RM_OPTS) $(DESTDIR)$(bindir)/ghc.exe
157         "$(MV)" -f $(DESTDIR)$(bindir)/ghc-stage$(INSTALL_GHC_STAGE).exe $(DESTDIR)$(bindir)/ghc.exe
158 endif
159