Remove an old "ToDo" comment
[ghc.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 ghc_USES_CABAL = YES
14 ghc_PACKAGE = ghc-bin
15
16 ghc_stage1_CONFIGURE_OPTS += --flags=stage1
17 ghc_stage2_CONFIGURE_OPTS += --flags=stage2
18 ghc_stage3_CONFIGURE_OPTS += --flags=stage3
19
20 ifeq "$(GhcWithInterpreter)" "YES"
21 ghc_stage2_CONFIGURE_OPTS += --flags=ghci
22 ghc_stage3_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 "$(GhcDebugged)" "YES"
38 ghc_stage1_MORE_HC_OPTS += -debug
39 ghc_stage2_MORE_HC_OPTS += -debug
40 ghc_stage3_MORE_HC_OPTS += -debug
41 endif
42
43 ifeq "$(GhcDynamic)" "YES"
44 ghc_stage2_MORE_HC_OPTS += -dynamic
45 ghc_stage3_MORE_HC_OPTS += -dynamic
46 endif
47
48 ifeq "$(GhcThreaded)" "YES"
49 # Use threaded RTS with GHCi, so threads don't get blocked at the prompt.
50 ghc_stage2_MORE_HC_OPTS += -threaded
51 ghc_stage3_MORE_HC_OPTS += -threaded
52 endif
53
54 ifeq "$(GhcProfiled)" "YES"
55 ghc_stage2_MORE_HC_OPTS += -prof
56 endif
57
58 ghc_stage1_PROG = ghc-stage1$(exeext)
59 ghc_stage2_PROG = ghc-stage2$(exeext)
60 ghc_stage3_PROG = ghc-stage3$(exeext)
61
62 ghc_stage1_SHELL_WRAPPER = YES
63 ghc_stage2_SHELL_WRAPPER = YES
64 ghc_stage3_SHELL_WRAPPER = YES
65 ghc_stage1_SHELL_WRAPPER_NAME = ghc/ghc.wrapper
66 ghc_stage2_SHELL_WRAPPER_NAME = ghc/ghc.wrapper
67 ghc_stage3_SHELL_WRAPPER_NAME = ghc/ghc.wrapper
68
69 ghc_stage$(INSTALL_GHC_STAGE)_INSTALL_SHELL_WRAPPER = YES
70 ghc_stage$(INSTALL_GHC_STAGE)_INSTALL_SHELL_WRAPPER_NAME = ghc-$(ProjectVersion)
71
72 # We override the program name to be ghc, rather than ghc-stage2.
73 # This means the right program name is used in error messages etc.
74 define ghc_stage$(INSTALL_GHC_STAGE)_INSTALL_SHELL_WRAPPER_EXTRA
75 echo 'executablename="$$exedir/ghc"' >> "$(WRAPPER)"
76 endef
77
78 # if stage is set to something other than "1" or "", disable stage 1
79 ifneq "$(filter-out 1,$(stage))" ""
80 ghc_stage1_NOT_NEEDED = YES
81 endif
82 # if stage is set to something other than "2" or "", disable stage 2
83 ifneq "$(filter-out 2,$(stage))" ""
84 ghc_stage2_NOT_NEEDED = YES
85 endif
86 # stage 3 has to be requested explicitly with stage=3
87 ifneq "$(stage)" "3"
88 ghc_stage3_NOT_NEEDED = YES
89 endif
90 $(eval $(call build-prog,ghc,stage1,0))
91 $(eval $(call build-prog,ghc,stage2,1))
92 $(eval $(call build-prog,ghc,stage3,2))
93
94 ifneq "$(BINDIST)" "YES"
95
96 ghc/stage1/build/tmp/$(ghc_stage1_PROG) : $(BOOT_LIBS)
97 ifeq "$(GhcProfiled)" "YES"
98 ghc/stage2/build/tmp/$(ghc_stage2_PROG) : $(compiler_stage2_p_LIB)
99 ghc/stage2/build/tmp/$(ghc_stage2_PROG) : $(foreach lib,$(PACKAGES_STAGE1),$(libraries/$(lib)_dist-install_p_LIB))
100 endif
101
102 # Modules here import HsVersions.h, so we need ghc_boot_platform.h
103 $(ghc_stage1_depfile_haskell) : compiler/stage1/$(PLATFORM_H)
104 $(ghc_stage2_depfile_haskell) : compiler/stage2/$(PLATFORM_H)
105 $(ghc_stage3_depfile_haskell) : compiler/stage3/$(PLATFORM_H)
106
107 all_ghc_stage1 : $(GHC_STAGE1)
108 all_ghc_stage2 : $(GHC_STAGE2)
109 all_ghc_stage3 : $(GHC_STAGE3)
110
111 $(INPLACE_LIB)/settings : settings
112 "$(CP)" $< $@
113
114 # The GHC programs need to depend on all the helper programs they might call,
115 # and the settings files they use
116
117 $(GHC_STAGE1) : | $(UNLIT) $(INPLACE_LIB)/settings
118 $(GHC_STAGE2) : | $(UNLIT) $(INPLACE_LIB)/settings
119 $(GHC_STAGE3) : | $(UNLIT) $(INPLACE_LIB)/settings
120
121 ifeq "$(GhcUnregisterised)" "NO"
122 $(GHC_STAGE1) : | $(SPLIT)
123 $(GHC_STAGE2) : | $(SPLIT)
124 $(GHC_STAGE3) : | $(SPLIT)
125 endif
126
127 ifeq "$(Windows)" "YES"
128 $(GHC_STAGE1) : | $(TOUCHY)
129 $(GHC_STAGE2) : | $(TOUCHY)
130 $(GHC_STAGE3) : | $(TOUCHY)
131 endif
132
133 ifeq "$(BootingFromHc)" "YES"
134 $(GHC_STAGE2) : $(ALL_STAGE1_LIBS)
135 ghc_stage2_OTHER_OBJS += $(compiler_stage2_v_LIB) $(ALL_STAGE1_LIBS) $(ALL_STAGE1_LIBS) $(ALL_STAGE1_LIBS) $(ALL_RTS_LIBS) $(libffi_STATIC_LIB)
136 endif
137
138 endif
139
140 INSTALL_LIBS += settings
141
142 ifeq "$(Windows)" "NO"
143 install: install_ghc_link
144 .PNONY: install_ghc_link
145 install_ghc_link:
146 "$(RM)" $(RM_OPTS) "$(DESTDIR)$(bindir)/ghc"
147 $(LN_S) ghc-$(ProjectVersion) "$(DESTDIR)$(bindir)/ghc"
148 else
149 # On Windows we install the main binary as $(bindir)/ghc.exe
150 # To get ghc-<version>.exe we have a little C program in driver/ghc
151 install: install_ghc_post
152 .PHONY: install_ghc_post
153 install_ghc_post: install_bins
154 "$(RM)" $(RM_OPTS) $(DESTDIR)$(bindir)/ghc.exe
155 "$(MV)" -f $(DESTDIR)$(bindir)/ghc-stage$(INSTALL_GHC_STAGE).exe $(DESTDIR)$(bindir)/ghc.exe
156 endif
157