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 # -----------------------------------------------------------------------------
15 # ghc_PACKAGE = ghc-bin
17 ghc_stage1_HC_OPTS = $(GhcStage1HcOpts)
18 ghc_stage2_HC_OPTS = $(GhcStage2HcOpts)
19 ghc_stage3_HC_OPTS = $(GhcStage3HcOpts)
21 ifeq "$(GhcWithInterpreter)" "YES"
22 ghc_stage2_HC_OPTS += -DGHCI
23 ghc_stage3_HC_OPTS += -DGHCI
26 ifeq "$(GhcDebugged)" "YES"
30 ifeq "$(GhcThreaded)" "YES"
31 # Use threaded RTS with GHCi, so threads don't get blocked at the prompt.
32 ghc_HC_OPTS += -threaded
35 ifeq "$(BuildSharedLibs)" "YES"
36 ghc_HC_OPTS += -dynamic
40 # ifeq "$(GhcProfiled)" "YES"
42 ghc_stage1_MODULES = Main
44 ghc_stage2_MODULES = $(ghc_stage1_MODULES)
45 ghc_stage3_MODULES = $(ghc_stage1_MODULES)
47 ghc_stage1_PROG = ghc-stage1$(exeext)
48 ghc_stage2_PROG = ghc-stage2$(exeext)
49 ghc_stage3_PROG = ghc-stage3$(exeext)
51 # ToDo: perhaps use ghc-cabal to configure ghc-bin
52 ghc_stage1_USE_BOOT_LIBS = YES
53 ghc_stage1_HC_OPTS += -package $(compiler_PACKAGE)-$(compiler_stage1_VERSION)
54 ghc_stage2_HC_OPTS += -package $(compiler_PACKAGE)-$(compiler_stage2_VERSION)
55 ghc_stage3_HC_OPTS += -package $(compiler_PACKAGE)-$(compiler_stage3_VERSION)
57 ghc_stage1_HC_OPTS += -XCPP -XPatternGuards
58 ghc_stage2_HC_OPTS += -XCPP -XPatternGuards
59 ghc_stage3_HC_OPTS += -XCPP -XPatternGuards
61 # In stage1 we might not benefit from cross-package dependencies and
62 # recompilation checking. We must force recompilation here, otherwise
63 # Main.o won't necessarily be rebuilt when the ghc package has changed:
64 ghc_stage1_HC_OPTS += -fforce-recomp
66 # Further dependencies we need only in stage 1, due to no
67 # cross-package dependencies or recompilation checking.
68 ghc/stage1/build/Main.o : $(compiler_stage1_v_LIB)
70 ghc_stage1_SHELL_WRAPPER = YES
71 ghc_stage2_SHELL_WRAPPER = YES
72 ghc_stage3_SHELL_WRAPPER = YES
73 ghc_stage1_SHELL_WRAPPER_NAME = ghc/ghc.wrapper
74 ghc_stage2_SHELL_WRAPPER_NAME = ghc/ghc.wrapper
75 ghc_stage3_SHELL_WRAPPER_NAME = ghc/ghc.wrapper
77 ghc_stage$(INSTALL_GHC_STAGE)_INSTALL_SHELL_WRAPPER = YES
78 ghc_stage$(INSTALL_GHC_STAGE)_INSTALL_SHELL_WRAPPER_NAME = ghc-$(ProjectVersion)
80 # stage 1 is enabled unless $(stage) is set to something other than 1
81 ifeq "$(filter-out 1,$(stage))" ""
82 $(eval $(call build-prog,ghc,stage1,0))
85 # stage 2 is enabled unless $(stage) is set to something other than 2
86 ifeq "$(filter-out 2,$(stage))" ""
87 $(eval $(call build-prog,ghc,stage2,1))
90 # stage 3 has to be requested explicitly with stage=3
92 $(eval $(call build-prog,ghc,stage3,2))
95 ifneq "$(BINDIST)" "YES"
97 # ToDo: should we add these in the build-prog macro?
98 ghc/stage1/build/tmp/$(ghc_stage1_PROG) : $(compiler_stage1_v_LIB)
99 ghc/stage2/build/tmp/$(ghc_stage2_PROG) : $(compiler_stage2_v_LIB)
100 ghc/stage3/build/tmp/$(ghc_stage3_PROG) : $(compiler_stage3_v_LIB)
102 all_ghc_stage1 : $(GHC_STAGE1)
103 all_ghc_stage2 : $(GHC_STAGE2)
104 all_ghc_stage3 : $(GHC_STAGE3)
106 $(INPLACE_LIB)/extra-gcc-opts : extra-gcc-opts
109 # The GHC programs need to depend on all the helper programs they might call
110 $(GHC_STAGE1) : $(INPLACE_LIB)/extra-gcc-opts $(MANGLER) $(SPLIT)
111 $(GHC_STAGE2) : $(INPLACE_LIB)/extra-gcc-opts $(MANGLER) $(SPLIT)
112 $(GHC_STAGE3) : $(INPLACE_LIB)/extra-gcc-opts $(MANGLER) $(SPLIT)
114 ifeq "$(Windows)" "YES"
115 $(GHC_STAGE1) : $(TOUCHY) $(INPLACE)/stamp-mingw $(INPLACE_LIB)/perl.exe
116 $(GHC_STAGE2) : $(TOUCHY) $(INPLACE)/stamp-mingw $(INPLACE_LIB)/perl.exe
117 $(GHC_STAGE3) : $(TOUCHY) $(INPLACE)/stamp-mingw $(INPLACE_LIB)/perl.exe
122 INSTALL_LIBS += extra-gcc-opts
124 ifeq "$(Windows)" "NO"
125 install: install_ghc_link
126 .PNONY: install_ghc_link
128 $(RM) -f $(DESTDIR)$(bindir)/ghc
129 $(LN_S) ghc-$(ProjectVersion) $(DESTDIR)$(bindir)/ghc
131 # On Windows we install the main binary as $(bindir)/ghc.exe
132 # To get ghc-<version>.exe we have a little C program in driver/ghc
133 install: install_ghc_post
134 .PHONY: install_ghc_post
135 install_ghc_post: install_bins
136 $(RM) -f $(DESTDIR)$(bindir)/ghc.exe
137 $(MV) -f $(DESTDIR)$(bindir)/ghc-stage$(INSTALL_GHC_STAGE).exe $(DESTDIR)$(bindir)/ghc.exe