1 # -----------------------------------------------------------------------------
2 # Main ghc/compiler Makefile
6 # all builds stage1 compiler
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).
13 # stage1 (or stage=1) builds stage1 compiler
14 # stage2 (or stage=2) builds stage2 compiler
15 # stage3 (or stage=3) builds stage3 compiler
20 # Use GHC for compiling C bits (NB. must be before boilerplate include)
24 include $(TOP)/mk/boilerplate.mk
26 #-----------------------------------------------------------------------------
27 # Counting source code lines
29 USER_SRCS = $(filter-out $(DERIVED_SRCS),$(SRCS))
31 ./count_lines $(USER_SRCS)
33 #-----------------------------------------------------------------------------
34 # Building ghc different ways (default is just `normal' sequential)
36 WAYS=$(GhcCompilerWays)
38 # -----------------------------------------------------------------------------
41 # The stage1/stage2/stage3 business is quite delicate. Here's how it works:
43 # - the variable $(stage) holds the current stage number. To build a
44 # particular stage, you say 'make stage=N' where N is 1, 2, or 3.
47 # - for stage N, object files and .hi files are placed inside
48 # the directory stageN, in subdirectories as per the sources.
50 # - .hi-boot files are *linked* into the stageN tree, because in GHC 5.05+
51 # the .hi-boot file must reside in the same place as the .hi file.
53 # - we use explicit -o and -ohi options to direct the output from C &
54 # Haskell compilations.
56 # - we generate a different .depend file for each build. They need to be
57 # different, because each stage might include different files: stage1
58 # might not include GHCi, for example. For each stage, a normal .depend
59 # file is generated, and then post-processed to add the correct stageN/
60 # prefix to each object and .hi filename. The resulting .depend file
61 # is named .depend-$(stage). See the end of this Makefile for details.
63 # - normal implicit rules don't work any more, because they're of the form
67 # whereas we really need
71 # so suffix.mk now defines the appropriate suffix rules when
72 # $(odir) is set to a non-empty value. Here we set $(odir) to
73 # stage1, stage2, or stage3.
75 # There are other plausible designs that might work, but each has different
78 # - using -odir and -hidir: GHC <= 4.08 doesn't support -hidir, and
79 # anyway -odir puts all the objects in one directory (strips off the
80 # subdirectory part), which eventually forces us to use VPATH to find
81 # the sources. I have a really bad feeling about VPATH.
83 # - invoke make in the stageN subdirectory. This probably requires VPATH
86 # - create a link tree. The problem with requiring link trees is that
87 # Windows doesn't support symbolic links.
95 $(MKDIRHIER) stage$(stage)
96 for i in $(ALL_DIRS); do \
97 $(MKDIRHIER) stage$(stage)/$$i; \
102 # On Windows, we can't use symbolic links for the -hi-boot files
103 # because GHC itself is a Mingw program and does not understand
104 # symbolic links. So we have to copy the files instead of link them.
105 # That means that if you modify a .hi-boot file in Windows, you
106 # have to to say 'make boot' again.
108 # PS: 'ln -s foo baz' takes 'foo' relative to the path to 'baz'
109 # whereas 'cp foo baz' treats the two paths independently.
110 # Hence the "../.." in the ln command line
112 ifeq "$(ghc_ge_603)" "NO"
113 ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
114 for i in */*hi-boot*; do \
115 cp -u -f $$i stage$(stage)/$$i; \
118 for i in */*hi-boot*; do \
119 $(LN_S) -f ../../$$i stage$(stage)/$$i || true ; \
148 SRC_HC_OPTS += $(patsubst %, -i$(odir)/%, $(ALL_DIRS))
150 HS_OBJS = $(patsubst %, $(odir)/%, $(addsuffix .$(way_)o,$(basename $(HS_SRCS))))
151 C_OBJS = $(patsubst %, $(odir)/%, $(addsuffix .$(way_)o,$(basename $(C_SRCS))))
153 CLEAN_FILES += $(odir)/*/*.hi
156 mostlyclean clean distclean maintainer-clean ::
161 # -----------------------------------------------------------------------------
164 # Note: there have been reports of people running up against the ARG_MAX limit
165 # when linking ghc with all its constituent object files. The likely source of
166 # the problem is that the environment is a bit too big, so a workaround could
167 # be to do `env PATH=$(PATH) make ghc' to minimise the environment. (or the
168 # equivalent of `env' if it doesn't exist locally).
170 ifneq "$(BuildPackageGHC)" "YES"
172 ifneq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
173 HS_PROG=$(odir)/ghc$(_way)-$(ProjectVersion)
175 HS_PROG=$(odir)/ghc$(_way)
178 HS_PROG=$(odir)/ghc-$(ProjectVersion)
182 # -----------------------------------------------------------------------------
183 # Create compiler configuration
185 # The 'echo' commands simply spit the values of various make variables
186 # into Config.hs, whence they can be compiled and used by GHC itself
188 CONFIG_HS = main/Config.hs
191 $(CONFIG_HS) : $(FPTOOLS_TOP)/mk/config.mk Makefile
192 @$(RM) -f $(CONFIG_HS)
193 @echo "Creating $(CONFIG_HS) ... "
194 @echo "module Config where" >>$(CONFIG_HS)
195 @echo "cProjectName = \"$(ProjectName)\"" >> $(CONFIG_HS)
196 @echo "cProjectVersion = \"$(ProjectVersion)\"" >> $(CONFIG_HS)
197 @echo "cProjectVersionInt = \"$(ProjectVersionInt)\"" >> $(CONFIG_HS)
198 @echo "cProjectPatchLevel = \"$(ProjectPatchLevel)\"" >> $(CONFIG_HS)
199 @echo "cBooterVersion = \"$(GhcVersion)\"" >> $(CONFIG_HS)
200 @echo "cHscIfaceFileVersion = \"$(HscIfaceFileVersion)\"" >> $(CONFIG_HS)
201 @echo "cGhcWithNativeCodeGen = \"$(GhcWithNativeCodeGen)\"" >> $(CONFIG_HS)
202 @echo "cGhcUnregisterised = \"$(GhcUnregisterised)\"" >> $(CONFIG_HS)
203 @echo "cLeadingUnderscore = \"$(LeadingUnderscore)\"" >> $(CONFIG_HS)
204 @echo "cRAWCPP_FLAGS = \"$(RAWCPP_FLAGS)\"" >> $(CONFIG_HS)
205 @echo "cGCC = \"$(WhatGccIsCalled)\"" >> $(CONFIG_HS)
206 @echo "cMKDLL = \"$(BLD_DLL)\"" >> $(CONFIG_HS)
207 @echo "cPROJECT_DIR = \"$(PROJECT_DIR)\"" >> $(CONFIG_HS)
208 @echo "cGHC_DRIVER_DIR_REL = \"$(GHC_DRIVER_DIR_REL)\"" >> $(CONFIG_HS)
209 @echo "cGHC_TOUCHY_PGM = \"$(GHC_TOUCHY_PGM)\"" >> $(CONFIG_HS)
210 @echo "cGHC_TOUCHY_DIR_REL = \"$(GHC_TOUCHY_DIR_REL)\"" >> $(CONFIG_HS)
211 @echo "cGHC_UNLIT_PGM = \"$(GHC_UNLIT_PGM)\"" >> $(CONFIG_HS)
212 @echo "cGHC_UNLIT_DIR_REL = \"$(GHC_UNLIT_DIR_REL)\"" >> $(CONFIG_HS)
213 @echo "cGHC_MANGLER_PGM = \"$(GHC_MANGLER_PGM)\"" >> $(CONFIG_HS)
214 @echo "cGHC_MANGLER_DIR_REL = \"$(GHC_MANGLER_DIR_REL)\"" >> $(CONFIG_HS)
215 @echo "cGHC_SPLIT_PGM = \"$(GHC_SPLIT_PGM)\"" >> $(CONFIG_HS)
216 @echo "cGHC_SPLIT_DIR_REL = \"$(GHC_SPLIT_DIR_REL)\"" >> $(CONFIG_HS)
217 @echo "cGHC_SYSMAN_PGM = \"$(GHC_SYSMAN)\"" >> $(CONFIG_HS)
218 @echo "cGHC_SYSMAN_DIR_REL = \"$(GHC_SYSMAN_DIR)\"" >> $(CONFIG_HS)
219 @echo "cGHC_CP = \"$(GHC_CP)\"" >> $(CONFIG_HS)
220 @echo "cGHC_PERL = \"$(GHC_PERL)\"" >> $(CONFIG_HS)
221 ifeq ($(GhcWithIlx),YES)
222 @echo "cILX2IL = \"$(ILX2IL)\"" >> $(CONFIG_HS)
223 @echo "cILASM = \"$(ILASM)\"" >> $(CONFIG_HS)
225 @echo "cEnableWin32DLLs = \"$(EnableWin32DLLs)\"" >> $(CONFIG_HS)
226 @echo "cCONTEXT_DIFF = \"$(CONTEXT_DIFF)\"" >> $(CONFIG_HS)
227 @echo "cUSER_WAY_NAMES = \"$(USER_WAY_NAMES)\"" >> $(CONFIG_HS)
228 @echo "cUSER_WAY_OPTS = \"$(USER_WAY_OPTS)\"" >> $(CONFIG_HS)
229 @echo "cDEFAULT_TMPDIR = \"$(DEFAULT_TMPDIR)\"" >> $(CONFIG_HS)
232 CLEAN_FILES += $(CONFIG_HS)
234 # -----------------------------------------------------------------------------
235 # Create platform includes
237 # Here we generate a little header file containing CPP symbols that GHC
238 # uses to determine which platform it is building on/for. The platforms
239 # can differ between stage1 and stage2 if we're cross-compiling, so we
240 # need one of these header files per stage.
242 PLATFORM_H = ghc_boot_platform.h
244 stage1/$(PLATFORM_H) : stage_dirs $(FPTOOLS_TOP)/mk/config.mk Makefile
245 @echo "Creating $@..."
247 @echo "#ifndef __PLATFORM_H__" >$@
248 @echo "#define __PLATFORM_H__" >>$@
250 @echo "#define BuildPlatform_TYPE $(BuildPlatform_CPP)" >> $@
251 @echo "#define HostPlatform_TYPE $(HostPlatform_CPP)" >> $@
252 @echo "#define TargetPlatform_TYPE $(TargetPlatform_CPP)" >> $@
254 @echo "#define $(BuildPlatform_CPP)_BUILD 1" >> $@
255 @echo "#define $(HostPlatform_CPP)_HOST 1" >> $@
256 @echo "#define $(TargetPlatform_CPP)_TARGET 1" >> $@
258 @echo "#define $(BuildArch_CPP)_BUILD_ARCH 1" >> $@
259 @echo "#define $(HostArch_CPP)_HOST_ARCH 1" >> $@
260 @echo "#define $(TargetArch_CPP)_TARGET_ARCH 1" >> $@
261 @echo "#define BUILD_ARCH \"$(BuildArch_CPP)\"" >> $@
262 @echo "#define HOST_ARCH \"$(HostArch_CPP)\"" >> $@
263 @echo "#define TARGET_ARCH \"$(TargetArch_CPP)\"" >> $@
265 @echo "#define $(BuildOS_CPP)_BUILD_OS 1" >> $@
266 @echo "#define $(HostOS_CPP)_HOST_OS 1" >> $@
267 @echo "#define $(TargetOS_CPP)_TARGET_OS 1" >> $@
268 @echo "#define BUILD_OS \"$(BuildOS_CPP)\"" >> $@
269 @echo "#define HOST_OS \"$(HostOS_CPP)\"" >> $@
270 @echo "#define TARGET_OS \"$(TargetOS_CPP)\"" >> $@
271 ifeq "$(HostOS_CPP)" "irix"
272 @echo "#ifndef $(IRIX_MAJOR)_TARGET_OS " >> $@
273 @echo "#define $(IRIX_MAJOR)_TARGET_OS 1" >> $@
274 @echo "#endif " >> $@
277 @echo "#define $(BuildVendor_CPP)_BUILD_VENDOR 1" >> $@
278 @echo "#define $(HostVendor_CPP)_HOST_VENDOR 1" >> $@
279 @echo "#define $(TargetVendor_CPP)_TARGET_VENDOR 1" >> $@
280 @echo "#define BUILD_VENDOR \"$(BuildVendor_CPP)\"" >> $@
281 @echo "#define HOST_VENDOR \"$(HostVendor_CPP)\"" >> $@
282 @echo "#define TARGET_VENDOR \"$(TargetVendor_CPP)\"" >> $@
284 @echo "#endif /* __PLATFORM_H__ */" >> $@
287 # For stage2 and above, the BUILD platform is the HOST of stage1, and
288 # the HOST platform is the TARGET of stage1. The TARGET remains the same
289 # (stage1 is the cross-compiler, not stage2).
290 stage2/$(PLATFORM_H) : stage_dirs $(FPTOOLS_TOP)/mk/config.mk Makefile
291 @echo "Creating $@..."
293 @echo "#ifndef __PLATFORM_H__" >$@
294 @echo "#define __PLATFORM_H__" >>$@
296 @echo "#define BuildPlatform_TYPE $(HostPlatform_CPP)" >> $@
297 @echo "#define HostPlatform_TYPE $(TargetPlatform_CPP)" >> $@
298 @echo "#define TargetPlatform_TYPE $(TargetPlatform_CPP)" >> $@
300 @echo "#define $(HostPlatform_CPP)_BUILD 1" >> $@
301 @echo "#define $(TargetPlatform_CPP)_HOST 1" >> $@
302 @echo "#define $(TargetPlatform_CPP)_TARGET 1" >> $@
304 @echo "#define $(HostArch_CPP)_BUILD_ARCH 1" >> $@
305 @echo "#define $(TargetArch_CPP)_HOST_ARCH 1" >> $@
306 @echo "#define $(TargetArch_CPP)_TARGET_ARCH 1" >> $@
307 @echo "#define BUILD_ARCH \"$(HostArch_CPP)\"" >> $@
308 @echo "#define HOST_ARCH \"$(TargetArch_CPP)\"" >> $@
309 @echo "#define TARGET_ARCH \"$(TargetArch_CPP)\"" >> $@
311 @echo "#define $(HostOS_CPP)_BUILD_OS 1" >> $@
312 @echo "#define $(TargetOS_CPP)_HOST_OS 1" >> $@
313 @echo "#define $(TargetOS_CPP)_TARGET_OS 1" >> $@
314 @echo "#define BUILD_OS \"$(HostOS_CPP)\"" >> $@
315 @echo "#define HOST_OS \"$(TargetOS_CPP)\"" >> $@
316 @echo "#define TARGET_OS \"$(TargetOS_CPP)\"" >> $@
317 ifeq "$(HostOS_CPP)" "irix"
318 @echo "#ifndef $(IRIX_MAJOR)_TARGET_OS " >> $@
319 @echo "#define $(IRIX_MAJOR)_TARGET_OS 1" >> $@
320 @echo "#endif " >> $@
323 @echo "#define $(HostVendor_CPP)_BUILD_VENDOR 1" >> $@
324 @echo "#define $(TargetVendor_CPP)_HOST_VENDOR 1" >> $@
325 @echo "#define $(TargetVendor_CPP)_TARGET_VENDOR 1" >> $@
326 @echo "#define BUILD_VENDOR \"$(HostVendor_CPP)\"" >> $@
327 @echo "#define HOST_VENDOR \"$(TargetVendor_CPP)\"" >> $@
328 @echo "#define TARGET_VENDOR \"$(TargetVendor_CPP)\"" >> $@
330 @echo "#endif /* __PLATFORM_H__ */" >> $@
333 stage3/$(PLATFORM_H) : stage_dirs stage2/$(PLATFORM_H)
334 $(CP) stage2/$(PLATFORM_H) stage3/$(PLATFORM_H)
336 STAGE_PLATFORM_H = stage$(stage)/$(PLATFORM_H)
338 boot :: $(STAGE_PLATFORM_H)
340 SRC_HC_OPTS += -Istage$(stage)
342 # -----------------------------------------------------------------------------
345 # First figure out ALL_DIRS, the source sub-directories
348 utils basicTypes types hsSyn prelude rename typecheck deSugar coreSyn \
349 specialise simplCore stranal stgSyn simplStg codeGen main \
350 profiling parser cprAnalysis compMan ndpFlatten iface cmm
352 # Make sure we include Config.hs even if it doesn't exist yet...
353 ALL_SRCS += $(CONFIG_HS)
355 # HsGeneric.hs is not used just now
356 EXCLUDED_SRCS += hsSyn/HsGeneric.hs
358 ifeq ($(GhcWithNativeCodeGen),YES)
359 ALL_DIRS += nativeGen
361 SRC_HC_OPTS += -DOMIT_NATIVE_CODEGEN
364 ifeq ($(GhcWithIlx),YES)
369 ifeq ($(GhcWithJavaGen),YES)
371 SRC_HC_OPTS += -DJAVA
374 ifeq "$(BootingFromHc)" "YES"
375 # HC files are always from a self-booted compiler
378 ifneq "$(findstring $(stage), 2 3)" ""
381 bootstrapped = $(shell if (test $(GhcCanonVersion) -ge $(ProjectVersionInt) -a $(GhcPatchLevel) -ge $(ProjectPatchLevel)); then echo YES; else echo NO; fi)
385 # -----------------------------------------------------------------------------
386 # Building a compiler with interpreter support
388 # The interpreter, GHCi interface, and Template Haskell are only
389 # enabled when we are bootstrapping with the same version of GHC, and
390 # the interpreter is supported on this platform.
392 ifeq "$(GhcWithInterpreter) $(bootstrapped)" "YES YES"
394 # Yes, include the interepreter, readline, and Template Haskell extensions
395 SRC_HC_OPTS += -DGHCI -package template-haskell
399 # Enable readline if either:
400 # - we're building stage 1 and $(GhcHasReadline)="YES"
401 # - we're building stage 2/3, and we have built the readline package
403 # But we don't enable readline on Windows, because readline is fairly
406 ifneq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
408 ifeq "$(GhcHasReadline)" "YES"
409 SRC_HC_OPTS += -package readline -DUSE_READLINE
412 ifeq "$(GhcLibsWithReadline)" "YES"
413 SRC_HC_OPTS += -package readline -DUSE_READLINE
420 # No interpreter, so exclude Template Haskell modules
421 EXCLUDED_SRCS += deSugar/DsMeta.hs typecheck/TcSplice.lhs hsSyn/Convert.lhs
423 endif # bootstrapped with interpreter
425 # -----------------------------------------------
428 # Big Fudge to get around inherent problem that Makefile setup
429 # has got with 'mkdependC'.
431 SRC_MKDEPENDC_OPTS += -D__GLASGOW_HASKELL__=$(ProjectVersionInt)
433 # XXX not really correct, hschooks.c actually gets include files like
434 # RtsFlags.c from the installed GHC, but we can't tell mkdependC about that.
435 SRC_MKDEPENDC_OPTS += -I$(GHC_INCLUDE_DIR)
437 # -----------------------------------------------------------------------------
438 # Haskell compilations
441 -cpp -fglasgow-exts -fno-generics -Rghc-timing \
442 -I. -IcodeGen -InativeGen -Iparser
444 # Omitted: -I$(GHC_INCLUDE_DIR)
445 # We should have -I$(GHC_INCLUDE_DIR) in SRC_HC_OPTS,
446 # to avoid the use of an explicit path in GHC source files
447 # (include "../includes/config.h"
448 # But alas GHC 4.08 (and others for all I know) uses this very
449 # same include path when compiling the .hc files it generates.
450 # Disaster! Then the hc file sees the GHC 5.02 (or whatever)
451 # include files. For the moment we've reverted to using
452 # an explicit path in the .hs sources
454 # For the benefit of <5.00 compilers, do include GHC_INCLUDE_DIR
455 # when generating dependencies. (=> it gets passed onto mkdependHS,
457 SRC_MKDEPENDHS_OPTS += -I$(GHC_INCLUDE_DIR)
459 # We need System.Posix (or Posix when ghc < 6.2)
460 ifneq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
461 ifeq "$(bootstrapped) $(ghc_ge_601)" "NO NO"
462 SRC_HC_OPTS += -package posix
464 SRC_HC_OPTS += -package unix
468 ifneq "$(findstring YES, $(bootstrapped) $(ghc_ge_603))" ""
469 SRC_HC_OPTS += -package Cabal
472 SRC_CC_OPTS += -Iparser -I. -O
473 SRC_HC_OPTS += -recomp $(GhcHcOpts) $(GhcStage$(stage)HcOpts)
476 ifeq "$(BootingFromHc)" "YES"
477 SRC_CC_OPTS += -D__GLASGOW_HASKELL__=$(ProjectVersionInt)
480 # Special flags for particular modules
481 # The standard suffix rule for compiling a Haskell file
482 # adds these flags to the command line
484 # There used to be a -no-recomp flag on PrimOp, but why?
485 # It's an expensive module to recompile!
486 prelude/PrimOp_HC_OPTS = -H80m
488 # because the NCG can't handle the 64-bit math in here
489 prelude/PrelRules_HC_OPTS = -fvia-C
491 main/ParsePkgConf_HC_OPTS += -fno-warn-incomplete-patterns
492 # Use -fvia-C since the NCG can't handle the narrow16Int# (and intToInt16#?)
493 # primops on all platforms.
494 parser/Parser_HC_OPTS += -fno-warn-incomplete-patterns -fvia-C
496 # Careful optimisation of the parser: we don't want to throw everything
497 # at it, because that takes too long and doesn't buy much, but we do want
498 # to inline certain key external functions, so we instruct GHC not to
499 # throw away inlinings as it would normally do in -Onot mode:
500 parser/Parser_HC_OPTS += -Onot -fno-ignore-interface-pragmas
502 ifeq "$(HOSTPLATFORM)" "hppa1.1-hp-hpux9"
503 rename/RnMonad_HC_OPTS = -O2 -O2-for-C
506 utils/Digraph_HC_OPTS = -fglasgow-exts
508 basicTypes/SrcLoc_HC_OPTS = -funbox-strict-fields
510 ifeq "$(bootstrapped)" "YES"
511 utils/Binary_HC_OPTS = -funbox-strict-fields
514 # ByteCodeItbls uses primops that the NCG doesn't support yet.
515 ghci/ByteCodeItbls_HC_OPTS += -fvia-C
516 ghci/ByteCodeLink_HC_OPTS += -fvia-C -monly-3-regs
518 # BinIface and Binary take ages to both compile and run if you don's use -O
519 main/BinIface_HC_OPTS += -O
520 utils/Binary_HC_OPTS += -O
521 utils/FastMutInt_HC_OPTS += -O
524 # ---- Profiling ----
525 #simplCore/Simplify_HC_OPTS = -auto-all
526 #simplCore/SimplEnv_HC_OPTS = -auto-all
527 #simplCore/SimplUtils_HC_OPTS = -auto-all
529 # CSE interacts badly with top-level IORefs (reportedly in DriverState and
530 # DriverMkDepend), causing some of them to be commoned up. We have a fix for
531 # this in 5.00+, but earlier versions of the compiler will need CSE turned off.
532 # To be on the safe side, we disable CSE in *all* modules with top-level IORefs.
533 compMan/CompManager_HC_OPTS = -fno-cse
534 ghci/InteractiveUI_HC_OPTS = -fno-cse
535 main/CmdLineOpts_HC_OPTS = -fno-cse
536 main/DriverFlags_HC_OPTS = -fno-cse
537 main/DriverMkDepend_HC_OPTS = -fno-cse
538 main/DriverPipeline_HC_OPTS = -fno-cse
539 main/DriverState_HC_OPTS = -fno-cse
540 main/DriverUtil_HC_OPTS = -fno-cse
541 main/Finder_HC_OPTS = -fno-cse
542 main/SysTools_HC_OPTS = -fno-cse
544 # The #include is vital for the via-C route, else the C
545 # compiler doesn't realise that the stcall foreign imports are indeed
546 # stdcall, and doesn't generate the Foo@8 name for them
547 ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
548 main/SysTools_HC_OPTS += '-\#include <windows.h>' '-\#include <process.h>'
551 parser/Lexer_HC_OPTS += -funbox-strict-fields
553 # ghc_strlen percolates through so many modules that it is easier to get its
554 # prototype via a global option instead of a myriad of per-file OPTIONS
555 SRC_HC_OPTS += '-\#include "hschooks.h"'
557 # ----------------------------------------------------------------------------
558 # Generate supporting stuff for prelude/PrimOp.lhs
559 # from prelude/primops.txt
561 GENPOC=$(TOP)/utils/genprimopcode/genprimopcode
563 PRIMOP_BITS=primop-data-decl.hs-incl \
565 primop-list.hs-incl \
566 primop-has-side-effects.hs-incl \
567 primop-out-of-line.hs-incl \
568 primop-commutable.hs-incl \
569 primop-needs-wrapper.hs-incl \
570 primop-can-fail.hs-incl \
571 primop-strictness.hs-incl \
572 primop-primop-info.hs-incl
574 CLEAN_FILES += prelude/primops.txt
575 CLEAN_FILES += $(PRIMOP_BITS)
577 SRC_CPP_OPTS += -I$(GHC_INCLUDE_DIR)
578 SRC_CPP_OPTS += ${GhcCppOpts}
580 ifneq "$(BootingFromHc)" "YES"
581 prelude/PrimOp.lhs $(odir)/prelude/PrimOp.o: $(PRIMOP_BITS)
584 ifneq "$(BootingFromHc)" "YES"
585 depend :: $(PRIMOP_BITS)
588 primop-data-decl.hs-incl: prelude/primops.txt
589 $(GENPOC) --data-decl < $< > $@
590 primop-tag.hs-incl: prelude/primops.txt
591 $(GENPOC) --primop-tag < $< > $@
592 primop-list.hs-incl: prelude/primops.txt
593 $(GENPOC) --primop-list < $< > $@
594 primop-has-side-effects.hs-incl: prelude/primops.txt
595 $(GENPOC) --has-side-effects < $< > $@
596 primop-out-of-line.hs-incl: prelude/primops.txt
597 $(GENPOC) --out-of-line < $< > $@
598 primop-commutable.hs-incl: prelude/primops.txt
599 $(GENPOC) --commutable < $< > $@
600 primop-needs-wrapper.hs-incl: prelude/primops.txt
601 $(GENPOC) --needs-wrapper < $< > $@
602 primop-can-fail.hs-incl: prelude/primops.txt
603 $(GENPOC) --can-fail < $< > $@
604 primop-strictness.hs-incl: prelude/primops.txt
605 $(GENPOC) --strictness < $< > $@
606 primop-primop-info.hs-incl: prelude/primops.txt
607 $(GENPOC) --primop-primop-info < $< > $@
609 # Usages aren't used any more; but the generator
610 # can still generate them if we want them back
611 primop-usage.hs-incl: prelude/primops.txt
612 $(GENPOC) --usage < $< > $@
615 #-----------------------------------------------------------------------------
618 # Include libghccompat in stage1 only. In stage2 onwards, all these
619 # libraries will be available from the main libraries.
621 SRC_HC_OPTS += -i$(GHC_LIB_COMPAT_DIR)
622 SRC_LD_OPTS += -L$(GHC_LIB_COMPAT_DIR) -lghccompat
624 ifeq "$(Windows)" "YES"
625 # not very nice, but required for -lghccompat on Windows
626 SRC_LD_OPTS += -lshell32
629 # This is horrible. We ought to be able to omit the entire directory
631 SRC_MKDEPENDHS_OPTS += \
632 -optdep--exclude-module=Compat.RawSystem \
633 -optdep--exclude-module=Compat.Directory \
634 -optdep--exclude-module=Distribution.Compat.ReadP \
635 -optdep--exclude-module=Distribution.Extension \
636 -optdep--exclude-module=Distribution.GetOpt \
637 -optdep--exclude-module=Distribution.InstalledPackageInfo \
638 -optdep--exclude-module=Distribution.License \
639 -optdep--exclude-module=Distribution.Package \
640 -optdep--exclude-module=Distribution.ParseUtils \
641 -optdep--exclude-module=Distribution.Setup \
642 -optdep--exclude-module=Distribution.Version \
643 -optdep--exclude-module=System.Directory.Internals
646 SRC_LD_OPTS += -no-link-chk
648 # -----------------------------------------------------------------------------
649 # create ghc-inplace, a convenient way to run ghc from the build tree...
651 all :: $(odir)/ghc-inplace ghc-inplace
653 $(odir)/ghc-inplace : $(HS_PROG)
655 echo '#!/bin/sh' >>$@
656 echo exec $(FPTOOLS_TOP_ABS)/ghc/compiler/$(HS_PROG) '-B$(subst \,\\,$(FPTOOLS_TOP_ABS_PLATFORM))' '"$$@"' >>$@
659 ghc-inplace : stage1/ghc-inplace
662 CLEAN_FILES += $(odir)/ghc-inplace ghc-inplace
664 #-----------------------------------------------------------------------------
667 # We don't want ghc treated as an ordinary executable,
668 # but put it together with the libraries.
669 # Also don't want any interface files installed
671 DESTDIR = $(INSTALL_LIBRARY_DIR_GHC)
673 ifneq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
674 INSTALL_LIBEXECS += $(HS_PROG)
676 INSTALL_PROGS += $(HS_PROG)
679 # ----------------------------------------------------------------------------
682 # rename/RnBinds_HC_OPTS += -auto-all
683 # rename/RnEnv_HC_OPTS += -auto-all
684 # rename/RnExpr_HC_OPTS += -auto-all
685 # rename/RnHiFiles_HC_OPTS += -auto-all
686 # rename/RnHsSyn_HC_OPTS += -auto-all
687 # rename/Rename_HC_OPTS += -auto-all
688 # rename/RnIfaces_HC_OPTS += -auto-all
689 # rename/RnNames_HC_OPTS += -auto-all
690 # rename/RnSource_HC_OPTS += -auto-all
691 # rename/RnTypes_HC_OPTS += -auto-all
693 # typecheck/Inst_HC_OPTS += -auto-all
694 # typecheck/TcBinds_HC_OPTS += -auto-all
695 # typecheck/TcClassDcl_HC_OPTS += -auto-all
696 # typecheck/TcDefaults_HC_OPTS += -auto-all
697 # typecheck/TcDeriv_HC_OPTS += -auto-all
698 # typecheck/TcEnv_HC_OPTS += -auto-all
699 # typecheck/TcExpr_HC_OPTS += -auto-all
700 # typecheck/TcForeign_HC_OPTS += -auto-all
701 # typecheck/TcGenDeriv_HC_OPTS += -auto-all
702 # typecheck/TcHsSyn_HC_OPTS += -auto-all
703 # typecheck/TcIfaceSig_HC_OPTS += -auto-all
704 # typecheck/TcInstDcls_HC_OPTS += -auto-all
705 # typecheck/TcMatches_HC_OPTS += -auto-all
706 # typecheck/TcMonoType_HC_OPTS += -auto-all
707 # typecheck/TcMType_HC_OPTS += -auto-all
708 # typecheck/TcPat_HC_OPTS += -auto-all
709 # typecheck/TcRnDriver_HC_OPTS += -auto-all
710 # #typecheck/TcRnMonad_HC_OPTS += -auto-all
711 # #typecheck/TcRnTypes_HC_OPTS += -auto-all
712 # typecheck/TcRules_HC_OPTS += -auto-all
713 # typecheck/TcSimplify_HC_OPTS += -auto-all
714 # typecheck/TcSplice_HC_OPTS += -auto-all
715 # typecheck/TcTyClsDecls_HC_OPTS += -auto-all
716 # typecheck/TcTyDecls_HC_OPTS += -auto-all
717 # typecheck/TcType_HC_OPTS += -auto-all
718 # typecheck/TcUnify_HC_OPTS += -auto-all
720 coreSyn/CorePrep_HC_OPTS += -auto-all
722 #-----------------------------------------------------------------------------
723 # Building GHC package
725 ifeq "$(BuildPackageGHC)" "YES"
728 STANDALONE_PACKAGE = YES
733 #-----------------------------------------------------------------------------
736 MAINTAINER_CLEAN_FILES += parser/Parser.info main/ParsePkgConf.info
738 #-----------------------------------------------------------------------------
739 # Include target-rule boilerplate
741 # Don't use the default MKDEPENDHS stuff... we'll do our own, below
745 # Make doesn't work this out for itself, it seems
746 parser/Parser.y : parser/Parser.y.pp
747 EXTRA_SRCS += parser/Parser.y
750 #-----------------------------------------------------------------------------
751 # Source files for tags file generation
753 # We want to excluded derived sources, because they won't be in the source
754 # tree, which is where we are going to move the TAGS file to.a
756 TAGS_HS_SRCS = parser/Parser.y.pp $(filter-out $(DERIVED_SRCS) main/Config.hs parser/Parser.y, $(sort $(SRCS)))
759 include $(TOP)/mk/target.mk
761 # -----------------------------------------------------------------------------
764 MKDEPENDHS_HC_OPTS = $(patsubst -i$(odir)/%, -i%, $(HC_OPTS))
768 # Must do this *after* including target.mk, because $(HS_SRCS) isn't set yet.
769 depend :: $(STAGE_PLATFORM_H) $(HS_SRCS) $(C_SRCS)
771 ifneq "$(BootingFromHc)" "YES"
772 $(MKDEPENDHS) -M -optdep-f -optdep.depend-BASE $(foreach way,$(WAYS),-optdep-s -optdep$(way)) $(foreach obj,$(MKDEPENDHS_OBJ_SUFFICES),-osuf $(obj)) $(MKDEPENDHS_OPTS) $(filter-out -split-objs, $(MKDEPENDHS_HC_OPTS)) $(HS_SRCS)
774 $(MKDEPENDC) -f .depend-BASE $(MKDEPENDC_OPTS) $(foreach way,$(WAYS),-s $(way)) -- $(CC_OPTS) -- $(C_SRCS)
775 $(PERL) -pe 'binmode(stdin); binmode(stdout); s@^(\S*\.o)@stage$(stage)/$$1@g; s@(\S*\.hi)@stage$(stage)/$$1@g' <.depend-BASE >.depend-$(stage)
776 # The binmode stuff tells perl not to add stupid ^M's to the output
778 -include .depend-$(stage)