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