1 # -----------------------------------------------------------------------------
3 # (c) 2009 The University of Glasgow
5 # This file is part of the GHC build system.
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
11 # -----------------------------------------------------------------------------
17 ghc_stage1_MORE_HC_OPTS = $(GhcStage1HcOpts)
18 ghc_stage2_MORE_HC_OPTS = $(GhcStage2HcOpts)
19 ghc_stage3_MORE_HC_OPTS = $(GhcStage3HcOpts)
21 ghc_stage2_CC_OPTS = -Iincludes
22 ghc_stage3_CC_OPTS = -Iincludes
24 ghc_stage1_C_FILES_NODEPS = ghc/hschooks.c
26 ghc_stage2_MKDEPENDC_OPTS = -DMAKING_GHC_BUILD_SYSTEM_DEPENDENCIES
27 ghc_stage3_MKDEPENDC_OPTS = -DMAKING_GHC_BUILD_SYSTEM_DEPENDENCIES
29 ifeq "$(GhcWithInterpreter)" "YES"
30 ghc_stage2_MORE_HC_OPTS += -DGHCI
31 ghc_stage3_MORE_HC_OPTS += -DGHCI
34 ifeq "$(GhcDebugged)" "YES"
35 ghc_stage1_MORE_HC_OPTS += -debug
36 ghc_stage2_MORE_HC_OPTS += -debug
37 ghc_stage3_MORE_HC_OPTS += -debug
40 ifeq "$(GhcDynamic)" "YES"
41 ghc_stage2_MORE_HC_OPTS += -dynamic
42 ghc_stage3_MORE_HC_OPTS += -dynamic
45 ifeq "$(GhcThreaded)" "YES"
46 # Use threaded RTS with GHCi, so threads don't get blocked at the prompt.
47 ghc_stage2_MORE_HC_OPTS += -threaded
48 ghc_stage3_MORE_HC_OPTS += -threaded
51 ifeq "$(GhcProfiled)" "YES"
52 ghc_stage2_MORE_HC_OPTS += -prof
55 ghc_stage1_PROG = ghc-stage1$(exeext)
56 ghc_stage2_PROG = ghc-stage2$(exeext)
57 ghc_stage3_PROG = ghc-stage3$(exeext)
59 ghc_stage1_SHELL_WRAPPER = YES
60 ghc_stage2_SHELL_WRAPPER = YES
61 ghc_stage3_SHELL_WRAPPER = YES
62 ghc_stage1_SHELL_WRAPPER_NAME = ghc/ghc.wrapper
63 ghc_stage2_SHELL_WRAPPER_NAME = ghc/ghc.wrapper
64 ghc_stage3_SHELL_WRAPPER_NAME = ghc/ghc.wrapper
66 ghc_stage$(INSTALL_GHC_STAGE)_INSTALL_SHELL_WRAPPER = YES
67 ghc_stage$(INSTALL_GHC_STAGE)_INSTALL_SHELL_WRAPPER_NAME = ghc-$(ProjectVersion)
69 # We override the program name to be ghc, rather than ghc-stage2.
70 # This means the right program name is used in error messages etc.
71 define ghc_stage$(INSTALL_GHC_STAGE)_INSTALL_SHELL_WRAPPER_EXTRA
72 echo 'executablename="$$exedir/ghc"' >> "$(WRAPPER)"
75 # if stage is set to something other than "1" or "", disable stage 1
76 ifneq "$(filter-out 1,$(stage))" ""
77 ghc_stage1_NOT_NEEDED = YES
79 # if stage is set to something other than "2" or "", disable stage 2
80 ifneq "$(filter-out 2,$(stage))" ""
81 ghc_stage2_NOT_NEEDED = YES
83 # stage 3 has to be requested explicitly with stage=3
85 ghc_stage3_NOT_NEEDED = YES
87 $(eval $(call build-prog,ghc,stage1,0))
88 $(eval $(call build-prog,ghc,stage2,1))
89 $(eval $(call build-prog,ghc,stage3,2))
91 ifneq "$(BINDIST)" "YES"
93 ifeq "$(GhcProfiled)" "YES"
94 ghc/stage2/build/tmp/$(ghc_stage2_PROG) : $(compiler_stage2_p_LIB)
95 ghc/stage2/build/tmp/$(ghc_stage2_PROG) : $(foreach lib,$(PACKAGES),$(libraries/$(lib)_dist-install_p_LIB))
98 # Modules here import HsVersions.h, so we need ghc_boot_platform.h
99 $(ghc_stage1_depfile_haskell) : compiler/stage1/$(PLATFORM_H)
100 $(ghc_stage2_depfile_haskell) : compiler/stage2/$(PLATFORM_H)
101 $(ghc_stage3_depfile_haskell) : compiler/stage3/$(PLATFORM_H)
103 all_ghc_stage1 : $(GHC_STAGE1)
104 all_ghc_stage2 : $(GHC_STAGE2)
105 all_ghc_stage3 : $(GHC_STAGE3)
107 $(INPLACE_LIB)/extra-gcc-opts : extra-gcc-opts
110 # The GHC programs need to depend on all the helper programs they might call
111 ifeq "$(GhcUnregisterised)" "NO"
112 $(GHC_STAGE1) : $(MANGLER) $(SPLIT)
113 $(GHC_STAGE2) : $(MANGLER) $(SPLIT)
114 $(GHC_STAGE3) : $(MANGLER) $(SPLIT)
117 $(GHC_STAGE1) : $(INPLACE_LIB)/extra-gcc-opts
118 $(GHC_STAGE2) : $(INPLACE_LIB)/extra-gcc-opts
119 $(GHC_STAGE3) : $(INPLACE_LIB)/extra-gcc-opts
121 ifeq "$(Windows)" "YES"
122 $(GHC_STAGE1) : $(TOUCHY)
123 $(GHC_STAGE2) : $(TOUCHY)
124 $(GHC_STAGE3) : $(TOUCHY)
127 ifeq "$(BootingFromHc)" "YES"
128 $(GHC_STAGE2) : $(ALL_STAGE1_LIBS)
129 ghc_stage2_OTHER_OBJS += $(compiler_stage2_v_LIB) $(ALL_STAGE1_LIBS) $(ALL_STAGE1_LIBS) $(ALL_STAGE1_LIBS) $(ALL_RTS_LIBS) $(libffi_STATIC_LIB)
134 INSTALL_LIBS += extra-gcc-opts
136 ifeq "$(Windows)" "NO"
137 install: install_ghc_link
138 .PNONY: install_ghc_link
140 "$(RM)" $(RM_OPTS) "$(DESTDIR)$(bindir)/ghc"
141 $(LN_S) ghc-$(ProjectVersion) "$(DESTDIR)$(bindir)/ghc"
143 # On Windows we install the main binary as $(bindir)/ghc.exe
144 # To get ghc-<version>.exe we have a little C program in driver/ghc
145 install: install_ghc_post
146 .PHONY: install_ghc_post
147 install_ghc_post: install_bins
148 "$(RM)" $(RM_OPTS) $(DESTDIR)$(bindir)/ghc.exe
149 "$(MV)" -f $(DESTDIR)$(bindir)/ghc-stage$(INSTALL_GHC_STAGE).exe $(DESTDIR)$(bindir)/ghc.exe