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.
94 $(MKDIRHIER) stage$(stage)
95 for i in $(ALL_DIRS); do \
96 $(MKDIRHIER) stage$(stage)/$$i; \
98 # On Windows, we can't use symbolic links for the -hi-boot files
99 # because GHC itself is a Mingw program and does not understand
100 # symbolic links. So we have to copy the files instead of link them.
101 # That means that if you modify a .hi-boot file in Windows, you
102 # have to to say 'make boot' again.
104 # PS: 'ln -s foo baz' takes 'foo' relative to the path to 'baz'
105 # whereas 'cp foo baz' treats the two paths independently.
106 # Hence the "../.." in the ln command line
108 ifeq "$(ghc_ge_603)" "NO"
109 ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
110 for i in */*hi-boot*; do \
111 cp -u -f $$i stage$(stage)/$$i; \
114 for i in */*hi-boot*; do \
115 $(LN_S) -f ../../$$i stage$(stage)/$$i || true ; \
144 SRC_HC_OPTS += $(patsubst %, -i$(odir)/%, $(ALL_DIRS))
146 HS_OBJS = $(patsubst %, $(odir)/%, $(addsuffix .$(way_)o,$(basename $(HS_SRCS))))
147 C_OBJS = $(patsubst %, $(odir)/%, $(addsuffix .$(way_)o,$(basename $(C_SRCS))))
149 CLEAN_FILES += $(odir)/*/*.hi
152 mostlyclean clean distclean maintainer-clean ::
157 # -----------------------------------------------------------------------------
160 # Note: there have been reports of people running up against the ARG_MAX limit
161 # when linking ghc with all its constituent object files. The likely source of
162 # the problem is that the environment is a bit too big, so a workaround could
163 # be to do `env PATH=$(PATH) make ghc' to minimise the environment. (or the
164 # equivalent of `env' if it doesn't exist locally).
166 ifneq "$(BuildPackageGHC)" "YES"
168 ifneq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
169 HS_PROG=$(odir)/ghc$(_way)-$(ProjectVersion)
171 HS_PROG=$(odir)/ghc$(_way)
174 HS_PROG=$(odir)/ghc-$(ProjectVersion)
178 # -----------------------------------------------------------------------------
179 # Create compiler configuration
181 # The 'echo' commands simply spit the values of various make variables
182 # into Config.hs, whence they can be compiled and used by GHC itself
184 CONFIG_HS = main/Config.hs
187 $(CONFIG_HS) : $(FPTOOLS_TOP)/mk/config.mk Makefile
188 @$(RM) -f $(CONFIG_HS)
189 @echo "Creating $(CONFIG_HS) ... "
190 @echo "module Config where" >>$(CONFIG_HS)
191 @echo "cProjectName = \"$(ProjectName)\"" >> $(CONFIG_HS)
192 @echo "cProjectVersion = \"$(ProjectVersion)\"" >> $(CONFIG_HS)
193 @echo "cProjectVersionInt = \"$(ProjectVersionInt)\"" >> $(CONFIG_HS)
194 @echo "cProjectPatchLevel = \"$(ProjectPatchLevel)\"" >> $(CONFIG_HS)
195 @echo "cBooterVersion = \"$(GhcVersion)\"" >> $(CONFIG_HS)
196 @echo "cHscIfaceFileVersion = \"$(HscIfaceFileVersion)\"" >> $(CONFIG_HS)
197 @echo "cGhcWithNativeCodeGen = \"$(GhcWithNativeCodeGen)\"" >> $(CONFIG_HS)
198 @echo "cGhcUnregisterised = \"$(GhcUnregisterised)\"" >> $(CONFIG_HS)
199 @echo "cLeadingUnderscore = \"$(LeadingUnderscore)\"" >> $(CONFIG_HS)
200 @echo "cRAWCPP_FLAGS = \"$(RAWCPP_FLAGS)\"" >> $(CONFIG_HS)
201 @echo "cGCC = \"$(WhatGccIsCalled)\"" >> $(CONFIG_HS)
202 @echo "cMKDLL = \"$(BLD_DLL)\"" >> $(CONFIG_HS)
203 @echo "cPROJECT_DIR = \"$(PROJECT_DIR)\"" >> $(CONFIG_HS)
204 @echo "cGHC_DRIVER_DIR_REL = \"$(GHC_DRIVER_DIR_REL)\"" >> $(CONFIG_HS)
205 @echo "cGHC_TOUCHY_PGM = \"$(GHC_TOUCHY_PGM)\"" >> $(CONFIG_HS)
206 @echo "cGHC_TOUCHY_DIR_REL = \"$(GHC_TOUCHY_DIR_REL)\"" >> $(CONFIG_HS)
207 @echo "cGHC_UNLIT_PGM = \"$(GHC_UNLIT_PGM)\"" >> $(CONFIG_HS)
208 @echo "cGHC_UNLIT_DIR_REL = \"$(GHC_UNLIT_DIR_REL)\"" >> $(CONFIG_HS)
209 @echo "cGHC_MANGLER_PGM = \"$(GHC_MANGLER_PGM)\"" >> $(CONFIG_HS)
210 @echo "cGHC_MANGLER_DIR_REL = \"$(GHC_MANGLER_DIR_REL)\"" >> $(CONFIG_HS)
211 @echo "cGHC_SPLIT_PGM = \"$(GHC_SPLIT_PGM)\"" >> $(CONFIG_HS)
212 @echo "cGHC_SPLIT_DIR_REL = \"$(GHC_SPLIT_DIR_REL)\"" >> $(CONFIG_HS)
213 @echo "cGHC_SYSMAN_PGM = \"$(GHC_SYSMAN)\"" >> $(CONFIG_HS)
214 @echo "cGHC_SYSMAN_DIR_REL = \"$(GHC_SYSMAN_DIR)\"" >> $(CONFIG_HS)
215 @echo "cGHC_CP = \"$(GHC_CP)\"" >> $(CONFIG_HS)
216 @echo "cGHC_PERL = \"$(GHC_PERL)\"" >> $(CONFIG_HS)
217 ifeq ($(GhcWithIlx),YES)
218 @echo "cILX2IL = \"$(ILX2IL)\"" >> $(CONFIG_HS)
219 @echo "cILASM = \"$(ILASM)\"" >> $(CONFIG_HS)
221 @echo "cEnableWin32DLLs = \"$(EnableWin32DLLs)\"" >> $(CONFIG_HS)
222 @echo "cCONTEXT_DIFF = \"$(CONTEXT_DIFF)\"" >> $(CONFIG_HS)
223 @echo "cUSER_WAY_NAMES = \"$(USER_WAY_NAMES)\"" >> $(CONFIG_HS)
224 @echo "cUSER_WAY_OPTS = \"$(USER_WAY_OPTS)\"" >> $(CONFIG_HS)
225 @echo "cDEFAULT_TMPDIR = \"$(DEFAULT_TMPDIR)\"" >> $(CONFIG_HS)
228 CLEAN_FILES += $(CONFIG_HS)
230 # -----------------------------------------------------------------------------
231 # Create platform includes
233 # Here we generate a little header file containing CPP symbols that GHC
234 # uses to determine which platform it is building on/for. The platforms
235 # can differ between stage1 and stage2 if we're cross-compiling, so we
236 # need one of these header files per stage.
238 PLATFORM_H = ghc_boot_platform.h
240 stage1/$(PLATFORM_H) : $(FPTOOLS_TOP)/mk/config.mk Makefile
241 @echo "Creating $@..."
243 @echo "#ifndef __PLATFORM_H__" >$@
244 @echo "#define __PLATFORM_H__" >>$@
246 @echo "#define BuildPlatform_TYPE $(BuildPlatform_CPP)" >> $@
247 @echo "#define HostPlatform_TYPE $(HostPlatform_CPP)" >> $@
248 @echo "#define TargetPlatform_TYPE $(TargetPlatform_CPP)" >> $@
250 @echo "#define $(BuildPlatform_CPP)_BUILD 1" >> $@
251 @echo "#define $(HostPlatform_CPP)_HOST 1" >> $@
252 @echo "#define $(TargetPlatform_CPP)_TARGET 1" >> $@
254 @echo "#define $(BuildArch_CPP)_BUILD_ARCH 1" >> $@
255 @echo "#define $(HostArch_CPP)_HOST_ARCH 1" >> $@
256 @echo "#define $(TargetArch_CPP)_TARGET_ARCH 1" >> $@
257 @echo "#define BUILD_ARCH \"$(BuildArch_CPP)\"" >> $@
258 @echo "#define HOST_ARCH \"$(HostArch_CPP)\"" >> $@
259 @echo "#define TARGET_ARCH \"$(TargetArch_CPP)\"" >> $@
261 @echo "#define $(BuildOS_CPP)_BUILD_OS 1" >> $@
262 @echo "#define $(HostOS_CPP)_HOST_OS 1" >> $@
263 @echo "#define $(TargetOS_CPP)_TARGET_OS 1" >> $@
264 @echo "#define BUILD_OS \"$(BuildOS_CPP)\"" >> $@
265 @echo "#define HOST_OS \"$(HostOS_CPP)\"" >> $@
266 @echo "#define TARGET_OS \"$(TargetOS_CPP)\"" >> $@
267 ifeq "$(HostOS_CPP)" "irix"
268 @echo "#ifndef $(IRIX_MAJOR)_TARGET_OS " >> $@
269 @echo "#define $(IRIX_MAJOR)_TARGET_OS 1" >> $@
270 @echo "#endif " >> $@
273 @echo "#define $(BuildVendor_CPP)_BUILD_VENDOR 1" >> $@
274 @echo "#define $(HostVendor_CPP)_HOST_VENDOR 1" >> $@
275 @echo "#define $(TargetVendor_CPP)_TARGET_VENDOR 1" >> $@
276 @echo "#define BUILD_VENDOR \"$(BuildVendor_CPP)\"" >> $@
277 @echo "#define HOST_VENDOR \"$(HostVendor_CPP)\"" >> $@
278 @echo "#define TARGET_VENDOR \"$(TargetVendor_CPP)\"" >> $@
280 @echo "#endif /* __PLATFORM_H__ */" >> $@
283 # For stage2 and above, the BUILD platform is the HOST of stage1, and
284 # the HOST platform is the TARGET of stage1. The TARGET remains the same
285 # (stage1 is the cross-compiler, not stage2).
286 stage2/$(PLATFORM_H) : $(FPTOOLS_TOP)/mk/config.mk Makefile
287 @echo "Creating $@..."
289 @echo "#ifndef __PLATFORM_H__" >$@
290 @echo "#define __PLATFORM_H__" >>$@
292 @echo "#define BuildPlatform_TYPE $(HostPlatform_CPP)" >> $@
293 @echo "#define HostPlatform_TYPE $(TargetPlatform_CPP)" >> $@
294 @echo "#define TargetPlatform_TYPE $(TargetPlatform_CPP)" >> $@
296 @echo "#define $(HostPlatform_CPP)_BUILD 1" >> $@
297 @echo "#define $(TargetPlatform_CPP)_HOST 1" >> $@
298 @echo "#define $(TargetPlatform_CPP)_TARGET 1" >> $@
300 @echo "#define $(HostArch_CPP)_BUILD_ARCH 1" >> $@
301 @echo "#define $(TargetArch_CPP)_HOST_ARCH 1" >> $@
302 @echo "#define $(TargetArch_CPP)_TARGET_ARCH 1" >> $@
303 @echo "#define BUILD_ARCH \"$(HostArch_CPP)\"" >> $@
304 @echo "#define HOST_ARCH \"$(TargetArch_CPP)\"" >> $@
305 @echo "#define TARGET_ARCH \"$(TargetArch_CPP)\"" >> $@
307 @echo "#define $(HostOS_CPP)_BUILD_OS 1" >> $@
308 @echo "#define $(TargetOS_CPP)_HOST_OS 1" >> $@
309 @echo "#define $(TargetOS_CPP)_TARGET_OS 1" >> $@
310 @echo "#define BUILD_OS \"$(HostOS_CPP)\"" >> $@
311 @echo "#define HOST_OS \"$(TargetOS_CPP)\"" >> $@
312 @echo "#define TARGET_OS \"$(TargetOS_CPP)\"" >> $@
313 ifeq "$(HostOS_CPP)" "irix"
314 @echo "#ifndef $(IRIX_MAJOR)_TARGET_OS " >> $@
315 @echo "#define $(IRIX_MAJOR)_TARGET_OS 1" >> $@
316 @echo "#endif " >> $@
319 @echo "#define $(HostVendor_CPP)_BUILD_VENDOR 1" >> $@
320 @echo "#define $(TargetVendor_CPP)_HOST_VENDOR 1" >> $@
321 @echo "#define $(TargetVendor_CPP)_TARGET_VENDOR 1" >> $@
322 @echo "#define BUILD_VENDOR \"$(HostVendor_CPP)\"" >> $@
323 @echo "#define HOST_VENDOR \"$(TargetVendor_CPP)\"" >> $@
324 @echo "#define TARGET_VENDOR \"$(TargetVendor_CPP)\"" >> $@
326 @echo "#endif /* __PLATFORM_H__ */" >> $@
329 stage3/$(PLATFORM_H) : stage2/$(PLATFORM_H)
330 $(CP) stage2/$(PLATFORM_H) stage3/$(PLATFORM_H)
332 boot :: stage$(stage)/$(PLATFORM_H)
334 SRC_HC_OPTS += -Istage$(stage)
336 # -----------------------------------------------------------------------------
339 # First figure out ALL_DIRS, the source sub-directories
342 utils basicTypes types hsSyn prelude rename typecheck deSugar coreSyn \
343 specialise simplCore stranal stgSyn simplStg codeGen main \
344 profiling parser cprAnalysis compMan ndpFlatten iface cmm
346 # Make sure we include Config.hs even if it doesn't exist yet...
347 ALL_SRCS += $(CONFIG_HS)
349 # HsGeneric.hs is not used just now
350 EXCLUDED_SRCS += hsSyn/HsGeneric.hs
352 ifeq ($(GhcWithNativeCodeGen),YES)
353 ALL_DIRS += nativeGen
355 SRC_HC_OPTS += -DOMIT_NATIVE_CODEGEN
358 ifeq ($(GhcWithIlx),YES)
363 ifeq ($(GhcWithJavaGen),YES)
365 SRC_HC_OPTS += -DJAVA
368 ifeq "$(BootingFromHc)" "YES"
369 # HC files are always from a self-booted compiler
372 ifneq "$(findstring $(stage), 2 3)" ""
375 bootstrapped = $(shell if (test $(GhcCanonVersion) -ge $(ProjectVersionInt) -a $(GhcPatchLevel) -ge $(ProjectPatchLevel)); then echo YES; else echo NO; fi)
379 # -----------------------------------------------------------------------------
380 # Building a compiler with interpreter support
382 # The interpreter, GHCi interface, and Template Haskell are only
383 # enabled when we are bootstrapping with the same version of GHC, and
384 # the interpreter is supported on this platform.
386 ifeq "$(GhcWithInterpreter) $(bootstrapped)" "YES YES"
388 # Yes, include the interepreter, readline, and Template Haskell extensions
389 SRC_HC_OPTS += -DGHCI -package template-haskell
393 # Enable readline if either:
394 # - we're building stage 1 and $(GhcHasReadline)="YES"
395 # - we're building stage 2/3, and we have built the readline package
397 # But we don't enable readline on Windows, because readline is fairly
400 ifneq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
402 ifeq "$(GhcHasReadline)" "YES"
403 SRC_HC_OPTS += -package readline -DUSE_READLINE
406 ifeq "$(GhcLibsWithReadline)" "YES"
407 SRC_HC_OPTS += -package readline -DUSE_READLINE
414 # No interpreter, so exclude Template Haskell modules
415 EXCLUDED_SRCS += deSugar/DsMeta.hs typecheck/TcSplice.lhs hsSyn/Convert.lhs
417 endif # bootstrapped with interpreter
419 # -----------------------------------------------
422 # Big Fudge to get around inherent problem that Makefile setup
423 # has got with 'mkdependC'.
425 SRC_MKDEPENDC_OPTS += -D__GLASGOW_HASKELL__=$(ProjectVersionInt)
427 # XXX not really correct, hschooks.c actually gets include files like
428 # RtsFlags.c from the installed GHC, but we can't tell mkdependC about that.
429 SRC_MKDEPENDC_OPTS += -I$(GHC_INCLUDE_DIR)
431 # -----------------------------------------------------------------------------
432 # Haskell compilations
435 -cpp -fglasgow-exts -fno-generics -Rghc-timing \
436 -I. -IcodeGen -InativeGen -Iparser
438 # Omitted: -I$(GHC_INCLUDE_DIR)
439 # We should have -I$(GHC_INCLUDE_DIR) in SRC_HC_OPTS,
440 # to avoid the use of an explicit path in GHC source files
441 # (include "../includes/config.h"
442 # But alas GHC 4.08 (and others for all I know) uses this very
443 # same include path when compiling the .hc files it generates.
444 # Disaster! Then the hc file sees the GHC 5.02 (or whatever)
445 # include files. For the moment we've reverted to using
446 # an explicit path in the .hs sources
448 # For the benefit of <5.00 compilers, do include GHC_INCLUDE_DIR
449 # when generating dependencies. (=> it gets passed onto mkdependHS,
451 SRC_MKDEPENDHS_OPTS += -I$(GHC_INCLUDE_DIR)
453 # We need System.Posix (or Posix when ghc < 6.2)
454 ifneq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
455 ifeq "$(bootstrapped) $(ghc_ge_601)" "NO NO"
456 SRC_HC_OPTS += -package posix
458 SRC_HC_OPTS += -package unix
462 ifneq "$(findstring YES, $(bootstrapped) $(ghc_ge_603))" ""
463 SRC_HC_OPTS += -package Cabal
466 SRC_CC_OPTS += -Iparser -I. -O
467 SRC_HC_OPTS += -recomp $(GhcHcOpts) $(GhcStage$(stage)HcOpts)
470 ifeq "$(BootingFromHc)" "YES"
471 SRC_CC_OPTS += -D__GLASGOW_HASKELL__=$(ProjectVersionInt)
474 # Special flags for particular modules
475 # The standard suffix rule for compiling a Haskell file
476 # adds these flags to the command line
478 # There used to be a -no-recomp flag on PrimOp, but why?
479 # It's an expensive module to recompile!
480 prelude/PrimOp_HC_OPTS = -H80m
482 # because the NCG can't handle the 64-bit math in here
483 prelude/PrelRules_HC_OPTS = -fvia-C
485 main/ParsePkgConf_HC_OPTS += -fno-warn-incomplete-patterns
486 # Use -fvia-C since the NCG can't handle the narrow16Int# (and intToInt16#?)
487 # primops on all platforms.
488 parser/Parser_HC_OPTS += -fno-warn-incomplete-patterns -fvia-C
490 # Careful optimisation of the parser: we don't want to throw everything
491 # at it, because that takes too long and doesn't buy much, but we do want
492 # to inline certain key external functions, so we instruct GHC not to
493 # throw away inlinings as it would normally do in -Onot mode:
494 parser/Parser_HC_OPTS += -Onot -fno-ignore-interface-pragmas
496 ifeq "$(HOSTPLATFORM)" "hppa1.1-hp-hpux9"
497 rename/RnMonad_HC_OPTS = -O2 -O2-for-C
500 utils/Digraph_HC_OPTS = -fglasgow-exts
502 basicTypes/SrcLoc_HC_OPTS = -funbox-strict-fields
504 ifeq "$(bootstrapped)" "YES"
505 utils/Binary_HC_OPTS = -funbox-strict-fields
508 # ByteCodeItbls uses primops that the NCG doesn't support yet.
509 ghci/ByteCodeItbls_HC_OPTS += -fvia-C
510 ghci/ByteCodeLink_HC_OPTS += -fvia-C -monly-3-regs
512 # BinIface and Binary take ages to both compile and run if you don's use -O
513 main/BinIface_HC_OPTS += -O
514 utils/Binary_HC_OPTS += -O
515 utils/FastMutInt_HC_OPTS += -O
518 # CSE interacts badly with top-level IORefs (reportedly in DriverState and
519 # DriverMkDepend), causing some of them to be commoned up. We have a fix for
520 # this in 5.00+, but earlier versions of the compiler will need CSE turned off.
521 # To be on the safe side, we disable CSE in *all* modules with top-level IORefs.
522 compMan/CompManager_HC_OPTS = -fno-cse
523 ghci/InteractiveUI_HC_OPTS = -fno-cse
524 main/CmdLineOpts_HC_OPTS = -fno-cse
525 main/DriverFlags_HC_OPTS = -fno-cse
526 main/DriverMkDepend_HC_OPTS = -fno-cse
527 main/DriverPipeline_HC_OPTS = -fno-cse
528 main/DriverState_HC_OPTS = -fno-cse
529 main/DriverUtil_HC_OPTS = -fno-cse
530 main/Finder_HC_OPTS = -fno-cse
531 main/SysTools_HC_OPTS = -fno-cse
533 # The #include is vital for the via-C route, else the C
534 # compiler doesn't realise that the stcall foreign imports are indeed
535 # stdcall, and doesn't generate the Foo@8 name for them
536 ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
537 main/SysTools_HC_OPTS += '-\#include <windows.h>' '-\#include <process.h>'
540 parser/Lexer_HC_OPTS += -funbox-strict-fields
542 # ghc_strlen percolates through so many modules that it is easier to get its
543 # prototype via a global option instead of a myriad of per-file OPTIONS
544 SRC_HC_OPTS += '-\#include "hschooks.h"'
546 # ----------------------------------------------------------------------------
547 # Generate supporting stuff for prelude/PrimOp.lhs
548 # from prelude/primops.txt
550 GENPOC=$(TOP)/utils/genprimopcode/genprimopcode
552 PRIMOP_BITS=primop-data-decl.hs-incl \
554 primop-list.hs-incl \
555 primop-has-side-effects.hs-incl \
556 primop-out-of-line.hs-incl \
557 primop-commutable.hs-incl \
558 primop-needs-wrapper.hs-incl \
559 primop-can-fail.hs-incl \
560 primop-strictness.hs-incl \
561 primop-primop-info.hs-incl
563 CLEAN_FILES += prelude/primops.txt
564 CLEAN_FILES += $(PRIMOP_BITS)
566 SRC_CPP_OPTS += -I$(GHC_INCLUDE_DIR)
567 SRC_CPP_OPTS += ${GhcCppOpts}
569 ifneq "$(BootingFromHc)" "YES"
570 prelude/PrimOp.lhs $(odir)/prelude/PrimOp.o: $(PRIMOP_BITS)
573 ifneq "$(BootingFromHc)" "YES"
574 depend :: $(PRIMOP_BITS)
577 primop-data-decl.hs-incl: prelude/primops.txt
578 $(GENPOC) --data-decl < $< > $@
579 primop-tag.hs-incl: prelude/primops.txt
580 $(GENPOC) --primop-tag < $< > $@
581 primop-list.hs-incl: prelude/primops.txt
582 $(GENPOC) --primop-list < $< > $@
583 primop-has-side-effects.hs-incl: prelude/primops.txt
584 $(GENPOC) --has-side-effects < $< > $@
585 primop-out-of-line.hs-incl: prelude/primops.txt
586 $(GENPOC) --out-of-line < $< > $@
587 primop-commutable.hs-incl: prelude/primops.txt
588 $(GENPOC) --commutable < $< > $@
589 primop-needs-wrapper.hs-incl: prelude/primops.txt
590 $(GENPOC) --needs-wrapper < $< > $@
591 primop-can-fail.hs-incl: prelude/primops.txt
592 $(GENPOC) --can-fail < $< > $@
593 primop-strictness.hs-incl: prelude/primops.txt
594 $(GENPOC) --strictness < $< > $@
595 primop-primop-info.hs-incl: prelude/primops.txt
596 $(GENPOC) --primop-primop-info < $< > $@
598 # Usages aren't used any more; but the generator
599 # can still generate them if we want them back
600 primop-usage.hs-incl: prelude/primops.txt
601 $(GENPOC) --usage < $< > $@
604 #-----------------------------------------------------------------------------
607 # Include libghccompat in stage1 only. In stage2 onwards, all these
608 # libraries will be available from the main libraries.
610 SRC_HC_OPTS += -i$(GHC_LIB_COMPAT_DIR)
611 SRC_LD_OPTS += -L$(GHC_LIB_COMPAT_DIR) -lghccompat
613 ifeq "$(Windows)" "YES"
614 # not very nice, but required for -lghccompat on Windows
615 SRC_LD_OPTS += -lshell32
618 # This is horrible. We ought to be able to omit the entire directory
620 SRC_MKDEPENDHS_OPTS += \
621 -optdep--exclude-module=Compat.RawSystem \
622 -optdep--exclude-module=Compat.Directory \
623 -optdep--exclude-module=Distribution.Compat.ReadP \
624 -optdep--exclude-module=Distribution.Extension \
625 -optdep--exclude-module=Distribution.GetOpt \
626 -optdep--exclude-module=Distribution.InstalledPackageInfo \
627 -optdep--exclude-module=Distribution.License \
628 -optdep--exclude-module=Distribution.Package \
629 -optdep--exclude-module=Distribution.ParseUtils \
630 -optdep--exclude-module=Distribution.Setup \
631 -optdep--exclude-module=Distribution.Version \
632 -optdep--exclude-module=System.Directory.Internals
635 SRC_LD_OPTS += -no-link-chk
637 # -----------------------------------------------------------------------------
638 # create ghc-inplace, a convenient way to run ghc from the build tree...
640 all :: $(odir)/ghc-inplace ghc-inplace
642 $(odir)/ghc-inplace : $(HS_PROG)
644 echo '#!/bin/sh' >>$@
645 echo exec $(FPTOOLS_TOP_ABS)/ghc/compiler/$(HS_PROG) '-B$(subst \,\\,$(FPTOOLS_TOP_ABS_PLATFORM))' '"$$@"' >>$@
648 ghc-inplace : stage1/ghc-inplace
651 CLEAN_FILES += $(odir)/ghc-inplace ghc-inplace
653 #-----------------------------------------------------------------------------
656 # We don't want ghc treated as an ordinary executable,
657 # but put it together with the libraries.
658 # Also don't want any interface files installed
660 DESTDIR = $(INSTALL_LIBRARY_DIR_GHC)
662 ifneq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
663 INSTALL_LIBEXECS += $(HS_PROG)
665 INSTALL_PROGS += $(HS_PROG)
668 # ----------------------------------------------------------------------------
671 # rename/RnBinds_HC_OPTS += -auto-all
672 # rename/RnEnv_HC_OPTS += -auto-all
673 # rename/RnExpr_HC_OPTS += -auto-all
674 # rename/RnHiFiles_HC_OPTS += -auto-all
675 # rename/RnHsSyn_HC_OPTS += -auto-all
676 # rename/Rename_HC_OPTS += -auto-all
677 # rename/RnIfaces_HC_OPTS += -auto-all
678 # rename/RnNames_HC_OPTS += -auto-all
679 # rename/RnSource_HC_OPTS += -auto-all
680 # rename/RnTypes_HC_OPTS += -auto-all
682 # typecheck/Inst_HC_OPTS += -auto-all
683 # typecheck/TcBinds_HC_OPTS += -auto-all
684 # typecheck/TcClassDcl_HC_OPTS += -auto-all
685 # typecheck/TcDefaults_HC_OPTS += -auto-all
686 # typecheck/TcDeriv_HC_OPTS += -auto-all
687 # typecheck/TcEnv_HC_OPTS += -auto-all
688 # typecheck/TcExpr_HC_OPTS += -auto-all
689 # typecheck/TcForeign_HC_OPTS += -auto-all
690 # typecheck/TcGenDeriv_HC_OPTS += -auto-all
691 # typecheck/TcHsSyn_HC_OPTS += -auto-all
692 # typecheck/TcIfaceSig_HC_OPTS += -auto-all
693 # typecheck/TcInstDcls_HC_OPTS += -auto-all
694 # typecheck/TcMatches_HC_OPTS += -auto-all
695 # typecheck/TcMonoType_HC_OPTS += -auto-all
696 # typecheck/TcMType_HC_OPTS += -auto-all
697 # typecheck/TcPat_HC_OPTS += -auto-all
698 # typecheck/TcRnDriver_HC_OPTS += -auto-all
699 # #typecheck/TcRnMonad_HC_OPTS += -auto-all
700 # #typecheck/TcRnTypes_HC_OPTS += -auto-all
701 # typecheck/TcRules_HC_OPTS += -auto-all
702 # typecheck/TcSimplify_HC_OPTS += -auto-all
703 # typecheck/TcSplice_HC_OPTS += -auto-all
704 # typecheck/TcTyClsDecls_HC_OPTS += -auto-all
705 # typecheck/TcTyDecls_HC_OPTS += -auto-all
706 # typecheck/TcType_HC_OPTS += -auto-all
707 # typecheck/TcUnify_HC_OPTS += -auto-all
709 coreSyn/CorePrep_HC_OPTS += -auto-all
711 #-----------------------------------------------------------------------------
712 # Building GHC package
714 ifeq "$(BuildPackageGHC)" "YES"
717 STANDALONE_PACKAGE = YES
722 #-----------------------------------------------------------------------------
725 MAINTAINER_CLEAN_FILES += parser/Parser.info main/ParsePkgConf.info
727 #-----------------------------------------------------------------------------
728 # Include target-rule boilerplate
730 # Don't use the default MKDEPENDHS stuff... we'll do our own, below
734 # Make doesn't work this out for itself, it seems
735 parser/Parser.y : parser/Parser.y.pp
736 EXTRA_SRCS += parser/Parser.y
739 #-----------------------------------------------------------------------------
740 # Source files for tags file generation
742 # We want to excluded derived sources, because they won't be in the source
743 # tree, which is where we are going to move the TAGS file to.a
745 TAGS_HS_SRCS = parser/Parser.y.pp $(filter-out $(DERIVED_SRCS) main/Config.hs parser/Parser.y, $(sort $(SRCS)))
748 include $(TOP)/mk/target.mk
750 # -----------------------------------------------------------------------------
753 MKDEPENDHS_HC_OPTS = $(patsubst -i$(odir)/%, -i%, $(HC_OPTS))
757 # Must do this *after* including target.mk, because $(HS_SRCS) isn't set yet.
758 depend :: $(HS_SRCS) $(C_SRCS)
760 ifneq "$(BootingFromHc)" "YES"
761 $(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)
763 $(MKDEPENDC) -f .depend-BASE $(MKDEPENDC_OPTS) $(foreach way,$(WAYS),-s $(way)) -- $(CC_OPTS) -- $(C_SRCS)
764 $(PERL) -pe 'binmode(stdin); binmode(stdout); s@^(\S*\.o)@stage$(stage)/$$1@g; s@(\S*\.hi)@stage$(stage)/$$1@g' <.depend-BASE >.depend-$(stage)
765 # The binmode stuff tells perl not to add stupid ^M's to the output
767 -include .depend-$(stage)