592498f5fa3d3f7658a3b4db16603ca18cd1a94c
[ghc-hetmet.git] / compiler / Makefile
1 # -----------------------------------------------------------------------------
2 # Main compiler Makefile
3
4 # Targets:
5 #
6 #       all     builds stage1 compiler
7 #
8 #       boot stage=N   generate build dirs and dependencies for stage N.
9 #                      NB. Must be done before 'make stageN'.
10 #                      NB. Cannot 'make boot stage=2' until stage1 has
11 #                          been built (similarly for stage3).
12 #
13 #       stage1  (or stage=1) builds stage1 compiler
14 #       stage2  (or stage=2) builds stage2 compiler
15 #       stage3  (or stage=3) builds stage3 compiler
16 #
17
18 TOP = ..
19
20 ifeq "$(stage)" ""
21 stage=1
22 endif
23
24 include $(TOP)/mk/boilerplate.mk
25 include $(TOP)/mk/cabal-flags.mk
26
27 ifeq "$(GhcThreaded) $(GhcProfiled)" "YES YES"
28 $(error Cannot make GHC both threaded and profiled)
29 endif
30
31 CONFIG_HS       = main/Config.hs
32 PRIMOP_BITS = primop-data-decl.hs-incl        \
33               primop-tag.hs-incl              \
34               primop-list.hs-incl             \
35               primop-has-side-effects.hs-incl \
36               primop-out-of-line.hs-incl      \
37               primop-commutable.hs-incl       \
38               primop-needs-wrapper.hs-incl    \
39               primop-can-fail.hs-incl         \
40               primop-strictness.hs-incl       \
41               primop-primop-info.hs-incl
42
43 boot:: boot.stage.$(stage)
44
45 all:: build.stage.$(stage)
46
47 doc:: doc.stage.$(stage)
48
49 stage1 ::
50         $(MAKE) stage=1
51
52 stage2 ::
53         $(MAKE) stage=2
54
55 stage3 ::
56         $(MAKE) stage=3
57
58 ifeq "$(CLEAN_ALL_STAGES)" "YES"
59 clean distclean::
60         $(RM) -f prelude/primops.txt
61         $(RM) -f $(PRIMOP_BITS)
62         $(RM) -f $(CONFIG_HS)
63         $(RM) -f parser/Parser.y
64         $(RM) -rf stage1 stage2plus
65         $(RM) -f $(STAGE3_PACKAGE_CONF)
66 endif
67
68 ifeq "$(CLEAN_ALL_STAGES)" "YES"
69 clean distclean:: clean.stage.1 clean.stage.2 clean.stage.3
70 else
71 clean distclean:: clean.stage.$(stage)
72 endif
73
74 ifeq "$(CLEAN_ALL_STAGES)" "YES"
75 distclean::
76         $(RM) -f ghc.cabal
77 endif
78
79 clean.stage.%:
80         -$(CABAL) clean --distpref dist-stage$*
81         $(RM) -f Makefile-stage$*
82
83 CONFIGURE_FLAGS_STAGE1 += --flags=stage1
84 CONFIGURE_FLAGS_STAGE2 += --flags=-stage1
85
86 ifeq "$(GhcWithNativeCodeGen)" "YES"
87 CONFIGURE_FLAGS_STAGE1 += --flags=ncg
88 CONFIGURE_FLAGS_STAGE2 += --flags=ncg
89 endif
90
91 ifeq "$(GhcWithInterpreter)" "YES"
92 CONFIGURE_FLAGS_STAGE2 += --flags=ghci
93
94 ifeq "$(BuildSharedLibs)" "YES"
95 CONFIGURE_FLAGS_STAGE2 += --enable-shared
96 # If we are going to use dynamic libraries instead of .o files for ghci,
97 # we will need to always retain CAFs in the compiler.
98 # ghci/keepCAFsForGHCi contains a GNU C __attribute__((constructor))
99 # function which sets the keepCAFs flag for the RTS before any Haskell
100 # code is run.
101 CONFIGURE_FLAGS_STAGE2 += --flags=dynlibs
102 endif
103
104 ifeq "$(GhcEnableTablesNextToCode) $(GhcUnregisterised)" "YES NO"
105 # Should GHCI be building info tables in the TABLES_NEXT_TO_CODE style
106 # or not?
107 # XXX This should logically be a CPP option, but there doesn't seem to
108 # be a flag for that
109 CONFIGURE_FLAGS_STAGE2 += --ghc-option=-DGHCI_TABLES_NEXT_TO_CODE
110 endif
111
112 # Should the debugger commands be enabled?
113 ifeq "$(GhciWithDebugger)" "YES"
114 CONFIGURE_FLAGS_STAGE2 += --ghc-option=-DDEBUGGER
115 endif
116
117 # Enable editline if:
118 #   - we're building stage 2/3, and we have built the editline package
119 #
120 # But we don't enable editline on Windows, as Windows terminals have
121 # editline-like support builtin.
122 #
123 ifneq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
124 ifeq "$(wildcard $(FPTOOLS_TOP_ABS)/libraries/editline/unbuildable)" ""
125 CONFIGURE_FLAGS_STAGE2 += --flags=editline
126 endif
127 endif
128 endif
129
130 ifeq "$(GhcWithNativeCodeGen)" "NO"
131 # XXX This should logically be a CPP option, but there doesn't seem to
132 # be a flag for that
133 COMMON_CONFIGURE_FLAGS += --ghc-option=-DOMIT_NATIVE_CODEGEN
134 endif
135
136 ifeq "$(TargetOS_CPP)" "openbsd"
137 COMMON_CONFIGURE_FLAGS += --ld-options=-E
138 endif
139
140 ifeq "$(GhcUnregisterised)" "NO"
141 ifeq "$(HOSTPLATFORM)" "ia64-unknown-linux"
142 # needed for generating proper relocation in large binaries: trac #856
143 COMMON_CONFIGURE_FLAGS += --ld-option=-Wl,--relax
144 endif
145 endif
146
147 # We need to turn on profiling either if we have been asked to
148 # (GhcLibProfiled = YES) or if we want GHC itself to be compiled with
149 # profiling enabled (GhcProfiled = YES).
150 ifneq "$(GhcLibProfiled) $(GhcProfiled)" "NO NO"
151 CONFIGURE_FLAGS_STAGE2 += --enable-library-profiling
152 # And if we're profiling GHC then we want lots of SCCs.
153 # We also don't want to waste time building the non-profiling library,
154 # either normally or for ghci. Unfortunately this means that we have to
155 # tell ghc-pkg --force as it gets upset when libHSghc-6.9.a doesn't
156 # exist.
157 ifeq "$(GhcProfiled)" "YES"
158 CONFIGURE_FLAGS_STAGE2 += --ghc-option=-auto-all
159 CONFIGURE_FLAGS_STAGE2 += --disable-library-vanilla
160 CONFIGURE_FLAGS_STAGE2 += --disable-library-for-ghci
161 CONFIGURE_FLAGS_STAGE2 += --ghc-pkg-option=--force
162 endif
163 endif
164
165 ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
166 # The #include is vital for the via-C route with older compilers, else the C
167 # compiler doesn't realise that the stcall foreign imports are indeed
168 # stdcall, and doesn't generate the Foo@8 name for them
169 # As it's only important for older compilers we don't need to do anything
170 # for stage2+.
171 CONFIGURE_FLAGS_STAGE1 += --ghc-option='-\#include'    \
172                           --ghc-option='"<windows.h>"' \
173                           --ghc-option='-\#include'    \
174                           --ghc-option='"<process.h>"'
175 endif
176
177 # ghc_strlen percolates through so many modules that it is easier to get its
178 # prototype via a global option instead of a myriad of per-file OPTIONS.
179 # Again, this is only important for older compilers, so we don't do it in
180 # stage 2+.
181 CONFIGURE_FLAGS_STAGE1 += --ghc-options='-\#include "cutils.h"'
182
183 CONFIGURE_FLAGS_STAGE3 = $(CONFIGURE_FLAGS_STAGE2)
184 CONFIGURE_FLAGS_STAGE1 += $(USE_BOOT_CONFIGURE_FLAGS)
185 CONFIGURE_FLAGS_STAGE2 += $(USE_STAGE1_CONFIGURE_FLAGS)
186 CONFIGURE_FLAGS_STAGE3 += $(USE_STAGE2_CONFIGURE_FLAGS)
187
188 boot.stage.%: $(PRIMOP_BITS) $(CONFIG_HS) parser/Parser.y
189         test -f $(STAGE3_PACKAGE_CONF) || echo "[]" > $(STAGE3_PACKAGE_CONF)
190         $(CABAL) configure --distpref dist-stage$* \
191                            $(CONFIGURE_FLAGS_STAGE$*) \
192                            $(INSTALL_DIRS_CONFIGURE_FLAGS) \
193                            $(COMMON_CONFIGURE_FLAGS) \
194                            --ghc-option=-DSTAGE=$*
195         $(RM) -f Makefile-stage$*
196         $(CABAL) makefile  --distpref dist-stage$* -f Makefile-stage$*
197
198 build.stage.%:
199         $(MAKE) -f Makefile-stage$* stage=$*
200         $(CABAL) register  --distpref dist-stage$* --inplace
201         $(MAKE) -C ../ghc stage=$*
202
203 doc.stage.%:
204         $(CABAL) haddock --distpref dist-stage$* \
205                          --haddock-option=--optghc=-DSTAGE=$* \
206                          --with-haddock=$(FPTOOLS_TOP_ABS)/utils/haddock/install-inplace/bin/haddock
207
208 install:
209         $(INSTALL_PACKAGE) install '$(GHC_PKG_INSTALL_PROG)' '$(DESTDIR)$(datadir)/package.conf' '$(DESTDIR)' '$(prefix)' '$(iprefix)' '$(ibindir)' '$(ilibdir)' '$(ilibexecdir)' '$(idynlibdir)' '$(idatadir)' '$(idocdir)' '$(ihtmldir)' '$(ihaddockdir)' --distpref dist-stage2
210
211 # -----------------------------------------------------------------------------
212 # Create compiler configuration
213 #
214 # The 'echo' commands simply spit the values of various make variables
215 # into Config.hs, whence they can be compiled and used by GHC itself
216
217 $(CONFIG_HS) : $(FPTOOLS_TOP)/mk/config.mk
218         @$(RM) -f $(CONFIG_HS)
219         @echo "Creating $(CONFIG_HS) ... "
220         @echo "module Config where" >>$(CONFIG_HS)
221         @echo "cProjectName          :: String" >> $(CONFIG_HS)
222         @echo "cProjectName          = \"$(ProjectName)\"" >> $(CONFIG_HS)
223         @echo "cProjectVersion       :: String" >> $(CONFIG_HS)
224         @echo "cProjectVersion       = \"$(ProjectVersion)\"" >> $(CONFIG_HS)
225         @echo "cProjectVersionInt    :: String" >> $(CONFIG_HS)
226         @echo "cProjectVersionInt    = \"$(ProjectVersionInt)\"" >> $(CONFIG_HS)
227         @echo "cProjectPatchLevel    :: String" >> $(CONFIG_HS)
228         @echo "cProjectPatchLevel    = \"$(ProjectPatchLevel)\"" >> $(CONFIG_HS)
229         @echo "cBooterVersion        :: String" >> $(CONFIG_HS)
230         @echo "cBooterVersion        = \"$(GhcVersion)\"" >> $(CONFIG_HS)
231         @echo "cStage                :: String" >> $(CONFIG_HS)
232         @echo "cStage                = show (STAGE :: Int)" >> $(CONFIG_HS)
233         @echo "cHscIfaceFileVersion  :: String" >> $(CONFIG_HS)
234         @echo "cHscIfaceFileVersion  = \"$(HscIfaceFileVersion)\"" >> $(CONFIG_HS)
235         @echo "cSplitObjs            :: String" >> $(CONFIG_HS)
236         @echo "cSplitObjs            = \"$(SplitObjs)\"" >> $(CONFIG_HS)
237         @echo "cGhcWithInterpreter   :: String" >> $(CONFIG_HS)
238         @echo "cGhcWithInterpreter   = \"$(GhcWithInterpreter)\"" >> $(CONFIG_HS)
239         @echo "cGhcWithNativeCodeGen :: String" >> $(CONFIG_HS)
240         @echo "cGhcWithNativeCodeGen = \"$(GhcWithNativeCodeGen)\"" >> $(CONFIG_HS)
241         @echo "cGhcWithSMP           :: String" >> $(CONFIG_HS)
242         @echo "cGhcWithSMP           = \"$(GhcWithSMP)\"" >> $(CONFIG_HS)
243         @echo "cGhcRTSWays           :: String" >> $(CONFIG_HS)
244         @echo "cGhcRTSWays           = \"$(GhcRTSWays)\"" >> $(CONFIG_HS)
245         @echo "cGhcUnregisterised    :: String" >> $(CONFIG_HS)
246         @echo "cGhcUnregisterised    = \"$(GhcUnregisterised)\"" >> $(CONFIG_HS)
247         @echo "cGhcEnableTablesNextToCode :: String" >> $(CONFIG_HS)
248         @echo "cGhcEnableTablesNextToCode = \"$(GhcEnableTablesNextToCode)\"" >> $(CONFIG_HS)
249         @echo "cLeadingUnderscore    :: String" >> $(CONFIG_HS)
250         @echo "cLeadingUnderscore    = \"$(LeadingUnderscore)\"" >> $(CONFIG_HS)
251         @echo "cRAWCPP_FLAGS         :: String" >> $(CONFIG_HS)
252         @echo "cRAWCPP_FLAGS         = \"$(RAWCPP_FLAGS)\"" >> $(CONFIG_HS)
253         @echo "cGCC                  :: String" >> $(CONFIG_HS)
254         @echo "cGCC                  = \"$(WhatGccIsCalled)\"" >> $(CONFIG_HS)
255         @echo "cMKDLL                :: String" >> $(CONFIG_HS)
256         @echo "cMKDLL                = \"$(BLD_DLL)\"" >> $(CONFIG_HS)
257         @echo "cLdIsGNULd            :: String" >> $(CONFIG_HS)
258         @echo "cLdIsGNULd            = \"$(LdIsGNULd)\"" >> $(CONFIG_HS)
259         @echo "cLD_X                 :: String" >> $(CONFIG_HS)
260         @echo "cLD_X                 = \"$(LD_X)\"" >> $(CONFIG_HS)
261         @echo "cGHC_DRIVER_DIR_REL   :: String" >> $(CONFIG_HS)
262         @echo "cGHC_DRIVER_DIR_REL   = \"$(GHC_DRIVER_DIR_REL)\"" >> $(CONFIG_HS)
263         @echo "cGHC_TOUCHY_PGM       :: String" >> $(CONFIG_HS)
264         @echo "cGHC_TOUCHY_PGM       = \"$(GHC_TOUCHY_PGM)\"" >> $(CONFIG_HS)
265         @echo "cGHC_TOUCHY_DIR_REL   :: String" >> $(CONFIG_HS)
266         @echo "cGHC_TOUCHY_DIR_REL   = \"$(GHC_TOUCHY_DIR_REL)\"" >> $(CONFIG_HS)
267         @echo "cGHC_UNLIT_PGM        :: String" >> $(CONFIG_HS)
268         @echo "cGHC_UNLIT_PGM        = \"$(GHC_UNLIT_PGM)\"" >> $(CONFIG_HS)
269         @echo "cGHC_UNLIT_DIR_REL    :: String" >> $(CONFIG_HS)
270         @echo "cGHC_UNLIT_DIR_REL    = \"$(GHC_UNLIT_DIR_REL)\"" >> $(CONFIG_HS)
271         @echo "cGHC_MANGLER_PGM      :: String" >> $(CONFIG_HS)
272         @echo "cGHC_MANGLER_PGM      = \"$(GHC_MANGLER_PGM)\"" >> $(CONFIG_HS)
273         @echo "cGHC_MANGLER_DIR_REL  :: String" >> $(CONFIG_HS)
274         @echo "cGHC_MANGLER_DIR_REL  = \"$(GHC_MANGLER_DIR_REL)\"" >> $(CONFIG_HS)
275         @echo "cGHC_SPLIT_PGM        :: String" >> $(CONFIG_HS)
276         @echo "cGHC_SPLIT_PGM        = \"$(GHC_SPLIT_PGM)\"" >> $(CONFIG_HS)
277         @echo "cGHC_SPLIT_DIR_REL    :: String" >> $(CONFIG_HS)
278         @echo "cGHC_SPLIT_DIR_REL    = \"$(GHC_SPLIT_DIR_REL)\"" >> $(CONFIG_HS)
279         @echo "cGHC_SYSMAN_PGM       :: String" >> $(CONFIG_HS)
280         @echo "cGHC_SYSMAN_PGM       = \"$(GHC_SYSMAN)\"" >> $(CONFIG_HS)
281         @echo "cGHC_SYSMAN_DIR_REL   :: String" >> $(CONFIG_HS)
282         @echo "cGHC_SYSMAN_DIR_REL   = \"$(GHC_SYSMAN_DIR)\"" >> $(CONFIG_HS)
283         @echo "cGHC_CP               :: String" >> $(CONFIG_HS)
284         @echo "cGHC_CP               = \"$(GHC_CP)\"" >> $(CONFIG_HS)
285         @echo "cGHC_PERL             :: String" >> $(CONFIG_HS)
286         @echo "cGHC_PERL             = \"$(GHC_PERL)\"" >> $(CONFIG_HS)
287         @echo "cEnableWin32DLLs      :: String" >> $(CONFIG_HS)
288         @echo "cEnableWin32DLLs      = \"$(EnableWin32DLLs)\"" >> $(CONFIG_HS)
289         @echo "cCONTEXT_DIFF         :: String" >> $(CONFIG_HS)
290         @echo "cCONTEXT_DIFF         = \"$(CONTEXT_DIFF)\"" >> $(CONFIG_HS)
291         @echo "cUSER_WAY_NAMES       :: String" >> $(CONFIG_HS)
292         @echo "cUSER_WAY_NAMES       = \"$(USER_WAY_NAMES)\"" >> $(CONFIG_HS)
293         @echo "cUSER_WAY_OPTS        :: String" >> $(CONFIG_HS)
294         @echo "cUSER_WAY_OPTS        = \"$(USER_WAY_OPTS)\"" >> $(CONFIG_HS)
295         @echo "cDEFAULT_TMPDIR       :: String" >> $(CONFIG_HS)
296         @echo "cDEFAULT_TMPDIR       = \"$(DEFAULT_TMPDIR)\"" >> $(CONFIG_HS)
297         @echo "cRelocatableBuild     :: Bool"                 >> $(CONFIG_HS)
298 ifeq "$(RelocatableBuild)" "YES"
299         @echo "cRelocatableBuild     = True"                  >> $(CONFIG_HS)
300 else
301         @echo "cRelocatableBuild     = False"                 >> $(CONFIG_HS)
302 endif
303         @echo "cLibFFI               :: Bool"                 >> $(CONFIG_HS)
304 ifeq "$(UseLibFFIForAdjustors)" "YES"
305         @echo "cLibFFI               = True"                  >> $(CONFIG_HS)
306 else
307         @echo "cLibFFI               = False"                 >> $(CONFIG_HS)
308 endif
309         @echo done.
310
311 # -----------------------------------------------------------------------------
312 # Create platform includes
313
314 # Here we generate a little header file containing CPP symbols that GHC
315 # uses to determine which platform it is building on/for.  The platforms
316 # can differ between stage1 and stage2 if we're cross-compiling, so we
317 # need one of these header files per stage.
318
319 PLATFORM_H = ghc_boot_platform.h
320
321 stage1/$(PLATFORM_H) : $(FPTOOLS_TOP)/mk/config.mk
322         $(MKDIRHIER) stage1
323         @echo "Creating $@..."
324         @$(RM) $@
325         @echo "#ifndef __PLATFORM_H__"  >$@
326         @echo "#define __PLATFORM_H__" >>$@
327         @echo >> $@
328         @echo "#define BuildPlatform_NAME  \"$(BUILDPLATFORM)\"" >> $@
329         @echo "#define HostPlatform_NAME   \"$(HOSTPLATFORM)\"" >> $@
330         @echo "#define TargetPlatform_NAME \"$(TARGETPLATFORM)\"" >> $@
331         @echo >> $@
332         @echo "#define $(BuildPlatform_CPP)_BUILD       1" >> $@
333         @echo "#define $(HostPlatform_CPP)_HOST         1" >> $@
334         @echo "#define $(TargetPlatform_CPP)_TARGET     1" >> $@
335         @echo >> $@
336         @echo "#define $(BuildArch_CPP)_BUILD_ARCH      1" >> $@
337         @echo "#define $(HostArch_CPP)_HOST_ARCH        1" >> $@
338         @echo "#define $(TargetArch_CPP)_TARGET_ARCH    1" >> $@
339         @echo "#define BUILD_ARCH \"$(BuildArch_CPP)\"" >> $@
340         @echo "#define HOST_ARCH \"$(HostArch_CPP)\"" >> $@
341         @echo "#define TARGET_ARCH \"$(TargetArch_CPP)\"" >> $@
342         @echo >> $@
343         @echo "#define $(BuildOS_CPP)_BUILD_OS          1" >> $@
344         @echo "#define $(HostOS_CPP)_HOST_OS            1" >> $@
345         @echo "#define $(TargetOS_CPP)_TARGET_OS        1" >> $@  
346         @echo "#define BUILD_OS \"$(BuildOS_CPP)\"" >> $@
347         @echo "#define HOST_OS \"$(HostOS_CPP)\"" >> $@
348         @echo "#define TARGET_OS \"$(TargetOS_CPP)\"" >> $@
349 ifeq "$(HostOS_CPP)" "irix"
350         @echo "#ifndef $(IRIX_MAJOR)_TARGET_OS           " >> $@  
351         @echo "#define $(IRIX_MAJOR)_TARGET_OS          1" >> $@  
352         @echo "#endif                                    " >> $@  
353 endif
354         @echo >> $@
355         @echo "#define $(BuildVendor_CPP)_BUILD_VENDOR  1" >> $@
356         @echo "#define $(HostVendor_CPP)_HOST_VENDOR    1" >> $@
357         @echo "#define $(TargetVendor_CPP)_TARGET_VENDOR  1" >> $@
358         @echo "#define BUILD_VENDOR \"$(BuildVendor_CPP)\"" >> $@
359         @echo "#define HOST_VENDOR \"$(HostVendor_CPP)\"" >> $@
360         @echo "#define TARGET_VENDOR \"$(TargetVendor_CPP)\"" >> $@
361         @echo >> $@
362         @echo "#endif /* __PLATFORM_H__ */"          >> $@
363         @echo "Done."
364
365 # For stage2 and above, the BUILD platform is the HOST of stage1, and
366 # the HOST platform is the TARGET of stage1.  The TARGET remains the same
367 # (stage1 is the cross-compiler, not stage2).
368 stage2plus/$(PLATFORM_H) : $(FPTOOLS_TOP)/mk/config.mk
369         $(MKDIRHIER) stage2plus
370         @echo "Creating $@..."
371         @$(RM) $@
372         @echo "#ifndef __PLATFORM_H__"  >$@
373         @echo "#define __PLATFORM_H__" >>$@
374         @echo >> $@
375         @echo "#define BuildPlatform_NAME  \"$(HOSTPLATFORM)\"" >> $@
376         @echo "#define HostPlatform_NAME   \"$(TARGETPLATFORM)\"" >> $@
377         @echo "#define TargetPlatform_NAME \"$(TARGETPLATFORM)\"" >> $@
378         @echo >> $@
379         @echo "#define $(HostPlatform_CPP)_BUILD        1" >> $@
380         @echo "#define $(TargetPlatform_CPP)_HOST               1" >> $@
381         @echo "#define $(TargetPlatform_CPP)_TARGET     1" >> $@
382         @echo >> $@
383         @echo "#define $(HostArch_CPP)_BUILD_ARCH       1" >> $@
384         @echo "#define $(TargetArch_CPP)_HOST_ARCH      1" >> $@
385         @echo "#define $(TargetArch_CPP)_TARGET_ARCH    1" >> $@
386         @echo "#define BUILD_ARCH \"$(HostArch_CPP)\"" >> $@
387         @echo "#define HOST_ARCH \"$(TargetArch_CPP)\"" >> $@
388         @echo "#define TARGET_ARCH \"$(TargetArch_CPP)\"" >> $@
389         @echo >> $@
390         @echo "#define $(HostOS_CPP)_BUILD_OS           1" >> $@
391         @echo "#define $(TargetOS_CPP)_HOST_OS          1" >> $@
392         @echo "#define $(TargetOS_CPP)_TARGET_OS        1" >> $@  
393         @echo "#define BUILD_OS \"$(HostOS_CPP)\"" >> $@
394         @echo "#define HOST_OS \"$(TargetOS_CPP)\"" >> $@
395         @echo "#define TARGET_OS \"$(TargetOS_CPP)\"" >> $@
396 ifeq "$(HostOS_CPP)" "irix"
397         @echo "#ifndef $(IRIX_MAJOR)_TARGET_OS           " >> $@  
398         @echo "#define $(IRIX_MAJOR)_TARGET_OS          1" >> $@  
399         @echo "#endif                                    " >> $@  
400 endif
401         @echo >> $@
402         @echo "#define $(HostVendor_CPP)_BUILD_VENDOR   1" >> $@
403         @echo "#define $(TargetVendor_CPP)_HOST_VENDOR  1" >> $@
404         @echo "#define $(TargetVendor_CPP)_TARGET_VENDOR  1" >> $@
405         @echo "#define BUILD_VENDOR \"$(HostVendor_CPP)\"" >> $@
406         @echo "#define HOST_VENDOR \"$(TargetVendor_CPP)\"" >> $@
407         @echo "#define TARGET_VENDOR \"$(TargetVendor_CPP)\"" >> $@
408         @echo >> $@
409         @echo "#endif /* __PLATFORM_H__ */"          >> $@
410         @echo "Done."
411
412 ifeq "$(stage)" "1"
413 STAGE_PLATFORM_H = stage1/$(PLATFORM_H)
414 else
415 STAGE_PLATFORM_H = stage2plus/$(PLATFORM_H)
416 endif
417
418 boot :: $(STAGE_PLATFORM_H)
419
420 # ----------------------------------------------------------------------------
421 #               Generate supporting stuff for prelude/PrimOp.lhs 
422 #               from prelude/primops.txt
423
424 SRC_CPP_OPTS += -I$(GHC_INCLUDE_DIR)
425 SRC_CPP_OPTS += ${GhcCppOpts}
426
427 prelude/primops.txt parser/Parser.y: %: %.pp stage1/$(PLATFORM_H)
428         $(CPP) $(RAWCPP_FLAGS) -P $(CPP_OPTS) -x c $< | grep -v '^#pragma GCC' > $@
429
430 primop-data-decl.hs-incl: prelude/primops.txt
431         $(GENPRIMOP) --data-decl          < $< > $@
432 primop-tag.hs-incl: prelude/primops.txt
433         $(GENPRIMOP) --primop-tag         < $< > $@
434 primop-list.hs-incl: prelude/primops.txt
435         $(GENPRIMOP) --primop-list        < $< > $@
436 primop-has-side-effects.hs-incl: prelude/primops.txt
437         $(GENPRIMOP) --has-side-effects   < $< > $@
438 primop-out-of-line.hs-incl: prelude/primops.txt
439         $(GENPRIMOP) --out-of-line        < $< > $@
440 primop-commutable.hs-incl: prelude/primops.txt
441         $(GENPRIMOP) --commutable         < $< > $@
442 primop-needs-wrapper.hs-incl: prelude/primops.txt
443         $(GENPRIMOP) --needs-wrapper      < $< > $@
444 primop-can-fail.hs-incl: prelude/primops.txt
445         $(GENPRIMOP) --can-fail           < $< > $@
446 primop-strictness.hs-incl: prelude/primops.txt
447         $(GENPRIMOP) --strictness         < $< > $@
448 primop-primop-info.hs-incl: prelude/primops.txt
449         $(GENPRIMOP) --primop-primop-info < $< > $@
450
451 # Usages aren't used any more; but the generator 
452 # can still generate them if we want them back
453 primop-usage.hs-incl: prelude/primops.txt
454         $(GENPRIMOP) --usage              < $< > $@
455
456 html:
457         $(MAKE) doc stage=2
458
459 install-docs:
460         @:
461
462 #-----------------------------------------------------------------------------
463 # binary-dist
464 #
465
466 # Ideally we'd get these from the Cabal file's Install-Includes:
467 BINDIST_EXTRAS += HsVersions.h
468 ifeq "$(stage)" "1"
469 BINDIST_EXTRAS += stage1/ghc_boot_platform.h
470 else
471 BINDIST_EXTRAS += stage2plus/ghc_boot_platform.h
472 endif
473
474 include $(TOP)/mk/bindist.mk
475 LIB_DIST_DIR = dist-stage2
476