| 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 | ifeq "$(compiler_stage1_VERSION_MUNGED)" "YES" |
|---|
| 26 | # If we munge the stage1 version, and we're using a devel snapshot for |
|---|
| 27 | # stage0, then stage1 may actually have an earlier version than stage0 |
|---|
| 28 | # (e.g. boot with ghc-7.5.20120316, building ghc-7.5). We therefore |
|---|
| 29 | # need to tell Cabal to use version 7.5 of the ghc package when building |
|---|
| 30 | # in ghc/stage1 |
|---|
| 31 | ghc_stage1_CONFIGURE_OPTS += --constraint "ghc == $(compiler_stage1_MUNGED_VERSION)" |
|---|
| 32 | endif |
|---|
| 33 | |
|---|
| 34 | ghc_stage1_MORE_HC_OPTS = $(GhcStage1HcOpts) |
|---|
| 35 | ghc_stage2_MORE_HC_OPTS = $(GhcStage2HcOpts) |
|---|
| 36 | ghc_stage3_MORE_HC_OPTS = $(GhcStage3HcOpts) |
|---|
| 37 | |
|---|
| 38 | # We need __GLASGOW_HASKELL__ in hschooks.c, so we have to build C |
|---|
| 39 | # sources with GHC: |
|---|
| 40 | ghc_stage1_UseGhcForCC = YES |
|---|
| 41 | ghc_stage2_UseGhcForCC = YES |
|---|
| 42 | ghc_stage3_UseGhcForCC = YES |
|---|
| 43 | |
|---|
| 44 | ghc_stage1_C_FILES_NODEPS = ghc/hschooks.c |
|---|
| 45 | |
|---|
| 46 | ghc_stage2_MKDEPENDC_OPTS = -DMAKING_GHC_BUILD_SYSTEM_DEPENDENCIES |
|---|
| 47 | ghc_stage3_MKDEPENDC_OPTS = -DMAKING_GHC_BUILD_SYSTEM_DEPENDENCIES |
|---|
| 48 | |
|---|
| 49 | ifeq "$(GhcDebugged)" "YES" |
|---|
| 50 | ghc_stage1_MORE_HC_OPTS += -debug |
|---|
| 51 | ghc_stage2_MORE_HC_OPTS += -debug |
|---|
| 52 | ghc_stage3_MORE_HC_OPTS += -debug |
|---|
| 53 | endif |
|---|
| 54 | |
|---|
| 55 | ifeq "$(GhcDynamic)" "YES" |
|---|
| 56 | ghc_stage2_MORE_HC_OPTS += -dynamic |
|---|
| 57 | ghc_stage3_MORE_HC_OPTS += -dynamic |
|---|
| 58 | endif |
|---|
| 59 | |
|---|
| 60 | ifeq "$(GhcThreaded)" "YES" |
|---|
| 61 | # Use threaded RTS with GHCi, so threads don't get blocked at the prompt. |
|---|
| 62 | ghc_stage2_MORE_HC_OPTS += -threaded |
|---|
| 63 | ghc_stage3_MORE_HC_OPTS += -threaded |
|---|
| 64 | endif |
|---|
| 65 | |
|---|
| 66 | ifeq "$(GhcProfiled)" "YES" |
|---|
| 67 | ghc_stage2_MORE_HC_OPTS += -prof |
|---|
| 68 | endif |
|---|
| 69 | |
|---|
| 70 | ghc_stage1_PROG = ghc-stage1$(exeext) |
|---|
| 71 | ghc_stage2_PROG = ghc-stage2$(exeext) |
|---|
| 72 | ghc_stage3_PROG = ghc-stage3$(exeext) |
|---|
| 73 | |
|---|
| 74 | ghc_stage1_SHELL_WRAPPER = YES |
|---|
| 75 | ghc_stage2_SHELL_WRAPPER = YES |
|---|
| 76 | ghc_stage3_SHELL_WRAPPER = YES |
|---|
| 77 | ghc_stage1_SHELL_WRAPPER_NAME = ghc/ghc.wrapper |
|---|
| 78 | ghc_stage2_SHELL_WRAPPER_NAME = ghc/ghc.wrapper |
|---|
| 79 | ghc_stage3_SHELL_WRAPPER_NAME = ghc/ghc.wrapper |
|---|
| 80 | |
|---|
| 81 | ghc_stage$(INSTALL_GHC_STAGE)_INSTALL_SHELL_WRAPPER = YES |
|---|
| 82 | ghc_stage$(INSTALL_GHC_STAGE)_INSTALL_SHELL_WRAPPER_NAME = ghc-$(ProjectVersion) |
|---|
| 83 | |
|---|
| 84 | # We override the program name to be ghc, rather than ghc-stage2. |
|---|
| 85 | # This means the right program name is used in error messages etc. |
|---|
| 86 | define ghc_stage$(INSTALL_GHC_STAGE)_INSTALL_SHELL_WRAPPER_EXTRA |
|---|
| 87 | echo 'executablename="$$exedir/ghc"' >> "$(WRAPPER)" |
|---|
| 88 | endef |
|---|
| 89 | |
|---|
| 90 | # if stage is set to something other than "1" or "", disable stage 1 |
|---|
| 91 | ifneq "$(filter-out 1,$(stage))" "" |
|---|
| 92 | ghc_stage1_NOT_NEEDED = YES |
|---|
| 93 | endif |
|---|
| 94 | # if stage is set to something other than "2" or "", disable stage 2 |
|---|
| 95 | ifneq "$(filter-out 2,$(stage))" "" |
|---|
| 96 | ghc_stage2_NOT_NEEDED = YES |
|---|
| 97 | endif |
|---|
| 98 | # When cross-compiling, the stage 1 compiler is our release compiler, so omit stage 2 |
|---|
| 99 | ifeq "$(BuildingCrossCompiler)" "YES" |
|---|
| 100 | ghc_stage2_NOT_NEEDED = YES |
|---|
| 101 | endif |
|---|
| 102 | # stage 3 has to be requested explicitly with stage=3 |
|---|
| 103 | ifneq "$(stage)" "3" |
|---|
| 104 | ghc_stage3_NOT_NEEDED = YES |
|---|
| 105 | endif |
|---|
| 106 | $(eval $(call build-prog,ghc,stage1,0)) |
|---|
| 107 | $(eval $(call build-prog,ghc,stage2,1)) |
|---|
| 108 | $(eval $(call build-prog,ghc,stage3,2)) |
|---|
| 109 | |
|---|
| 110 | ifneq "$(BINDIST)" "YES" |
|---|
| 111 | |
|---|
| 112 | ghc/stage1/build/tmp/$(ghc_stage1_PROG) : $(BOOT_LIBS) |
|---|
| 113 | ifeq "$(GhcProfiled)" "YES" |
|---|
| 114 | ghc/stage2/build/tmp/$(ghc_stage2_PROG) : $(compiler_stage2_p_LIB) |
|---|
| 115 | ghc/stage2/build/tmp/$(ghc_stage2_PROG) : $(foreach lib,$(PACKAGES_STAGE1),$(libraries/$(lib)_dist-install_p_LIB)) |
|---|
| 116 | endif |
|---|
| 117 | |
|---|
| 118 | # Modules here import HsVersions.h, so we need ghc_boot_platform.h |
|---|
| 119 | $(ghc_stage1_depfile_haskell) : compiler/stage1/$(PLATFORM_H) |
|---|
| 120 | $(ghc_stage2_depfile_haskell) : compiler/stage2/$(PLATFORM_H) |
|---|
| 121 | $(ghc_stage3_depfile_haskell) : compiler/stage3/$(PLATFORM_H) |
|---|
| 122 | |
|---|
| 123 | all_ghc_stage1 : $(GHC_STAGE1) |
|---|
| 124 | all_ghc_stage2 : $(GHC_STAGE2) |
|---|
| 125 | all_ghc_stage3 : $(GHC_STAGE3) |
|---|
| 126 | |
|---|
| 127 | $(INPLACE_LIB)/settings : settings |
|---|
| 128 | "$(CP)" $< $@ |
|---|
| 129 | |
|---|
| 130 | # The GHC programs need to depend on all the helper programs they might call, |
|---|
| 131 | # and the settings files they use |
|---|
| 132 | |
|---|
| 133 | $(GHC_STAGE1) : | $(UNLIT) $(INPLACE_LIB)/settings |
|---|
| 134 | $(GHC_STAGE2) : | $(UNLIT) $(INPLACE_LIB)/settings |
|---|
| 135 | $(GHC_STAGE3) : | $(UNLIT) $(INPLACE_LIB)/settings |
|---|
| 136 | |
|---|
| 137 | ifeq "$(GhcUnregisterised)" "NO" |
|---|
| 138 | $(GHC_STAGE1) : | $(SPLIT) |
|---|
| 139 | $(GHC_STAGE2) : | $(SPLIT) |
|---|
| 140 | $(GHC_STAGE3) : | $(SPLIT) |
|---|
| 141 | endif |
|---|
| 142 | |
|---|
| 143 | ifeq "$(Windows)" "YES" |
|---|
| 144 | $(GHC_STAGE1) : | $(TOUCHY) |
|---|
| 145 | $(GHC_STAGE2) : | $(TOUCHY) |
|---|
| 146 | $(GHC_STAGE3) : | $(TOUCHY) |
|---|
| 147 | endif |
|---|
| 148 | |
|---|
| 149 | ifeq "$(BootingFromHc)" "YES" |
|---|
| 150 | $(GHC_STAGE2) : $(ALL_STAGE1_LIBS) |
|---|
| 151 | ghc_stage2_OTHER_OBJS += $(compiler_stage2_v_LIB) $(ALL_STAGE1_LIBS) $(ALL_STAGE1_LIBS) $(ALL_STAGE1_LIBS) $(ALL_RTS_LIBS) $(libffi_STATIC_LIB) |
|---|
| 152 | endif |
|---|
| 153 | |
|---|
| 154 | endif |
|---|
| 155 | |
|---|
| 156 | INSTALL_LIBS += settings |
|---|
| 157 | |
|---|
| 158 | ifeq "$(Windows)" "NO" |
|---|
| 159 | install: install_ghc_link |
|---|
| 160 | .PHONY: install_ghc_link |
|---|
| 161 | install_ghc_link: |
|---|
| 162 | $(call removeFiles,"$(DESTDIR)$(bindir)/ghc") |
|---|
| 163 | $(LN_S) $(CrossCompilePrefix)ghc-$(ProjectVersion) "$(DESTDIR)$(bindir)/$(CrossCompilePrefix)ghc" |
|---|
| 164 | else |
|---|
| 165 | # On Windows we install the main binary as $(bindir)/ghc.exe |
|---|
| 166 | # To get ghc-<version>.exe we have a little C program in driver/ghc |
|---|
| 167 | install: install_ghc_post |
|---|
| 168 | .PHONY: install_ghc_post |
|---|
| 169 | install_ghc_post: install_bins |
|---|
| 170 | $(call removeFiles,$(DESTDIR)$(bindir)/ghc.exe) |
|---|
| 171 | "$(MV)" -f $(DESTDIR)$(bindir)/ghc-stage$(INSTALL_GHC_STAGE).exe $(DESTDIR)$(bindir)/$(CrossCompilePrefix)ghc.exe |
|---|
| 172 | endif |
|---|