Add {-# OPTIONS_GHC -w #-} and some blurb to all compiler modules
[ghc.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 # Use GHC for compiling C bits (NB. must be before boilerplate include)
21 #
22 UseGhcForCc = YES
23
24 include $(TOP)/mk/boilerplate.mk
25
26 ifeq "$(GhcThreaded)$(GhcProfiled)" "YESYES"
27 $(error Cannot make GHC both threaded and profiled)
28 endif
29
30
31 #-----------------------------------------------------------------------------
32 # Counting source code lines
33
34 USER_SRCS = $(filter-out $(DERIVED_SRCS),$(SRCS))
35 count :
36 ./count_lines $(USER_SRCS)
37
38 # -----------------------------------------------------------------------------
39 # Bootstrapping
40
41 # The stage1/stage2/stage3 business is quite delicate. Here's how it works:
42 #
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.
45 # N defaults to 1.
46 #
47 # - for stage N, object files and .hi files are placed inside
48 # the directory stageN, in subdirectories as per the sources.
49 #
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.
52 #
53 # - we use explicit -o and -ohi options to direct the output from C &
54 # Haskell compilations.
55 #
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.
62 #
63 # - normal implicit rules don't work any more, because they're of the form
64 #
65 # %.o : %.hs
66 #
67 # whereas we really need
68 #
69 # stageN/%.o : %.hs
70 #
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.
74 #
75 # There are other plausible designs that might work, but each has different
76 # problems:
77 #
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.
82 #
83 # - invoke make in the stageN subdirectory. This probably requires VPATH
84 # too.
85 #
86 # - create a link tree. The problem with requiring link trees is that
87 # Windows doesn't support symbolic links.
88
89 ifeq "$(stage)" ""
90 stage=1
91 endif
92
93 ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
94 ifeq "$(stage)" "1"
95 DQ = \"
96 else
97 DQ = \\\"
98 endif
99 else
100 DQ = \"
101 endif
102
103 .DUMMY: stage_dir
104 stage_dirs :
105 $(MKDIRHIER) stage$(stage)
106 for i in $(ALL_DIRS); do \
107 $(MKDIRHIER) stage$(stage)/$$i; \
108 done
109
110 ifeq "$(stage) $(ghc_ge_603)" "1 YES"
111 UsingHsBoot = YES
112 else
113 ifneq "$(findstring $(stage), 2 3)" ""
114 UsingHsBoot = YES
115 else
116 UsingHsBoot = NO
117 endif
118 endif
119
120 boot :: stage_dirs
121 # On Windows, we can't use symbolic links for the -hi-boot files
122 # because GHC itself is a Mingw program and does not understand
123 # symbolic links. So we have to copy the files instead of link them.
124 # That means that if you modify a .hi-boot file in Windows, you
125 # have to to say 'make boot' again.
126 #
127 # PS: 'ln -s foo baz' takes 'foo' relative to the path to 'baz'
128 # whereas 'cp foo baz' treats the two paths independently.
129 # Hence the "../.." in the ln command line
130 ifeq "$(UsingHsBoot)" "NO"
131 ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
132 for i in */*hi-boot*; do \
133 cp -u -f $$i stage$(stage)/$$i; \
134 done
135 else
136 for i in */*hi-boot*; do \
137 ($(RM) -f stage$(stage)/$$i \
138 && $(LN_S) ../../$$i stage$(stage)/$$i) || true ; \
139 done
140 endif
141 endif
142
143 ifeq "$(stage)" "1"
144 HC=$(GHC)
145 endif
146
147 ifeq "$(stage)" "2"
148 HC=$(GHC_STAGE1)
149 endif
150
151 ifeq "$(stage)" "3"
152 HC=$(GHC_STAGE2)
153 endif
154
155 stage1 ::
156 $(MAKE) stage=1
157
158 stage2 ::
159 $(MAKE) stage=2
160
161 stage3 ::
162 $(MAKE) stage=3
163
164 odir=stage$(stage)
165
166 SRC_HC_OPTS += $(patsubst %, -i$(odir)/%, $(ALL_DIRS))
167
168 HS_OBJS = $(patsubst %, $(odir)/%, $(addsuffix .$(way_)o,$(basename $(HS_SRCS))))
169 C_OBJS = $(patsubst %, $(odir)/%, $(addsuffix .$(way_)o,$(basename $(C_SRCS))))
170
171 # Our standard cleaning rules don't know that we're doing our output
172 # into $(odir), so we have to augment CLEAN_FILES appropriateliy.
173
174 CLEAN_FILES += $(odir)/*/*.hi $(odir)/*/*.hi-boot $(odir)/*/*.o-boot
175
176 ifeq "$(UsingHsBoot)" "YES"
177 CLEAN_FILES += $(odir)/*/*.hi-boot $(odir)/*/*.o-boot
178 endif
179
180 ifeq "$(stage)" "1"
181 mostlyclean clean distclean maintainer-clean ::
182 $(MAKE) $@ stage=2
183 $(MAKE) $@ stage=3
184 endif
185
186 # -----------------------------------------------------------------------------
187 # Set HS_PROG
188
189 # Note: there have been reports of people running up against the ARG_MAX limit
190 # when linking ghc with all its constituent object files. The likely source of
191 # the problem is that the environment is a bit too big, so a workaround could
192 # be to do `env PATH=$(PATH) make ghc' to minimise the environment. (or the
193 # equivalent of `env' if it doesn't exist locally).
194 #
195 ifneq "$(way)" "dll"
196 ifneq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
197 GHC_PROG=$(odir)/ghc$(_way)-$(ProjectVersion)
198 else
199 GHC_PROG=$(odir)/ghc$(_way)
200 endif
201 else
202 GHC_PROG=$(odir)/ghc-$(ProjectVersion)
203 endif
204
205 ifeq "$(stage)" "1"
206 HS_PROG = $(GHC_PROG)
207 endif
208
209 # -----------------------------------------------------------------------------
210 # Create compiler configuration
211 #
212 # The 'echo' commands simply spit the values of various make variables
213 # into Config.hs, whence they can be compiled and used by GHC itself
214
215 CONFIG_HS = main/Config.hs
216 boot :: $(CONFIG_HS)
217
218 $(CONFIG_HS) : $(FPTOOLS_TOP)/mk/config.mk
219 @$(RM) -f $(CONFIG_HS)
220 @echo "Creating $(CONFIG_HS) ... "
221 @echo "{-# OPTIONS_GHC -w #-}" >>$(CONFIG_HS)
222 @echo "module Config where" >>$(CONFIG_HS)
223 @echo "cProjectName = \"$(ProjectName)\"" >> $(CONFIG_HS)
224 @echo "cProjectVersion = \"$(ProjectVersion)\"" >> $(CONFIG_HS)
225 @echo "cProjectVersionInt = \"$(ProjectVersionInt)\"" >> $(CONFIG_HS)
226 @echo "cProjectPatchLevel = \"$(ProjectPatchLevel)\"" >> $(CONFIG_HS)
227 @echo "cBooterVersion = \"$(GhcVersion)\"" >> $(CONFIG_HS)
228 @echo "cStage = STAGE" >> $(CONFIG_HS)
229 @echo "cHscIfaceFileVersion = \"$(HscIfaceFileVersion)\"" >> $(CONFIG_HS)
230 @echo "cSplitObjs = \"$(SplitObjs)\"" >> $(CONFIG_HS)
231 @echo "cGhcWithInterpreter = \"$(GhcWithInterpreter)\"" >> $(CONFIG_HS)
232 @echo "cGhcWithNativeCodeGen = \"$(GhcWithNativeCodeGen)\"" >> $(CONFIG_HS)
233 @echo "cGhcWithSMP = \"$(GhcWithSMP)\"" >> $(CONFIG_HS)
234 @echo "cGhcRTSWays = \"$(GhcRTSWays)\"" >> $(CONFIG_HS)
235 @echo "cGhcUnregisterised = \"$(GhcUnregisterised)\"" >> $(CONFIG_HS)
236 @echo "cGhcEnableTablesNextToCode = \"$(GhcEnableTablesNextToCode)\"" >> $(CONFIG_HS)
237 @echo "cLeadingUnderscore = \"$(LeadingUnderscore)\"" >> $(CONFIG_HS)
238 @echo "cRAWCPP_FLAGS = \"$(RAWCPP_FLAGS)\"" >> $(CONFIG_HS)
239 @echo "cGCC = \"$(WhatGccIsCalled)\"" >> $(CONFIG_HS)
240 @echo "cMKDLL = \"$(BLD_DLL)\"" >> $(CONFIG_HS)
241 @echo "cLdIsGNULd = \"$(LdIsGNULd)\"" >> $(CONFIG_HS)
242 @echo "cLD_X = \"$(LD_X)\"" >> $(CONFIG_HS)
243 @echo "cPROJECT_DIR = \"$(PROJECT_DIR)\"" >> $(CONFIG_HS)
244 @echo "cGHC_DRIVER_DIR_REL = \"$(GHC_DRIVER_DIR_REL)\"" >> $(CONFIG_HS)
245 @echo "cGHC_TOUCHY_PGM = \"$(GHC_TOUCHY_PGM)\"" >> $(CONFIG_HS)
246 @echo "cGHC_TOUCHY_DIR_REL = \"$(GHC_TOUCHY_DIR_REL)\"" >> $(CONFIG_HS)
247 @echo "cGHC_UNLIT_PGM = \"$(GHC_UNLIT_PGM)\"" >> $(CONFIG_HS)
248 @echo "cGHC_UNLIT_DIR_REL = \"$(GHC_UNLIT_DIR_REL)\"" >> $(CONFIG_HS)
249 @echo "cGHC_MANGLER_PGM = \"$(GHC_MANGLER_PGM)\"" >> $(CONFIG_HS)
250 @echo "cGHC_MANGLER_DIR_REL = \"$(GHC_MANGLER_DIR_REL)\"" >> $(CONFIG_HS)
251 @echo "cGHC_SPLIT_PGM = \"$(GHC_SPLIT_PGM)\"" >> $(CONFIG_HS)
252 @echo "cGHC_SPLIT_DIR_REL = \"$(GHC_SPLIT_DIR_REL)\"" >> $(CONFIG_HS)
253 @echo "cGHC_SYSMAN_PGM = \"$(GHC_SYSMAN)\"" >> $(CONFIG_HS)
254 @echo "cGHC_SYSMAN_DIR_REL = \"$(GHC_SYSMAN_DIR)\"" >> $(CONFIG_HS)
255 @echo "cGHC_CP = \"$(GHC_CP)\"" >> $(CONFIG_HS)
256 @echo "cGHC_PERL = \"$(GHC_PERL)\"" >> $(CONFIG_HS)
257 ifeq ($(GhcWithIlx),YES)
258 @echo "cILX2IL = \"$(ILX2IL)\"" >> $(CONFIG_HS)
259 @echo "cILASM = \"$(ILASM)\"" >> $(CONFIG_HS)
260 endif
261 @echo "cEnableWin32DLLs = \"$(EnableWin32DLLs)\"" >> $(CONFIG_HS)
262 @echo "cCONTEXT_DIFF = \"$(CONTEXT_DIFF)\"" >> $(CONFIG_HS)
263 @echo "cUSER_WAY_NAMES = \"$(USER_WAY_NAMES)\"" >> $(CONFIG_HS)
264 @echo "cUSER_WAY_OPTS = \"$(USER_WAY_OPTS)\"" >> $(CONFIG_HS)
265 @echo "cDEFAULT_TMPDIR = \"$(DEFAULT_TMPDIR)\"" >> $(CONFIG_HS)
266 @echo "cDocDir = \"$(docdir)\"" >> $(CONFIG_HS)
267 @echo done.
268
269 CLEAN_FILES += $(CONFIG_HS)
270
271 # -----------------------------------------------------------------------------
272 # Create platform includes
273
274 # Here we generate a little header file containing CPP symbols that GHC
275 # uses to determine which platform it is building on/for. The platforms
276 # can differ between stage1 and stage2 if we're cross-compiling, so we
277 # need one of these header files per stage.
278
279 PLATFORM_H = ghc_boot_platform.h
280
281 stage1/$(PLATFORM_H) : stage_dirs $(FPTOOLS_TOP)/mk/config.mk
282 @echo "Creating $@..."
283 @$(RM) $@
284 @echo "#ifndef __PLATFORM_H__" >$@
285 @echo "#define __PLATFORM_H__" >>$@
286 @echo >> $@
287 @echo "#define BuildPlatform_NAME \"$(BUILDPLATFORM)\"" >> $@
288 @echo "#define HostPlatform_NAME \"$(HOSTPLATFORM)\"" >> $@
289 @echo "#define TargetPlatform_NAME \"$(TARGETPLATFORM)\"" >> $@
290 @echo >> $@
291 @echo "#define $(BuildPlatform_CPP)_BUILD 1" >> $@
292 @echo "#define $(HostPlatform_CPP)_HOST 1" >> $@
293 @echo "#define $(TargetPlatform_CPP)_TARGET 1" >> $@
294 @echo >> $@
295 @echo "#define $(BuildArch_CPP)_BUILD_ARCH 1" >> $@
296 @echo "#define $(HostArch_CPP)_HOST_ARCH 1" >> $@
297 @echo "#define $(TargetArch_CPP)_TARGET_ARCH 1" >> $@
298 @echo "#define BUILD_ARCH \"$(BuildArch_CPP)\"" >> $@
299 @echo "#define HOST_ARCH \"$(HostArch_CPP)\"" >> $@
300 @echo "#define TARGET_ARCH \"$(TargetArch_CPP)\"" >> $@
301 @echo >> $@
302 @echo "#define $(BuildOS_CPP)_BUILD_OS 1" >> $@
303 @echo "#define $(HostOS_CPP)_HOST_OS 1" >> $@
304 @echo "#define $(TargetOS_CPP)_TARGET_OS 1" >> $@
305 @echo "#define BUILD_OS \"$(BuildOS_CPP)\"" >> $@
306 @echo "#define HOST_OS \"$(HostOS_CPP)\"" >> $@
307 @echo "#define TARGET_OS \"$(TargetOS_CPP)\"" >> $@
308 ifeq "$(HostOS_CPP)" "irix"
309 @echo "#ifndef $(IRIX_MAJOR)_TARGET_OS " >> $@
310 @echo "#define $(IRIX_MAJOR)_TARGET_OS 1" >> $@
311 @echo "#endif " >> $@
312 endif
313 @echo >> $@
314 @echo "#define $(BuildVendor_CPP)_BUILD_VENDOR 1" >> $@
315 @echo "#define $(HostVendor_CPP)_HOST_VENDOR 1" >> $@
316 @echo "#define $(TargetVendor_CPP)_TARGET_VENDOR 1" >> $@
317 @echo "#define BUILD_VENDOR \"$(BuildVendor_CPP)\"" >> $@
318 @echo "#define HOST_VENDOR \"$(HostVendor_CPP)\"" >> $@
319 @echo "#define TARGET_VENDOR \"$(TargetVendor_CPP)\"" >> $@
320 @echo >> $@
321 @echo "#endif /* __PLATFORM_H__ */" >> $@
322 @echo "Done."
323
324 # For stage2 and above, the BUILD platform is the HOST of stage1, and
325 # the HOST platform is the TARGET of stage1. The TARGET remains the same
326 # (stage1 is the cross-compiler, not stage2).
327 stage2/$(PLATFORM_H) : stage_dirs $(FPTOOLS_TOP)/mk/config.mk
328 @echo "Creating $@..."
329 @$(RM) $@
330 @echo "#ifndef __PLATFORM_H__" >$@
331 @echo "#define __PLATFORM_H__" >>$@
332 @echo >> $@
333 @echo "#define BuildPlatform_NAME \"$(HOSTPLATFORM)\"" >> $@
334 @echo "#define HostPlatform_NAME \"$(TARGETPLATFORM)\"" >> $@
335 @echo "#define TargetPlatform_NAME \"$(TARGETPLATFORM)\"" >> $@
336 @echo >> $@
337 @echo "#define $(HostPlatform_CPP)_BUILD 1" >> $@
338 @echo "#define $(TargetPlatform_CPP)_HOST 1" >> $@
339 @echo "#define $(TargetPlatform_CPP)_TARGET 1" >> $@
340 @echo >> $@
341 @echo "#define $(HostArch_CPP)_BUILD_ARCH 1" >> $@
342 @echo "#define $(TargetArch_CPP)_HOST_ARCH 1" >> $@
343 @echo "#define $(TargetArch_CPP)_TARGET_ARCH 1" >> $@
344 @echo "#define BUILD_ARCH \"$(HostArch_CPP)\"" >> $@
345 @echo "#define HOST_ARCH \"$(TargetArch_CPP)\"" >> $@
346 @echo "#define TARGET_ARCH \"$(TargetArch_CPP)\"" >> $@
347 @echo >> $@
348 @echo "#define $(HostOS_CPP)_BUILD_OS 1" >> $@
349 @echo "#define $(TargetOS_CPP)_HOST_OS 1" >> $@
350 @echo "#define $(TargetOS_CPP)_TARGET_OS 1" >> $@
351 @echo "#define BUILD_OS \"$(HostOS_CPP)\"" >> $@
352 @echo "#define HOST_OS \"$(TargetOS_CPP)\"" >> $@
353 @echo "#define TARGET_OS \"$(TargetOS_CPP)\"" >> $@
354 ifeq "$(HostOS_CPP)" "irix"
355 @echo "#ifndef $(IRIX_MAJOR)_TARGET_OS " >> $@
356 @echo "#define $(IRIX_MAJOR)_TARGET_OS 1" >> $@
357 @echo "#endif " >> $@
358 endif
359 @echo >> $@
360 @echo "#define $(HostVendor_CPP)_BUILD_VENDOR 1" >> $@
361 @echo "#define $(TargetVendor_CPP)_HOST_VENDOR 1" >> $@
362 @echo "#define $(TargetVendor_CPP)_TARGET_VENDOR 1" >> $@
363 @echo "#define BUILD_VENDOR \"$(HostVendor_CPP)\"" >> $@
364 @echo "#define HOST_VENDOR \"$(TargetVendor_CPP)\"" >> $@
365 @echo "#define TARGET_VENDOR \"$(TargetVendor_CPP)\"" >> $@
366 @echo >> $@
367 @echo "#endif /* __PLATFORM_H__ */" >> $@
368 @echo "Done."
369
370 stage3/$(PLATFORM_H) : stage_dirs stage2/$(PLATFORM_H)
371 $(CP) stage2/$(PLATFORM_H) stage3/$(PLATFORM_H)
372
373 STAGE_PLATFORM_H = stage$(stage)/$(PLATFORM_H)
374
375 boot :: $(STAGE_PLATFORM_H)
376
377 SRC_HC_OPTS += -Istage$(stage)
378
379 # -----------------------------------------------------------------------------
380 # Set SRCS etc.
381 #
382 # First figure out ALL_DIRS, the source sub-directories
383
384 ALL_DIRS = \
385 utils basicTypes types hsSyn prelude rename typecheck deSugar coreSyn \
386 vectorise specialise simplCore stranal stgSyn simplStg codeGen main \
387 profiling parser cprAnalysis ndpFlatten iface cmm
388
389 # Make sure we include Config.hs even if it doesn't exist yet...
390 ALL_SRCS += $(CONFIG_HS)
391
392 # HsGeneric.hs is not used just now
393 EXCLUDED_SRCS += hsSyn/HsGeneric.hs
394
395 ifeq ($(GhcWithNativeCodeGen),YES)
396 ALL_DIRS += nativeGen
397 else
398 SRC_HC_OPTS += -DOMIT_NATIVE_CODEGEN
399 endif
400
401 ifeq ($(GhcWithIlx),YES)
402 ALL_DIRS += ilxGen
403 SRC_HC_OPTS += -DILX
404 endif
405
406 ifeq ($(GhcWithJavaGen),YES)
407 ALL_DIRS += javaGen
408 SRC_HC_OPTS += -DJAVA
409 endif
410
411 ifeq "$(BootingFromHc)" "YES"
412 # HC files are always from a self-booted compiler
413 bootstrapped = YES
414 else
415 ifneq "$(findstring $(stage), 2 3)" ""
416 bootstrapped = YES
417 else
418 bootstrapped = NO
419 endif
420 endif
421
422 # -----------------------------------------------------------------------------
423 # Building a compiler with interpreter support
424 #
425 # The interpreter, GHCi interface, Template Haskell and Hpc are only
426 # enabled when we are bootstrapping with the same version of GHC, and
427 # the interpreter is supported on this platform.
428
429 ifeq "$(bootstrapped)" "YES"
430 SRC_HC_OPTS += -package hpc -package bytestring
431 PKG_DEPENDS += hpc bytestring
432 endif
433
434 ifeq "$(GhcWithInterpreter) $(bootstrapped)" "YES YES"
435
436 # Yes, include the interepreter, readline, and Template Haskell extensions
437 SRC_HC_OPTS += -DGHCI -package template-haskell
438 PKG_DEPENDS += template-haskell
439
440 # Should GHCI be building info tables in the TABLES_NEXT_TO_CODE style
441 # or not?
442 ifeq "$(GhcEnableTablesNextToCode) $(GhcUnregisterised)" "YES NO"
443 SRC_HC_OPTS += -DGHCI_TABLES_NEXT_TO_CODE
444 endif
445
446 ifeq "$(GhcThreaded)" "YES"
447 # Use threaded RTS with GHCi, so threads don't get blocked at the prompt.
448 SRC_LD_OPTS += -threaded
449 endif
450 ifeq "$(GhcProfiled)" "YES"
451 SRC_LD_OPTS += -prof
452 endif
453 ifeq "$(GhcDebugged)" "YES"
454 SRC_LD_OPTS += -debug
455 endif
456
457 ALL_DIRS += ghci
458
459 # If we are going to use dynamic libraries instead of .o files for ghci,
460 # we will need to always retain CAFs in the compiler.
461 # ghci/keepCAFsForGHCi contains a GNU C __attribute__((constructor))
462 # function which sets the keepCAFs flag for the RTS before any Haskell
463 # code is run.
464 ifeq "$(GhcBuildDylibs)" "YES"
465 else
466 EXCLUDED_SRCS += ghci/keepCAFsForGHCi.c
467 endif
468
469 # Enable readline if either:
470 # - we're building stage 1 and $(GhcHasReadline)="YES"
471 # - we're building stage 2/3, and we have built the readline package
472 #
473 # But we don't enable readline on Windows, because readline is fairly
474 # broken there.
475 #
476 ifneq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
477 ifeq "$(stage)" "1"
478 ifeq "$(GhcHasReadline)" "YES"
479 SRC_HC_OPTS += -package readline -DUSE_READLINE
480 PKG_DEPENDS += readline
481 endif
482 else
483 -include $(FPTOOLS_TOP)/libraries/readline/config.mk
484 # readline's config.mk sets PACKAGE, which we don't want here
485 PACKAGE=
486 ifeq "$(READLINE_BUILD_PACKAGE)" "yes"
487 SRC_HC_OPTS += -package readline -DUSE_READLINE
488 PKG_DEPENDS += readline
489 endif
490 endif # stage=1
491 endif # not windows
492
493 else
494
495 # No interpreter, so exclude Template Haskell modules
496 EXCLUDED_SRCS += deSugar/DsMeta.hs typecheck/TcSplice.lhs hsSyn/Convert.lhs
497
498 endif # bootstrapped with interpreter
499
500 # -----------------------------------------------
501 # mkdependC stuff
502 #
503 # Big Fudge to get around inherent problem that Makefile setup
504 # has got with 'mkdependC'.
505 #
506 SRC_MKDEPENDC_OPTS += -D__GLASGOW_HASKELL__=$(ProjectVersionInt)
507
508 # XXX not really correct, hschooks.c actually gets include files like
509 # RtsFlags.c from the installed GHC, but we can't tell mkdependC about that.
510 SRC_MKDEPENDC_OPTS += -I$(GHC_INCLUDE_DIR)
511
512 # -----------------------------------------------------------------------------
513 # Haskell compilations
514
515 SRC_HC_OPTS += \
516 -cpp -fglasgow-exts -fno-generics -Rghc-timing \
517 -I. -Iparser
518
519 # Omitted: -I$(GHC_INCLUDE_DIR)
520 # We should have -I$(GHC_INCLUDE_DIR) in SRC_HC_OPTS,
521 # to avoid the use of an explicit path in GHC source files
522 # (include "../includes/config.h"
523 # But alas GHC 4.08 (and others for all I know) uses this very
524 # same include path when compiling the .hc files it generates.
525 # Disaster! Then the hc file sees the GHC 5.02 (or whatever)
526 # include files. For the moment we've reverted to using
527 # an explicit path in the .hs sources
528 #
529 # For the benefit of <5.00 compilers, do include GHC_INCLUDE_DIR
530 # when generating dependencies. (=> it gets passed onto mkdependHS,
531 # which needs it).
532 SRC_MKDEPENDHS_OPTS += -I$(GHC_INCLUDE_DIR)
533
534 # We need System.Posix (or Posix when ghc < 6.2)
535 ifeq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
536 ifeq "$(bootstrapped)" "YES"
537 SRC_HC_OPTS += -package Win32
538 PKG_DEPENDS += Win32
539 endif
540 else
541 ifeq "$(bootstrapped) $(ghc_ge_601)" "NO NO"
542 SRC_HC_OPTS += -package posix
543 else
544 SRC_HC_OPTS += -package unix
545 PKG_DEPENDS += unix
546 endif
547 endif
548
549 # We use the Cabal package in stages 2/3 only; in stage 1 we're using
550 # the libcompat library which provides the Cabal modules.
551 ifneq "$(stage)" "1"
552 SRC_HC_OPTS += -package Cabal
553 PKG_DEPENDS += Cabal
554 endif
555
556 ifeq "$(ghc_ge_603)" "YES"
557 # Ignore lang, to avoid potential clash with the Generics module if
558 # lang happens to be a dependency of some exposed package in the local
559 # GHC installation (eg. wxHaskell did this around 6.4).
560 SRC_HC_OPTS += -ignore-package lang
561 endif
562
563 SRC_CC_OPTS += -Iparser -I. -O
564 SRC_HC_OPTS += -recomp $(GhcHcOpts) $(GhcStage$(stage)HcOpts)
565 SRC_HC_OPTS += -H16M
566
567 ifeq "$(BootingFromHc)" "YES"
568 SRC_CC_OPTS += -D__GLASGOW_HASKELL__=$(ProjectVersionInt)
569 endif
570
571 # Special flags for particular modules
572 # The standard suffix rule for compiling a Haskell file
573 # adds these flags to the command line
574
575 # There used to be a -no-recomp flag on PrimOp, but why?
576 # It's an expensive module to recompile!
577 prelude/PrimOp_HC_OPTS = -H80m
578
579
580 main/ParsePkgConf_HC_OPTS += -fno-warn-incomplete-patterns
581 parser/Parser_HC_OPTS += -fno-warn-incomplete-patterns
582
583 ifeq "$(ghc_ge_603)" "NO"
584 # Use -fvia-C since the NCG can't handle the narrow16Int# (and intToInt16#?)
585 # primops on all platforms.
586 parser/Parser_HC_OPTS += -fvia-C
587 # because the NCG can't handle the 64-bit math in here
588 prelude/PrelRules_HC_OPTS += -fvia-C
589 # ByteCodeItbls uses primops that the NCG doesn't support.
590 ghci/ByteCodeItbls_HC_OPTS += -fvia-C
591 ghci/ByteCodeLink_HC_OPTS += -fvia-C -monly-3-regs
592 endif
593
594 # Careful optimisation of the parser: we don't want to throw everything
595 # at it, because that takes too long and doesn't buy much, but we do want
596 # to inline certain key external functions, so we instruct GHC not to
597 # throw away inlinings as it would normally do in -Onot mode:
598 parser/Parser_HC_OPTS += -Onot -fno-ignore-interface-pragmas
599
600 ifeq "$(HOSTPLATFORM)" "hppa1.1-hp-hpux9"
601 rename/RnMonad_HC_OPTS = -O2 -O2-for-C
602 endif
603
604 utils/Digraph_HC_OPTS = -fglasgow-exts
605
606 basicTypes/SrcLoc_HC_OPTS = -funbox-strict-fields
607
608 # We always optimise some low-level modules, otherwise performance of
609 # a non-optimised compiler is severely affected.
610 main/BinIface_HC_OPTS += -O
611 utils/Binary_HC_OPTS += -O -funbox-strict-fields
612 utils/FastMutInt_HC_OPTS += -O
613 utils/Encoding_HC_OPTS += -O
614 utils/StringBuffer_HC_OPTS += -O -funbox-strict-fields
615 utils/FastString_HC_OPTS += -O -funbox-strict-fields
616
617 # ---- Profiling ----
618 #simplCore/Simplify_HC_OPTS = -auto-all
619 #simplCore/SimplEnv_HC_OPTS = -auto-all
620 #simplCore/SimplUtils_HC_OPTS = -auto-all
621
622 # CSE interacts badly with top-level IORefs (reportedly in DriverState and
623 # DriverMkDepend), causing some of them to be commoned up. We have a fix for
624 # this in 5.00+, but earlier versions of the compiler will need CSE turned off.
625 # To be on the safe side, we disable CSE in *all* modules with top-level IORefs.
626 ghci/InteractiveUI_HC_OPTS = -fno-cse
627 main/CmdLineOpts_HC_OPTS = -fno-cse
628 main/DriverMkDepend_HC_OPTS = -fno-cse
629 main/DriverPipeline_HC_OPTS = -fno-cse
630 main/Finder_HC_OPTS = -fno-cse
631 main/SysTools_HC_OPTS = -fno-cse
632 main/StaticFlags_HC_OPTS = -fno-cse
633
634 # The #include is vital for the via-C route, else the C
635 # compiler doesn't realise that the stcall foreign imports are indeed
636 # stdcall, and doesn't generate the Foo@8 name for them
637 ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
638 main/SysTools_HC_OPTS += '-\#include <windows.h>' '-\#include <process.h>'
639 endif
640
641 parser/Lexer_HC_OPTS += -funbox-strict-fields
642
643 # ghc_strlen percolates through so many modules that it is easier to get its
644 # prototype via a global option instead of a myriad of per-file OPTIONS
645 SRC_HC_OPTS += '-\#include "cutils.h"'
646
647 # ----------------------------------------------------------------------------
648 # Generate supporting stuff for prelude/PrimOp.lhs
649 # from prelude/primops.txt
650
651 PRIMOP_BITS=primop-data-decl.hs-incl \
652 primop-tag.hs-incl \
653 primop-list.hs-incl \
654 primop-has-side-effects.hs-incl \
655 primop-out-of-line.hs-incl \
656 primop-commutable.hs-incl \
657 primop-needs-wrapper.hs-incl \
658 primop-can-fail.hs-incl \
659 primop-strictness.hs-incl \
660 primop-primop-info.hs-incl
661
662 CLEAN_FILES += prelude/primops.txt
663 CLEAN_FILES += $(PRIMOP_BITS)
664
665 SRC_CPP_OPTS += -I$(GHC_INCLUDE_DIR)
666 SRC_CPP_OPTS += ${GhcCppOpts}
667
668 ifneq "$(BootingFromHc)" "YES"
669 prelude/PrimOp.lhs $(odir)/prelude/PrimOp.o: $(PRIMOP_BITS)
670 endif
671
672 ifneq "$(BootingFromHc)" "YES"
673 depend :: $(PRIMOP_BITS)
674 endif
675
676 # This is an ugly hack: we need stage1/$(PLATFORM_H) built before we
677 # preprocess primops.txt.pp, but we don't want to just add that
678 # dependency because we don't want $(PLATFORM_H) built during normal
679 # operations, because we don't have have dependencies from the .hs
680 # sources on it, and we don't want those dependencies because that
681 # would cause everything to be rebuilt every time the Makefile
682 # changed. So here we add the required dependency only when making
683 # boot or depend:
684 ifneq "$(findstring boot, $(MAKECMDGOALS))$(findstring depend, $(MAKECMDGOALS))" ""
685 prelude/primops.txt.pp : stage1/$(PLATFORM_H)
686 endif
687
688 primop-data-decl.hs-incl: prelude/primops.txt
689 $(GENPRIMOP) --data-decl < $< > $@
690 primop-tag.hs-incl: prelude/primops.txt
691 $(GENPRIMOP) --primop-tag < $< > $@
692 primop-list.hs-incl: prelude/primops.txt
693 $(GENPRIMOP) --primop-list < $< > $@
694 primop-has-side-effects.hs-incl: prelude/primops.txt
695 $(GENPRIMOP) --has-side-effects < $< > $@
696 primop-out-of-line.hs-incl: prelude/primops.txt
697 $(GENPRIMOP) --out-of-line < $< > $@
698 primop-commutable.hs-incl: prelude/primops.txt
699 $(GENPRIMOP) --commutable < $< > $@
700 primop-needs-wrapper.hs-incl: prelude/primops.txt
701 $(GENPRIMOP) --needs-wrapper < $< > $@
702 primop-can-fail.hs-incl: prelude/primops.txt
703 $(GENPRIMOP) --can-fail < $< > $@
704 primop-strictness.hs-incl: prelude/primops.txt
705 $(GENPRIMOP) --strictness < $< > $@
706 primop-primop-info.hs-incl: prelude/primops.txt
707 $(GENPRIMOP) --primop-primop-info < $< > $@
708
709 # Usages aren't used any more; but the generator
710 # can still generate them if we want them back
711 primop-usage.hs-incl: prelude/primops.txt
712 $(GENPRIMOP) --usage < $< > $@
713
714
715 #-----------------------------------------------------------------------------
716 # Linking
717
718 # Include libghccompat in stage1 only. In stage2 onwards, all these
719 # libraries will be available from the main libraries.
720
721 ifeq "$(stage)" "1"
722 include $(GHC_COMPAT_DIR)/compat.mk
723 endif
724
725 SRC_LD_OPTS += -no-link-chk
726
727 # -----------------------------------------------------------------------------
728 # create ghc-inplace, a convenient way to run ghc from the build tree...
729 # See comments in $(FPTOOLS_TOP)/utils/ghc-pkg/Makefile for why we use
730 # a real binary here rather than a shell script.
731
732 INPLACE_PROG = $(odir)/ghc-inplace$(exeext)
733 EXCLUDED_C_SRCS += ghc-inplace.c
734
735 # FPTOOLS_TOP_ABS platform uses backslashes, at least on Cygwin, but that
736 # will go wrong when we use it in a Haskell string below.
737 TOP_ABS=$(subst \\,/,$(FPTOOLS_TOP_ABS_PLATFORM))
738
739 GHC_PATH=$(TOP_ABS)/$(GHC_COMPILER_DIR_REL)/$(GHC_PROG)$(exeext)
740
741 ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
742 INPLACE_EXTRA_FLAGS = -optc-DWINDOWS
743 endif
744
745 $(INPLACE_PROG): ghc-inplace.c
746 $(HC) -cpp -optc-DGHC_PATH=$(DQ)$(GHC_PATH)$(DQ) -optc-DTOP_ABS=$(DQ)$(TOP_ABS)$(DQ) $(INPLACE_EXTRA_FLAGS) $< -o $@
747
748 all :: $(INPLACE_PROG)
749
750 CLEAN_FILES += $(INPLACE_PROG)
751
752 ifeq "$(stage)" "1"
753 ghc-inplace : $(INPLACE_PROG)
754 $(RM) -f $@ && $(LN_S) $< $@
755
756 all :: ghc-inplace
757
758 CLEAN_FILES += ghc-inplace
759 endif
760
761 #-----------------------------------------------------------------------------
762 # install
763
764 # We don't want ghc treated as an ordinary executable,
765 # but put it together with the libraries.
766 # Also don't want any interface files installed
767
768 DESTDIR = $(INSTALL_LIBRARY_DIR_GHC)
769
770 ifneq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
771 INSTALL_LIBEXECS += $(GHC_PROG)
772 else
773 INSTALL_PROGS += $(GHC_PROG)
774 endif
775
776 # ----------------------------------------------------------------------------
777 # profiling.
778
779 # rename/RnBinds_HC_OPTS += -auto-all
780 # rename/RnEnv_HC_OPTS += -auto-all
781 # rename/RnExpr_HC_OPTS += -auto-all
782 # rename/RnHiFiles_HC_OPTS += -auto-all
783 # rename/RnHsSyn_HC_OPTS += -auto-all
784 # rename/Rename_HC_OPTS += -auto-all
785 # rename/RnIfaces_HC_OPTS += -auto-all
786 # rename/RnNames_HC_OPTS += -auto-all
787 # rename/RnSource_HC_OPTS += -auto-all
788 # rename/RnTypes_HC_OPTS += -auto-all
789 #
790 # typecheck/Inst_HC_OPTS += -auto-all
791 # typecheck/TcBinds_HC_OPTS += -auto-all
792 # typecheck/TcClassDcl_HC_OPTS += -auto-all
793 # typecheck/TcDefaults_HC_OPTS += -auto-all
794 # typecheck/TcDeriv_HC_OPTS += -auto-all
795 # typecheck/TcEnv_HC_OPTS += -auto-all
796 # typecheck/TcExpr_HC_OPTS += -auto-all
797 # typecheck/TcForeign_HC_OPTS += -auto-all
798 # typecheck/TcGenDeriv_HC_OPTS += -auto-all
799 # typecheck/TcHsSyn_HC_OPTS += -auto-all
800 # typecheck/TcIfaceSig_HC_OPTS += -auto-all
801 # typecheck/TcInstDcls_HC_OPTS += -auto-all
802 # typecheck/TcMatches_HC_OPTS += -auto-all
803 # typecheck/TcMonoType_HC_OPTS += -auto-all
804 # typecheck/TcMType_HC_OPTS += -auto-all
805 # typecheck/TcPat_HC_OPTS += -auto-all
806 # typecheck/TcRnDriver_HC_OPTS += -auto-all
807 # #typecheck/TcRnMonad_HC_OPTS += -auto-all
808 # #typecheck/TcRnTypes_HC_OPTS += -auto-all
809 # typecheck/TcRules_HC_OPTS += -auto-all
810 # typecheck/TcSimplify_HC_OPTS += -auto-all
811 # typecheck/TcSplice_HC_OPTS += -auto-all
812 # typecheck/TcTyClsDecls_HC_OPTS += -auto-all
813 # typecheck/TcTyDecls_HC_OPTS += -auto-all
814 # typecheck/TcType_HC_OPTS += -auto-all
815 # typecheck/TcUnify_HC_OPTS += -auto-all
816
817 # coreSyn/CorePrep_HC_OPTS += -auto-all
818 # parser/Parser_HC_OPTS += -fasm
819
820 #-----------------------------------------------------------------------------
821 # Building the GHC package
822
823 # The GHC package is made from the stage 2 build and later.
824 # Fortunately the package build system framework more or less does the
825 # right thing for us here.
826
827 ifneq "$(findstring $(stage), 2 3)" ""
828 BUILD_GHC_PACKAGE=YES
829 endif
830
831 ifeq "$(BUILD_GHC_PACKAGE)" "YES"
832 PACKAGE = ghc
833 HIERARCHICAL_LIB = NO
834 VERSION = $(ProjectVersion)
835 PKG_DEPENDS += base haskell98
836 PACKAGE_CPP_OPTS += -DPKG_DEPENDS='$(PKG_DEPENDS)'
837 PACKAGE_CPP_OPTS += -DSTAGE='"$(stage)"'
838
839 # Omit Main from the library, the client will want to plug their own Main in
840 LIBOBJS = $(filter-out $(odir)/main/Main.o $(odir)/parser/hschooks.o \
841 $(odir)/main/Main.p_o $(odir)/parser/hschooks.p_o, \
842 $(OBJS))
843
844 # disable splitting: it won't really help with GHC, and the specialised
845 # build system for compiler/ isn't set up to handle it.
846 SplitObjs = NO
847
848 # the package build system likes to set WAYS=$(GhcLibWays), but we don't
849 # really want to build the whole of GHC multiple ways... if you do,
850 # set GhcCompilerWays instead.
851 GhcLibWays = $(GhcCompilerWays)
852
853 # override $(GhcLibHcOpts): we want GhcStage2HcOpts to take precedence
854 GhcLibHcOpts =
855
856 # override default definition of HS_IFACES so we can add $(odir)
857 HS_IFACES = $(addsuffix .$(way_)hi,$(basename $(HS_OBJS)))
858
859 # Haddock can't handle recursive modules currently, so we disable it for now.
860 HADDOCK_DOCS = NO
861
862 # Tell package.mk not to set $(HC)
863 NO_SET_HC = YES
864
865 # The stage 2 GHC binary itself is built by compiling main/Main.hs
866 # (the same as used in stage 1) against the GHC package.
867 #
868 # This is done by compiling Main.hs separately and linking it with
869 # -package ghc. This is done using a separate Makefile, Makefile.ghcbin
870 # Why? See comments in Makefile.ghcbin
871
872 # The stage 2 and stage 3 package.conf.in files are different, because they
873 # point to either the stage2/ or stage3/ dirs in import-dirs. Hence before
874 # linking the ghc binary we must install the correct version of the package
875 # configuration. Yeuch... maybe one day this will all be done more cleanly.
876 STAMP_PKG_CONF = $(GHC_DRIVER_DIR)/stamp-pkg-conf-$(PACKAGE)
877
878 ifeq "$(GhcBuildDylibs)" "YES"
879 ifeq "$(darwin_TARGET_OS)" "1"
880 GhcLibraryName=libHS$(PACKAGE)$(_way)_dyn.dylib
881 else
882 GhcLibraryName=libHS$(PACKAGE)$(_way)_dyn.so
883 endif
884 else
885 GhcLibraryName=libHS$(PACKAGE)$(_way).a
886 endif
887
888 ifneq "$(DOING_BIN_DIST)" "YES"
889 $(GHC_PROG) : $(GhcLibraryName) main/Main.hs
890 $(RM) package.conf.inplace
891 $(RM) $(STAMP_PKG_CONF)
892 $(MAKE) $(STAMP_PKG_CONF)
893 $(MAKE) -f Makefile.ghcbin $(MFLAGS) HS_PROG=$(GHC_PROG) $@
894 endif
895
896 # Propagate standard targets to Makefile.ghcbin
897 docs runtests $(BOOT_TARGET) TAGS clean distclean mostlyclean maintainer-clean $(INSTALL_TARGET) $(INSTALL_DOCS_TARGET) html chm HxS ps dvi txt::
898 $(MAKE) -f Makefile.ghcbin $(MFLAGS) $@
899 endif
900
901 #-----------------------------------------------------------------------------
902 # clean
903
904 MAINTAINER_CLEAN_FILES += parser/Parser.info main/ParsePkgConf.info
905
906 #-----------------------------------------------------------------------------
907 # Include target-rule boilerplate
908
909 # Don't use the default MKDEPENDHS stuff... we'll do our own, below
910 MKDEPENDHS_SRCS =
911 MKDEPENDC_SRCS =
912
913 # Make doesn't work this out for itself, it seems
914 parser/Parser.y : parser/Parser.y.pp
915 EXTRA_SRCS += parser/Parser.y
916
917
918 #-----------------------------------------------------------------------------
919 # Source files for tags file generation
920 #
921 # We want to excluded derived sources, because they won't be in the source
922 # tree, which is where we are going to move the TAGS file to.a
923
924 TAGS_HS_SRCS = parser/Parser.y.pp $(filter-out $(DERIVED_SRCS) main/Config.hs parser/Parser.y, $(sort $(SRCS)))
925
926 include $(TOP)/mk/target.mk
927
928 ifeq "$(BUILD_GHC_PACKAGE)" "YES"
929 ifeq "$(way)" ""
930 all :: $(GHC_PROG)
931 endif
932 endif
933
934 $(odir)/main/Config.$(way_)o: SRC_HC_OPTS+=-DSTAGE=$(DQ)$(stage)$(DQ)
935
936 #-----------------------------------------------------------------------------
937 # binary-dist
938
939 ifeq "$(DOING_BIN_DIST)" "YES"
940 # This is derived from the sources when we are in a source tree, but we
941 # don't have any sources in a bindist, so we have to shortcut it
942 HS_IFACES := $(wildcard stage$(stage)/*/*.hi)
943 endif
944
945 binary-dist:
946 $(INSTALL_DIR) $(BIN_DIST_DIR)/compiler
947 $(INSTALL_DIR) $(BIN_DIST_DIR)/compiler/stage$(stage)
948 echo "stage=$(stage)" > $(BIN_DIST_DIR)/compiler/Makefile
949 cat Makefile >> $(BIN_DIST_DIR)/compiler/Makefile
950 $(INSTALL_DATA) package.conf.in $(BIN_DIST_DIR)/compiler/
951 set -e; for d in stage$(stage)/*/; do $(INSTALL_DIR) $(BIN_DIST_DIR)/compiler/$$d; done
952 set -e; for f in $(HS_IFACES); do $(INSTALL_DATA) $$f $(BIN_DIST_DIR)/compiler/$$f; done
953 ifneq "$(INSTALL_LIBS)" ""
954 set -e; for f in $(INSTALL_LIBS); do $(INSTALL_DATA) $$f $(BIN_DIST_DIR)/compiler/$$f; done
955 endif
956 ifneq "$(INSTALL_PROGS)" ""
957 set -e; for f in $(INSTALL_PROGS); do $(INSTALL_PROGRAM) $$f $(BIN_DIST_DIR)/compiler/$$f; done
958 endif
959 ifneq "$(INSTALL_LIBEXECS)" ""
960 set -e; for f in $(INSTALL_LIBEXECS); do $(INSTALL_PROGRAM) $$f $(BIN_DIST_DIR)/compiler/$$f; done
961 endif
962
963 # -----------------------------------------------------------------------------
964 # Explicit dependencies
965
966 # Some .hs files #include other source files, but since ghc -M doesn't spit out
967 # these dependencies we have to include them manually.
968
969 # We don't add dependencies on HsVersions.h, ghcautoconf.h, or ghc_boot_platform.h,
970 # because then modifying one of these files would force recompilation of everything,
971 # which is probably not what you want. However, it does mean you have to be
972 # careful to recompile stuff you need if you reconfigure or change HsVersions.h.
973
974 # Aargh, these don't work properly anyway, because GHC's recompilation checker
975 # just reports "compilation NOT required". Do we have to add -no-recomp for each
976 # of these .hs files? I haven't done anything about this yet.
977
978 $(odir)/codeGen/Bitmap.$(way_)o : ../includes/MachDeps.h
979 $(odir)/codeGen/CgCallConv.$(way_)o : ../includes/StgFun.h
980 $(odir)/codeGen/CgProf.$(way_)o : ../includes/MachDeps.h
981 $(odir)/codeGen/CgProf.$(way_)o : ../includes/Constants.h
982 $(odir)/codeGen/CgProf.$(way_)o : ../includes/DerivedConstants.h
983 $(odir)/codeGen/CgTicky.$(way_)o : ../includes/DerivedConstants.h
984 $(odir)/codeGen/ClosureInfo.$(way_)o : ../includes/MachDeps.h
985 $(odir)/codeGen/SMRep.$(way_)o : ../includes/MachDeps.h
986 $(odir)/codeGen/SMRep.$(way_)o : ../includes/ClosureTypes.h
987 $(odir)/ghci/ByteCodeAsm.$(way_)o : ../includes/Bytecodes.h
988 $(odir)/ghci/ByteCodeFFI.$(way_)o : nativeGen/NCG.h
989 $(odir)/ghci/ByteCodeInstr.$(way_)o : ../includes/MachDeps.h
990 $(odir)/ghci/ByteCodeItbls.$(way_)o : ../includes/ClosureTypes.h
991 $(odir)/ghci/ByteCodeItbls.$(way_)o : nativeGen/NCG.h
992 $(odir)/main/Constants.$(way_)o : ../includes/MachRegs.h
993 $(odir)/main/Constants.$(way_)o : ../includes/Constants.h
994 $(odir)/main/Constants.$(way_)o : ../includes/MachDeps.h
995 $(odir)/main/Constants.$(way_)o : ../includes/DerivedConstants.h
996 $(odir)/main/Constants.$(way_)o : ../includes/GHCConstants.h
997 $(odir)/nativeGen/AsmCodeGen.$(way_)o : nativeGen/NCG.h
998 $(odir)/nativeGen/MachCodeGen.$(way_)o : nativeGen/NCG.h
999 $(odir)/nativeGen/MachCodeGen.$(way_)o : ../includes/MachDeps.h
1000 $(odir)/nativeGen/MachInstrs.$(way_)o : nativeGen/NCG.h
1001 $(odir)/nativeGen/MachRegs.$(way_)o : nativeGen/NCG.h
1002 $(odir)/nativeGen/MachRegs.$(way_)o : ../includes/MachRegs.h
1003 $(odir)/nativeGen/PositionIndependentCode.$(way_)o : nativeGen/NCG.h
1004 $(odir)/nativeGen/PprMach.$(way_)o : nativeGen/NCG.h
1005 $(odir)/nativeGen/RegAllocInfo.$(way_)o : nativeGen/NCG.h
1006 $(odir)/typecheck/TcForeign.$(way_)o : nativeGen/NCG.h
1007 $(odir)/utils/Binary.$(way_)o : ../includes/MachDeps.h
1008 $(odir)/utils/FastMutInt.$(way_)o : ../includes/MachDeps.h
1009
1010 # -----------------------------------------------------------------------------
1011 # Dependencies
1012
1013 MKDEPENDHS_HC_OPTS = $(patsubst -i$(odir)/%, -i%, $(HC_OPTS))
1014
1015 MKDEPENDHS=$(HC)
1016
1017 # Must do this *after* including target.mk, because $(HS_SRCS) isn't set yet.
1018 depend :: $(STAGE_PLATFORM_H) $(HS_SRCS) $(C_SRCS)
1019 touch .depend-BASE
1020 ifneq "$(BootingFromHc)" "YES"
1021 $(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)
1022 endif
1023 $(MKDEPENDC) -f .depend-BASE $(MKDEPENDC_OPTS) $(foreach way,$(WAYS),-s $(way)) -- $(CC_OPTS) -- $(C_SRCS)
1024 $(PERL) -pe 'binmode(stdin); binmode(stdout); s@(\S*[._]o)@stage$(stage)/$$1@g; s@(\S*[._]hi)@stage$(stage)/$$1@g; s@^.*/compat.*$$@@g;' <.depend-BASE >.depend-$(stage)
1025 # The binmode stuff tells perl not to add stupid ^M's to the output
1026 #
1027 # The /lib/compat replacement is to workaround a bug in the
1028 # -optdep--exclude-module flag in GHC 6.4. It is not required for any
1029 # other version of GHC, but doesn't do any harm.
1030
1031 ifeq "$(MakefileDeps)" "YES"
1032 $(CONFIG_HS) : Makefile
1033 stage1/$(PLATFORM_H) : Makefile
1034 stage2/$(PLATFORM_H) : Makefile
1035 endif
1036
1037 -include .depend-$(stage)