fix haddock submodule pointer
[ghc-hetmet.git] / rts / ghc.mk
1 # -----------------------------------------------------------------------------
2 #
3 # (c) 2009 The University of Glasgow
4 #
5 # This file is part of the GHC build system.
6 #
7 # To understand how the build system works and how to modify it, see
8 #      http://hackage.haskell.org/trac/ghc/wiki/Building/Architecture
9 #      http://hackage.haskell.org/trac/ghc/wiki/Building/Modifying
10 #
11 # -----------------------------------------------------------------------------
12
13 # -----------------------------------------------------------------------------
14 # Building the RTS
15
16 # We build the RTS with stage 1
17 rts_dist_HC = $(GHC_STAGE1)
18
19 # merge GhcLibWays and GhcRTSWays but strip out duplicates
20 rts_WAYS = $(GhcLibWays) $(filter-out $(GhcLibWays),$(GhcRTSWays))
21 rts_dist_WAYS = $(rts_WAYS)
22
23 ALL_RTS_LIBS = rts/dist/build/libHSrtsmain.a \
24                $(foreach way,$(rts_WAYS),rts/dist/build/libHSrts$($(way)_libsuf))
25 all_rts : $(ALL_RTS_LIBS)
26
27 # -----------------------------------------------------------------------------
28 # Defining the sources
29
30 ALL_DIRS = hooks parallel sm eventlog
31
32 ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
33 ALL_DIRS += win32
34 else
35 ALL_DIRS += posix
36 endif
37
38 EXCLUDED_SRCS :=
39 EXCLUDED_SRCS += rts/Main.c
40 EXCLUDED_SRCS += rts/parallel/SysMan.c
41 EXCLUDED_SRCS += $(wildcard rts/Vis*.c)
42
43 rts_C_SRCS := $(filter-out $(EXCLUDED_SRCS),$(wildcard rts/*.c $(foreach dir,$(ALL_DIRS),rts/$(dir)/*.c)))
44 rts_CMM_SRCS := $(wildcard rts/*.cmm)
45
46 # Don't compile .S files when bootstrapping a new arch
47 ifneq "$(PORTING_HOST)" "YES"
48 ifneq "$(findstring $(TargetArch_CPP), powerpc powerpc64)" ""
49 rts_S_SRCS += rts/AdjustorAsm.S
50 else
51 ifneq "$(findstring $(TargetOS_CPP), darwin)" ""
52 rts_S_SRCS += rts/AdjustorAsm.S
53 endif
54 endif
55 endif
56
57 ifeq "$(GhcUnregisterised)" "YES"
58 GENAPPLY_OPTS = -u
59 endif
60
61 rts_AUTO_APPLY_CMM = rts/dist/build/AutoApply.cmm
62
63 $(rts_AUTO_APPLY_CMM): $(GENAPPLY_INPLACE)
64         "$(GENAPPLY_INPLACE)" >$@
65
66 rts/dist/build/sm/Evac_thr.c : rts/sm/Evac.c | $$(dir $$@)/.
67         cp $< $@
68 rts/dist/build/sm/Scav_thr.c : rts/sm/Scav.c | $$(dir $$@)/.
69         cp $< $@
70
71 rts_H_FILES := $(wildcard rts/*.h)
72
73 ifeq "$(USE_DTRACE)" "YES"
74 DTRACEPROBES_H = rts/dist/build/RtsProbes.h
75 rts_H_FILES += $(DTRACEPROBES_H)
76 endif
77
78 # collect the -l flags that we need to link the rts dyn lib.
79 rts/libs.depend : $(GHC_PKG_INPLACE)
80         "$(GHC_PKG_INPLACE)" field rts extra-libraries \
81           | sed -e 's/^extra-libraries: //' -e 's/\([a-z0-9]*\)[ ]*/-l\1 /g' > $@
82
83
84 # ----------------------------------------------------------------------------
85 # On Windows, as the RTS and base libraries have recursive imports,
86 #       we have to break the loop with "import libraries".
87 #       These are made from rts/win32/libHS*.def which contain lists of
88 #       all the symbols in those libraries used by the RTS.
89 #
90 ifneq "$$(findstring dyn, $1)" ""
91 ifeq  "$(HOSTPLATFORM)" "i386-unknown-mingw32" 
92
93 ALL_RTS_DEF_LIBNAMES    = base ghc-prim
94 ALL_RTS_DEF_LIBS        = \
95         rts/dist/build/win32/libHSbase.dll.a \
96         rts/dist/build/win32/libHSghc-prim.dll.a \
97         rts/dist/build/win32/libHSffi.dll.a 
98
99 # -- import libs for the regular Haskell libraries
100 define make-importlib-def # args $1 = lib name
101 rts/dist/build/win32/libHS$1.def : rts/win32/libHS$1.def
102         cat rts/win32/libHS$1.def \
103                 | sed "s/@LibVersion@/$$(libraries/$1_dist-install_VERSION)/" \
104                 | sed "s/@ProjectVersion@/$(ProjectVersion)/" \
105                 > rts/dist/build/win32/libHS$1.def
106
107 rts/dist/build/win32/libHS$1.dll.a : rts/dist/build/win32/libHS$1.def
108         "$$(DLLTOOL)"   -d rts/dist/build/win32/libHS$1.def \
109                         -l rts/dist/build/win32/libHS$1.dll.a
110 endef
111 $(foreach lib,$(ALL_RTS_DEF_LIBNAMES),$(eval $(call make-importlib-def,$(lib))))
112
113
114 # -- import libs for libffi
115 rts/dist/build/win32/libHSffi.def : rts/win32/libHSffi.def
116         cat rts/win32/libHSffi.def \
117                 | sed "s/@ProjectVersion@/$(ProjectVersion)/" \
118                 > rts/dist/build/win32/libHSffi.def
119
120 rts/dist/build/win32/libHSffi.dll.a : rts/dist/build/win32/libHSffi.def
121         "$(DLLTOOL)"    -d rts/dist/build/win32/libHSffi.def \
122                         -l rts/dist/build/win32/libHSffi.dll.a
123 endif
124 endif
125
126
127 #-----------------------------------------------------------------------------
128 # Building one way
129 define build-rts-way # args: $1 = way
130
131 ifneq "$$(BINDIST)" "YES"
132
133 # The per-way CC_OPTS
134 ifneq "$$(findstring debug, $1)" ""
135 rts_dist_$1_HC_OPTS =
136 rts_dist_$1_CC_OPTS = -g -O0
137 else
138 rts_dist_$1_HC_OPTS = $$(GhcRtsHcOpts)
139 rts_dist_$1_CC_OPTS = $$(GhcRtsCcOpts)
140 endif
141
142 ifneq "$$(findstring thr, $1)" ""
143 rts_$1_EXTRA_C_SRCS  =  rts/dist/build/sm/Evac_thr.c rts/dist/build/sm/Scav_thr.c
144 endif
145
146 $(call distdir-way-opts,rts,dist,$1)
147 $(call c-suffix-rules,rts,dist,$1,YES)
148 $(call cmm-suffix-rules,rts,dist,$1)
149 $(call hs-suffix-rules-srcdir,rts,dist,$1,.)
150 # hs-suffix-rules-srcdir is needed when BootingFromHc to get the .hc rules
151
152 rts_$1_LIB_NAME = libHSrts$$($1_libsuf)
153 rts_$1_LIB = rts/dist/build/$$(rts_$1_LIB_NAME)
154
155 rts_$1_C_OBJS   = $$(patsubst rts/%.c,rts/dist/build/%.$$($1_osuf),$$(rts_C_SRCS)) $$(patsubst %.c,%.$$($1_osuf),$$(rts_$1_EXTRA_C_SRCS))
156 rts_$1_S_OBJS   = $$(patsubst rts/%.S,rts/dist/build/%.$$($1_osuf),$$(rts_S_SRCS))
157 rts_$1_CMM_OBJS = $$(patsubst rts/%.cmm,rts/dist/build/%.$$($1_osuf),$$(rts_CMM_SRCS)) $$(patsubst %.cmm,%.$$($1_osuf),$$(rts_AUTO_APPLY_CMM))
158
159 rts_$1_OBJS = $$(rts_$1_C_OBJS) $$(rts_$1_S_OBJS) $$(rts_$1_CMM_OBJS)
160
161 ifeq "$(USE_DTRACE)" "YES"
162 ifeq "$(TargetOS_CPP)" "solaris2"
163 # On Darwin we don't need to generate binary containing probes defined
164 # in DTrace script, but DTrace on Solaris expects generation of binary
165 # from the DTrace probes definitions
166 rts_$1_DTRACE_OBJS = rts/dist/build/RtsProbes.$$($1_osuf)
167
168 rts/dist/build/RtsProbes.$$($1_osuf) : $$(rts_$1_OBJS)
169         $(DTRACE) -G -C -Iincludes -DDTRACE -s rts/RtsProbes.d -o \
170                 $$@ $$(rts_$1_OBJS)
171 endif
172 endif
173
174 rts_dist_$1_CC_OPTS += -DRtsWay=\"rts_$1\"
175
176 # Making a shared library for the RTS.
177 ifneq "$$(findstring dyn, $1)" ""
178 ifeq "$$(HOSTPLATFORM)" "i386-unknown-mingw32"
179 $$(rts_$1_LIB) : $$(rts_$1_OBJS) $$(ALL_RTS_DEF_LIBS) rts/libs.depend
180         "$$(RM)" $$(RM_OPTS) $$@
181         "$$(rts_dist_HC)" -package-name rts -shared -dynamic -dynload deploy \
182           -no-auto-link-packages `cat rts/libs.depend` $$(rts_$1_OBJS) $$(ALL_RTS_DEF_LIBS) -o $$@
183 else
184 $$(rts_$1_LIB) : $$(rts_$1_OBJS) $$(rts_$1_DTRACE_OBJS) rts/libs.depend
185         "$$(RM)" $$(RM_OPTS) $$@
186         "$$(rts_dist_HC)" -package-name rts -shared -dynamic -dynload deploy \
187           -no-auto-link-packages `cat rts/libs.depend` $$(rts_$1_OBJS) \
188           $$(rts_$1_DTRACE_OBJS) -o $$@
189 ifeq "$$(darwin_HOST_OS)" "1"
190         # Ensure library's install name is correct before anyone links with it.
191         install_name_tool -id $(ghclibdir)/$$(rts_$1_LIB_NAME) $$@
192 endif
193 endif
194 else
195 $$(rts_$1_LIB) : $$(rts_$1_OBJS) $$(rts_$1_DTRACE_OBJS)
196         "$$(RM)" $$(RM_OPTS) $$@
197         echo $$(rts_$1_OBJS) $$(rts_$1_DTRACE_OBJS) | "$$(XARGS)" $$(XARGS_OPTS) "$$(AR_STAGE1)" \
198                 $$(AR_OPTS_STAGE1) $$(EXTRA_AR_ARGS_STAGE1) $$@
199 endif
200
201 endif
202
203 endef
204
205 # And expand the above for each way:
206 $(foreach way,$(rts_WAYS),$(eval $(call build-rts-way,$(way))))
207
208 #-----------------------------------------------------------------------------
209 # Flags for compiling every file
210
211 # We like plenty of warnings.
212 WARNING_OPTS += -Wall
213 ifeq "$(GccLT34)" "YES"
214 WARNING_OPTS += -W
215 else
216 WARNING_OPTS += -Wextra
217 endif
218 WARNING_OPTS += -Wstrict-prototypes 
219 WARNING_OPTS += -Wmissing-prototypes 
220 WARNING_OPTS += -Wmissing-declarations
221 WARNING_OPTS += -Winline
222 WARNING_OPTS += -Waggregate-return
223 WARNING_OPTS += -Wpointer-arith
224 WARNING_OPTS += -Wmissing-noreturn
225 WARNING_OPTS += -Wnested-externs
226 WARNING_OPTS += -Wredundant-decls 
227
228 # These ones are hard to avoid:
229 #WARNING_OPTS += -Wconversion
230 #WARNING_OPTS += -Wbad-function-cast
231 #WARNING_OPTS += -Wshadow
232 #WARNING_OPTS += -Wcast-qual
233
234 # This one seems buggy on GCC 4.1.2, which is the only GCC version we 
235 # have that can bootstrap the SPARC build. We end up with lots of supurious
236 # warnings of the form "cast increases required alignment of target type".
237 # Some legitimate warnings can be fixed by adding an intermediate cast to
238 # (void*), but we get others in rts/sm/GCUtils.c concerning the gct var
239 # that look innocuous to me. We could enable this again once we deprecate
240 # support for registerised builds on this arch. -- BL 2010/02/03
241 # WARNING_OPTS += -Wcast-align
242
243 STANDARD_OPTS += -Iincludes -Irts
244 # COMPILING_RTS is only used when building Win32 DLL support.
245 STANDARD_OPTS += -DCOMPILING_RTS
246
247 # HC_OPTS is included in both .c and .cmm compilations, whereas CC_OPTS is
248 # only included in .c compilations.  HC_OPTS included the WAY_* opts, which
249 # must be included in both types of compilations.
250
251 rts_CC_OPTS += $(WARNING_OPTS)
252 rts_CC_OPTS += $(STANDARD_OPTS)
253
254 rts_HC_OPTS += $(STANDARD_OPTS) -package-name rts
255
256 ifneq "$(GhcWithSMP)" "YES"
257 rts_CC_OPTS += -DNOSMP
258 rts_HC_OPTS += -optc-DNOSMP
259 endif
260
261 ifeq "$(UseLibFFIForAdjustors)" "YES"
262 rts_CC_OPTS += -DUSE_LIBFFI_FOR_ADJUSTORS
263 endif
264
265 # Mac OS X: make sure we compile for the right OS version
266 rts_CC_OPTS += $(MACOSX_DEPLOYMENT_CC_OPTS)
267 rts_HC_OPTS += $(addprefix -optc, $(MACOSX_DEPLOYMENT_CC_OPTS))
268 rts_LD_OPTS += $(addprefix -optl, $(MACOSX_DEPLOYMENT_LD_OPTS))
269
270 # We *want* type-checking of hand-written cmm.
271 rts_HC_OPTS += -dcmm-lint 
272
273 # -fno-strict-aliasing is required for the runtime, because we often
274 # use a variety of types to represent closure pointers (StgPtr,
275 # StgClosure, StgMVar, etc.), and without -fno-strict-aliasing gcc is
276 # allowed to assume that these pointers do not alias.  eg. without
277 # this flag we get problems in sm/Evac.c:copy() with gcc 3.4.3, the
278 # upd_evacee() assigments get moved before the object copy.
279 rts_CC_OPTS += -fno-strict-aliasing
280
281 rts_CC_OPTS += -fno-common
282
283 ifeq "$(BeConservative)" "YES"
284 rts_CC_OPTS += -DBE_CONSERVATIVE
285 endif
286
287 #-----------------------------------------------------------------------------
288 # Flags for compiling specific files
289
290 # If RtsMain.c is built with optimisation then the SEH exception stuff on
291 # Windows gets confused.
292 # This has to be in HC rather than CC opts, as otherwise there's a
293 # -optc-O2 that comes after it.
294 rts/RtsMain_HC_OPTS += -optc-O0
295
296 rts/RtsMessages_CC_OPTS += -DProjectVersion=\"$(ProjectVersion)\"
297 rts/RtsUtils_CC_OPTS += -DProjectVersion=\"$(ProjectVersion)\"
298 rts/Trace_CC_OPTS += -DProjectVersion=\"$(ProjectVersion)\"
299 #
300 rts/RtsUtils_CC_OPTS += -DHostPlatform=\"$(HOSTPLATFORM)\"
301 rts/RtsUtils_CC_OPTS += -DHostArch=\"$(HostArch_CPP)\"
302 rts/RtsUtils_CC_OPTS += -DHostOS=\"$(HostOS_CPP)\"
303 rts/RtsUtils_CC_OPTS += -DHostVendor=\"$(HostVendor_CPP)\"
304 #
305 rts/RtsUtils_CC_OPTS += -DBuildPlatform=\"$(BUILDPLATFORM)\"
306 rts/RtsUtils_CC_OPTS += -DBuildArch=\"$(BuildArch_CPP)\"
307 rts/RtsUtils_CC_OPTS += -DBuildOS=\"$(BuildOS_CPP)\"
308 rts/RtsUtils_CC_OPTS += -DBuildVendor=\"$(BuildVendor_CPP)\"
309 #
310 rts/RtsUtils_CC_OPTS += -DTargetPlatform=\"$(TARGETPLATFORM)\"
311 rts/RtsUtils_CC_OPTS += -DTargetArch=\"$(TargetArch_CPP)\"
312 rts/RtsUtils_CC_OPTS += -DTargetOS=\"$(TargetOS_CPP)\"
313 rts/RtsUtils_CC_OPTS += -DTargetVendor=\"$(TargetVendor_CPP)\"
314 #
315 rts/RtsUtils_CC_OPTS += -DGhcUnregisterised=\"$(GhcUnregisterised)\"
316 rts/RtsUtils_CC_OPTS += -DGhcEnableTablesNextToCode=\"$(GhcEnableTablesNextToCode)\"
317
318 # Compile various performance-critical pieces *without* -fPIC -dynamic
319 # even when building a shared library.  If we don't do this, then the
320 # GC runs about 50% slower on x86 due to the overheads of PIC.  The
321 # cost of doing this is a little runtime linking and less sharing, but
322 # not much.
323 #
324 # On x86_64 this doesn't work, because all objects in a shared library
325 # must be compiled with -fPIC (since the 32-bit relocations generated
326 # by the default small memory can't be resolved at runtime).  So we
327 # only do this on i386.
328 #
329 # This apparently doesn't work on OS X (Darwin) nor on Solaris.
330 # On Darwin we get errors of the form
331 #
332 #  ld: absolute addressing (perhaps -mdynamic-no-pic) used in _stg_ap_0_fast from rts/dist/build/Apply.dyn_o not allowed in slidable image
333 #
334 # and lots of these warnings:
335 #
336 #  ld: warning codegen in _stg_ap_pppv_fast (offset 0x0000005E) prevents image from loading in dyld shared cache
337 #
338 # On Solaris we get errors like:
339 #
340 # Text relocation remains                         referenced
341 #     against symbol                  offset      in file
342 # .rodata (section)                   0x11        rts/dist/build/Apply.dyn_o
343 #   ...
344 # ld: fatal: relocations remain against allocatable but non-writable sections
345 # collect2: ld returned 1 exit status
346
347 ifeq "$(TargetArch_CPP)" "i386"
348 i386_SPEED_HACK := "YES"
349 ifeq "$(TargetOS_CPP)" "darwin"
350 i386_SPEED_HACK := "NO"
351 endif
352 ifeq "$(TargetOS_CPP)" "solaris2"
353 i386_SPEED_HACK := "NO"
354 endif
355 endif
356
357 ifeq "$(TargetArch_CPP)" "i386"
358 ifeq "$(i386_SPEED_HACK)" "YES"
359 rts/sm/Evac_HC_OPTS           += -fno-PIC
360 rts/sm/Evac_thr_HC_OPTS       += -fno-PIC
361 rts/sm/Scav_HC_OPTS           += -fno-PIC
362 rts/sm/Scav_thr_HC_OPTS       += -fno-PIC
363 rts/sm/Compact_HC_OPTS        += -fno-PIC
364 rts/sm/GC_HC_OPTS             += -fno-PIC
365
366 # -static is also necessary for these bits, otherwise the NCG
367 # -generates dynamic references:
368 rts/Updates_HC_OPTS += -fno-PIC -static
369 rts/StgMiscClosures_HC_OPTS += -fno-PIC -static
370 rts/PrimOps_HC_OPTS += -fno-PIC -static
371 rts/Apply_HC_OPTS += -fno-PIC -static
372 rts/dist/build/AutoApply_HC_OPTS += -fno-PIC -static
373 endif
374 endif
375
376 # ffi.h triggers prototype warnings, so disable them here:
377 rts/Interpreter_CC_OPTS += -Wno-strict-prototypes
378 rts/Adjustor_CC_OPTS    += -Wno-strict-prototypes
379 rts/sm/Storage_CC_OPTS  += -Wno-strict-prototypes
380
381 # inlining warnings happen in Compact
382 rts/sm/Compact_CC_OPTS += -Wno-inline
383
384 # emits warnings about call-clobbered registers on x86_64
385 rts/StgCRun_CC_OPTS += -w
386
387 rts/RetainerProfile_CC_OPTS += -w
388 rts/RetainerSet_CC_OPTS += -Wno-format
389 # On Windows:
390 rts/win32/ConsoleHandler_CC_OPTS += -w
391 rts/win32/ThrIOManager_CC_OPTS += -w
392 # The above warning supression flags are a temporary kludge.
393 # While working on this module you are encouraged to remove it and fix
394 # any warnings in the module. See
395 #     http://hackage.haskell.org/trac/ghc/wiki/WorkingConventions#Warnings
396 # for details
397
398 # Without this, thread_obj will not be inlined (at least on x86 with GCC 4.1.0)
399 rts/sm/Compact_CC_OPTS += -finline-limit=2500
400
401 # -O3 helps unroll some loops (especially in copy() with a constant argument).
402 rts/sm/Evac_CC_OPTS += -funroll-loops
403 rts/dist/build/sm/Evac_thr_HC_OPTS += -optc-funroll-loops
404
405 # These files are just copies of sm/Evac.c and sm/Scav.c respectively,
406 # but compiled with -DPARALLEL_GC.
407 rts/dist/build/sm/Evac_thr_CC_OPTS += -DPARALLEL_GC -Irts/sm
408 rts/dist/build/sm/Scav_thr_CC_OPTS += -DPARALLEL_GC -Irts/sm
409
410 #-----------------------------------------------------------------------------
411 # Add PAPI library if needed
412
413 ifeq "$(GhcRtsWithPapi)" "YES"
414
415 rts_CC_OPTS             += -DUSE_PAPI
416
417 rts_PACKAGE_CPP_OPTS    += -DUSE_PAPI
418 rts_PACKAGE_CPP_OPTS    += -DPAPI_INCLUDE_DIR=$(PapiIncludeDir)
419 rts_PACKAGE_CPP_OPTS    += -DPAPI_LIB_DIR=$(PapiLibDir)
420
421 ifneq "$(PapiIncludeDir)" ""
422 rts_HC_OPTS     += -I$(PapiIncludeDir)
423 rts_CC_OPTS     += -I$(PapiIncludeDir)
424 rts_HSC2HS_OPTS += -I$(PapiIncludeDir)
425 endif
426 ifneq "$(PapiLibDirs)" ""
427 rts_LD_OPTS     += -L$(PapiLibDirs)
428 endif
429
430 else # GhcRtsWithPapi==YES
431
432 rts_PACKAGE_CPP_OPTS += -DPAPI_INCLUDE_DIR=""
433 rts_PACKAGE_CPP_OPTS += -DPAPI_LIB_DIR=""
434
435 endif
436
437 # -----------------------------------------------------------------------------
438 # dependencies
439
440 rts_WAYS_DASHED = $(subst $(space),,$(patsubst %,-%,$(strip $(rts_WAYS))))
441 rts_dist_depfile_base = rts/dist/build/.depend$(rts_WAYS_DASHED)
442
443 rts_dist_C_SRCS  = $(rts_C_SRCS) $(rts_thr_EXTRA_C_SRCS)
444 rts_dist_S_SRCS =  $(rts_S_SRCS)
445 rts_dist_C_FILES = $(rts_C_SRCS) $(rts_thr_EXTRA_C_SRCS) $(rts_S_SRCS)
446
447 # Hack: we define every way-related option here, so that we get (hopefully)
448 # a superset of the dependencies.  To do this properly, we should generate
449 # a different set of dependencies for each way.  Further hack: PROFILING an
450
451 # TICKY_TICKY can't be used together, so we omit TICKY_TICKY for now.
452 rts_dist_MKDEPENDC_OPTS += -DPROFILING -DTHREADED_RTS -DDEBUG
453
454 ifeq "$(USE_DTRACE)" "YES"
455
456 rts_dist_MKDEPENDC_OPTS += -Irts/dist/build
457
458 endif
459
460 $(eval $(call dependencies,rts,dist,1))
461
462 $(rts_dist_depfile_c_asm) : libffi/dist-install/build/ffi.h $(DTRACEPROBES_H)
463
464 #-----------------------------------------------------------------------------
465 # libffi stuff
466
467 rts_CC_OPTS     += -Ilibffi/build/include
468 rts_HC_OPTS     += -Ilibffi/build/include
469 rts_HSC2HS_OPTS += -Ilibffi/build/include
470 rts_LD_OPTS     += -Llibffi/build/include
471
472 # -----------------------------------------------------------------------------
473 # compile dtrace probes if dtrace is supported
474
475 ifeq "$(USE_DTRACE)" "YES"
476
477 rts_CC_OPTS             += -DDTRACE
478 rts_HC_OPTS             += -DDTRACE
479
480 # Apple's dtrace (the only one supported by ghc at the moment) uses
481 # gcc as its preprocessor. If gcc isn't at /usr/bin/gcc, or we need
482 # to force it to use a different gcc, we need to give the path in
483 # the option cpppath.
484
485 ifeq "$(TargetOS_CPP)" "darwin"
486 # Darwin has a flag to tell dtrace which cpp to use.
487 # Unfortunately, this isn't supported on Solaris (See Solaris Dynamic Tracing
488 # Guide, Chapter 16, for the configuration variables available on Solaris)
489 DTRACE_FLAGS = -x cpppath=$(WhatGccIsCalled)
490 endif
491
492 DTRACEPROBES_SRC = rts/RtsProbes.d
493 $(DTRACEPROBES_H): $(DTRACEPROBES_SRC) includes/ghcplatform.h | $$(dir $$@)/.
494         "$(DTRACE)" $(filter -I%,$(rts_CC_OPTS)) -C $(DTRACE_FLAGS) -h -o $@ -s $<
495 endif
496
497 # -----------------------------------------------------------------------------
498 # build the static lib containing the C main symbol
499
500 ifneq "$(BINDIST)" "YES"
501 rts/dist/build/libHSrtsmain.a : rts/dist/build/Main.o
502         "$(RM)" $(RM_OPTS) $@
503         "$(AR_STAGE1)" $(AR_OPTS_STAGE1) $(EXTRA_AR_ARGS_STAGE1) $@ $<
504 endif
505
506 # -----------------------------------------------------------------------------
507 # The RTS package config
508
509 # If -DDEBUG is in effect, adjust package conf accordingly..
510 ifneq "$(strip $(filter -optc-DDEBUG,$(GhcRtsHcOpts)))" ""
511 rts_PACKAGE_CPP_OPTS += -DDEBUG
512 endif
513
514 ifeq "$(HaveLibMingwEx)" "YES"
515 rts_PACKAGE_CPP_OPTS += -DHAVE_LIBMINGWEX
516 endif
517
518 $(eval $(call manual-package-config,rts))
519
520 ifneq "$(BootingFromHc)" "YES"
521 rts/package.conf.inplace : $(includes_H_CONFIG) $(includes_H_PLATFORM)
522 endif
523
524 # -----------------------------------------------------------------------------
525 # installing
526
527 INSTALL_LIBS += $(ALL_RTS_LIBS)
528
529 # -----------------------------------------------------------------------------
530 # cleaning
531
532 $(eval $(call clean-target,rts,dist,rts/dist))
533
534 BINDIST_EXTRAS += rts/package.conf.in
535