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