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