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