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