Enable and fix building dynlibs on Win64
[ghc.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 = $(foreach way,$(rts_WAYS),rts/dist/build/libHSrts$($(way)_libsuf))
24 all_rts : $(ALL_RTS_LIBS)
25
26 # -----------------------------------------------------------------------------
27 # Defining the sources
28
29 ALL_DIRS = hooks parallel sm eventlog
30
31 ifeq "$(HostOS_CPP)" "mingw32"
32 ALL_DIRS += win32
33 else
34 ALL_DIRS += posix
35 endif
36
37 EXCLUDED_SRCS :=
38 EXCLUDED_SRCS += rts/parallel/SysMan.c
39 EXCLUDED_SRCS += $(wildcard rts/Vis*.c)
40
41 rts_C_SRCS := $(filter-out $(EXCLUDED_SRCS),$(wildcard rts/*.c $(foreach dir,$(ALL_DIRS),rts/$(dir)/*.c)))
42 rts_CMM_SRCS := $(wildcard rts/*.cmm)
43
44 # Don't compile .S files when bootstrapping a new arch
45 ifneq "$(PORTING_HOST)" "YES"
46 ifneq "$(findstring $(TargetArch_CPP), i386 powerpc powerpc64)" ""
47 rts_S_SRCS += rts/AdjustorAsm.S
48 endif
49 endif
50
51 ifeq "$(GhcUnregisterised)" "YES"
52 GENAPPLY_OPTS = -u
53 endif
54
55 rts_AUTO_APPLY_CMM = rts/dist/build/AutoApply.cmm
56
57 $(rts_AUTO_APPLY_CMM): $(GENAPPLY_INPLACE)
58 "$(GENAPPLY_INPLACE)" >$@
59
60 rts/dist/build/sm/Evac_thr.c : rts/sm/Evac.c | $$(dir $$@)/.
61 cp $< $@
62 rts/dist/build/sm/Scav_thr.c : rts/sm/Scav.c | $$(dir $$@)/.
63 cp $< $@
64
65 rts_H_FILES := $(wildcard rts/*.h rts/*/*.h)
66
67 ifeq "$(USE_DTRACE)" "YES"
68 DTRACEPROBES_H = rts/dist/build/RtsProbes.h
69 rts_H_FILES += $(DTRACEPROBES_H)
70 endif
71
72 # collect the -l flags that we need to link the rts dyn lib.
73 rts/libs.depend : $(GHC_PKG_INPLACE)
74 "$(GHC_PKG_INPLACE)" field rts extra-libraries \
75 | sed -e 's/^extra-libraries: //' -e 's/\([a-z0-9]*\)[ ]*/-l\1 /g' > $@
76
77
78 # ----------------------------------------------------------------------------
79 # On Windows, as the RTS and base libraries have recursive imports,
80 # we have to break the loop with "import libraries".
81 # These are made from rts/win32/libHS*.def which contain lists of
82 # all the symbols in those libraries used by the RTS.
83 #
84 ifeq "$(HostOS_CPP)" "mingw32"
85
86 ALL_RTS_DEF_LIBNAMES = base ghc-prim
87 ALL_RTS_DEF_LIBS = \
88 rts/dist/build/win32/libHSbase.dll.a \
89 rts/dist/build/win32/libHSghc-prim.dll.a
90
91 # -- import libs for the regular Haskell libraries
92 define make-importlib-def # args $1 = lib name
93 rts/dist/build/win32/libHS$1.def : rts/win32/libHS$1.def
94 cat rts/win32/libHS$1.def \
95 | sed "s/@LibVersion@/$$(libraries/$1_dist-install_VERSION)/" \
96 | sed "s/@ProjectVersion@/$$(ProjectVersion)/" \
97 > rts/dist/build/win32/libHS$1.def
98
99 rts/dist/build/win32/libHS$1.dll.a : rts/dist/build/win32/libHS$1.def
100 "$$(DLLTOOL)" -d rts/dist/build/win32/libHS$1.def \
101 -l rts/dist/build/win32/libHS$1.dll.a
102 endef
103 $(foreach lib,$(ALL_RTS_DEF_LIBNAMES),$(eval $(call make-importlib-def,$(lib))))
104 endif
105
106 ifneq "$(BINDIST)" "YES"
107 rts_ffi_objs_stamp = rts/dist/ffi/stamp
108 rts_ffi_objs = rts/dist/ffi/*.o
109 $(rts_ffi_objs_stamp): $(libffi_STATIC_LIB) $(TOUCH_DEP) | $$(dir $$@)/.
110 cd rts/dist/ffi && $(AR) x ../../../$(libffi_STATIC_LIB)
111 "$(TOUCH_CMD)" $@
112
113 # This is a little hacky. We don't know the SO version, so we only
114 # depend on libffi.so, but copy libffi.so*
115 rts/dist/build/libffi$(soext): libffi/build/inst/lib/libffi$(soext)
116 cp libffi/build/inst/lib/libffi$(soext)* rts/dist/build
117
118 rts/dist/build/$(LIBFFI_DLL): libffi/build/inst/bin/$(LIBFFI_DLL)
119 cp $< $@
120 endif
121
122 #-----------------------------------------------------------------------------
123 # Building one way
124 define build-rts-way # args: $1 = way
125
126 ifneq "$$(BINDIST)" "YES"
127
128 # The per-way CC_OPTS
129 ifneq "$$(findstring debug, $1)" ""
130 rts_dist_$1_HC_OPTS =
131 rts_dist_$1_CC_OPTS = -g -O0
132 else
133 rts_dist_$1_HC_OPTS = $$(GhcRtsHcOpts)
134 rts_dist_$1_CC_OPTS = $$(GhcRtsCcOpts)
135 endif
136
137 ifneq "$$(findstring thr, $1)" ""
138 rts_$1_EXTRA_C_SRCS = rts/dist/build/sm/Evac_thr.c rts/dist/build/sm/Scav_thr.c
139 endif
140
141 $(call distdir-way-opts,rts,dist,$1)
142 $(call c-suffix-rules,rts,dist,$1,YES)
143 $(call cmm-suffix-rules,rts,dist,$1)
144 $(call hs-suffix-rules-srcdir,rts,dist,$1,.)
145 # hs-suffix-rules-srcdir is needed when BootingFromHc to get the .hc rules
146
147 rts_$1_LIB_NAME = libHSrts$$($1_libsuf)
148 rts_$1_LIB = rts/dist/build/$$(rts_$1_LIB_NAME)
149
150 rts_$1_C_OBJS = $$(patsubst rts/%.c,rts/dist/build/%.$$($1_osuf),$$(rts_C_SRCS)) $$(patsubst %.c,%.$$($1_osuf),$$(rts_$1_EXTRA_C_SRCS))
151 rts_$1_S_OBJS = $$(patsubst rts/%.S,rts/dist/build/%.$$($1_osuf),$$(rts_S_SRCS))
152 rts_$1_CMM_OBJS = $$(patsubst rts/%.cmm,rts/dist/build/%.$$($1_osuf),$$(rts_CMM_SRCS)) $$(patsubst %.cmm,%.$$($1_osuf),$$(rts_AUTO_APPLY_CMM))
153
154 rts_$1_OBJS = $$(rts_$1_C_OBJS) $$(rts_$1_S_OBJS) $$(rts_$1_CMM_OBJS)
155
156 ifeq "$(USE_DTRACE)" "YES"
157 ifeq "$(TargetOS_CPP)" "solaris2"
158 # On Darwin we don't need to generate binary containing probes defined
159 # in DTrace script, but DTrace on Solaris expects generation of binary
160 # from the DTrace probes definitions
161 rts_$1_DTRACE_OBJS = rts/dist/build/RtsProbes.$$($1_osuf)
162
163 rts/dist/build/RtsProbes.$$($1_osuf) : $$(rts_$1_OBJS)
164 $(DTRACE) -G -C $$(addprefix -I,$$(GHC_INCLUDE_DIRS)) -DDTRACE -s rts/RtsProbes.d -o \
165 $$@ $$(rts_$1_OBJS)
166 endif
167 endif
168
169 rts_dist_$1_CC_OPTS += -DRtsWay=\"rts_$1\"
170
171 # Making a shared library for the RTS.
172 ifneq "$$(findstring dyn, $1)" ""
173 ifeq "$$(HostOS_CPP)" "mingw32"
174 $$(rts_$1_LIB) : $$(rts_$1_OBJS) $$(ALL_RTS_DEF_LIBS) rts/libs.depend rts/dist/build/$$(LIBFFI_DLL)
175 "$$(RM)" $$(RM_OPTS) $$@
176 "$$(rts_dist_HC)" -package-name rts -shared -dynamic -dynload deploy \
177 -no-auto-link-packages -Lrts/dist/build -l$(LIBFFI_WINDOWS_LIB) `cat rts/libs.depend` $$(rts_$1_OBJS) $$(ALL_RTS_DEF_LIBS) -o $$@
178 else
179 $$(rts_$1_LIB) : $$(rts_$1_OBJS) $$(rts_$1_DTRACE_OBJS) rts/libs.depend rts/dist/build/libffi$$(soext)
180 "$$(RM)" $$(RM_OPTS) $$@
181 "$$(rts_dist_HC)" -package-name rts -shared -dynamic -dynload deploy \
182 -no-auto-link-packages -Lrts/dist/build -lffi `cat rts/libs.depend` $$(rts_$1_OBJS) \
183 $$(rts_$1_DTRACE_OBJS) -o $$@
184 ifeq "$$(darwin_HOST_OS)" "1"
185 # Ensure library's install name is correct before anyone links with it.
186 install_name_tool -id $$(ghclibdir)/$$(rts_$1_LIB_NAME) $$@
187 endif
188 endif
189 else
190 $$(rts_$1_LIB) : $$(rts_$1_OBJS) $$(rts_$1_DTRACE_OBJS) $$(rts_ffi_objs_stamp)
191 "$$(RM)" $$(RM_OPTS) $$@
192 echo $$(rts_ffi_objs) $$(rts_$1_OBJS) $$(rts_$1_DTRACE_OBJS) | "$$(XARGS)" $$(XARGS_OPTS) "$$(AR_STAGE1)" \
193 $$(AR_OPTS_STAGE1) $$(EXTRA_AR_ARGS_STAGE1) $$@
194 endif
195
196 endif
197
198 endef
199
200 # And expand the above for each way:
201 $(foreach way,$(rts_WAYS),$(eval $(call build-rts-way,$(way))))
202
203 #-----------------------------------------------------------------------------
204 # Flags for compiling every file
205
206 # We like plenty of warnings.
207 WARNING_OPTS += -Wall
208 ifeq "$(GccLT34)" "YES"
209 WARNING_OPTS += -W
210 else
211 WARNING_OPTS += -Wextra
212 endif
213 WARNING_OPTS += -Wstrict-prototypes
214 WARNING_OPTS += -Wmissing-prototypes
215 WARNING_OPTS += -Wmissing-declarations
216 WARNING_OPTS += -Winline
217 WARNING_OPTS += -Waggregate-return
218 WARNING_OPTS += -Wpointer-arith
219 WARNING_OPTS += -Wmissing-noreturn
220 WARNING_OPTS += -Wnested-externs
221 WARNING_OPTS += -Wredundant-decls
222
223 # These ones are hard to avoid:
224 #WARNING_OPTS += -Wconversion
225 #WARNING_OPTS += -Wbad-function-cast
226 #WARNING_OPTS += -Wshadow
227 #WARNING_OPTS += -Wcast-qual
228
229 # This one seems buggy on GCC 4.1.2, which is the only GCC version we
230 # have that can bootstrap the SPARC build. We end up with lots of supurious
231 # warnings of the form "cast increases required alignment of target type".
232 # Some legitimate warnings can be fixed by adding an intermediate cast to
233 # (void*), but we get others in rts/sm/GCUtils.c concerning the gct var
234 # that look innocuous to me. We could enable this again once we deprecate
235 # support for registerised builds on this arch. -- BL 2010/02/03
236 # WARNING_OPTS += -Wcast-align
237
238 STANDARD_OPTS += $(addprefix -I,$(GHC_INCLUDE_DIRS)) -Irts -Irts/dist/build
239 # COMPILING_RTS is only used when building Win32 DLL support.
240 STANDARD_OPTS += -DCOMPILING_RTS
241
242 # HC_OPTS is included in both .c and .cmm compilations, whereas CC_OPTS is
243 # only included in .c compilations. HC_OPTS included the WAY_* opts, which
244 # must be included in both types of compilations.
245
246 rts_CC_OPTS += $(WARNING_OPTS)
247 rts_CC_OPTS += $(STANDARD_OPTS)
248
249 rts_HC_OPTS += $(STANDARD_OPTS) -package-name rts
250
251 ifneq "$(GhcWithSMP)" "YES"
252 rts_CC_OPTS += -DNOSMP
253 rts_HC_OPTS += -optc-DNOSMP
254 endif
255
256 ifeq "$(UseLibFFIForAdjustors)" "YES"
257 rts_CC_OPTS += -DUSE_LIBFFI_FOR_ADJUSTORS
258 endif
259
260 # Mac OS X: make sure we compile for the right OS version
261 rts_CC_OPTS += $(MACOSX_DEPLOYMENT_CC_OPTS)
262 rts_HC_OPTS += $(addprefix -optc, $(MACOSX_DEPLOYMENT_CC_OPTS))
263 rts_LD_OPTS += $(addprefix -optl, $(MACOSX_DEPLOYMENT_LD_OPTS))
264
265 # We *want* type-checking of hand-written cmm.
266 rts_HC_OPTS += -dcmm-lint
267
268 # -fno-strict-aliasing is required for the runtime, because we often
269 # use a variety of types to represent closure pointers (StgPtr,
270 # StgClosure, StgMVar, etc.), and without -fno-strict-aliasing gcc is
271 # allowed to assume that these pointers do not alias. eg. without
272 # this flag we get problems in sm/Evac.c:copy() with gcc 3.4.3, the
273 # upd_evacee() assigments get moved before the object copy.
274 rts_CC_OPTS += -fno-strict-aliasing
275
276 rts_CC_OPTS += -fno-common
277
278 ifeq "$(BeConservative)" "YES"
279 rts_CC_OPTS += -DBE_CONSERVATIVE
280 endif
281
282 #-----------------------------------------------------------------------------
283 # Flags for compiling specific files
284
285 # If RtsMain.c is built with optimisation then the SEH exception stuff on
286 # Windows gets confused.
287 # This has to be in HC rather than CC opts, as otherwise there's a
288 # -optc-O2 that comes after it.
289 rts/RtsMain_HC_OPTS += -optc-O0
290
291 rts/RtsMessages_CC_OPTS += -DProjectVersion=\"$(ProjectVersion)\"
292 rts/RtsUtils_CC_OPTS += -DProjectVersion=\"$(ProjectVersion)\"
293 rts/Trace_CC_OPTS += -DProjectVersion=\"$(ProjectVersion)\"
294 #
295 rts/RtsUtils_CC_OPTS += -DHostPlatform=\"$(HOSTPLATFORM)\"
296 rts/RtsUtils_CC_OPTS += -DHostArch=\"$(HostArch_CPP)\"
297 rts/RtsUtils_CC_OPTS += -DHostOS=\"$(HostOS_CPP)\"
298 rts/RtsUtils_CC_OPTS += -DHostVendor=\"$(HostVendor_CPP)\"
299 #
300 rts/RtsUtils_CC_OPTS += -DBuildPlatform=\"$(BUILDPLATFORM)\"
301 rts/RtsUtils_CC_OPTS += -DBuildArch=\"$(BuildArch_CPP)\"
302 rts/RtsUtils_CC_OPTS += -DBuildOS=\"$(BuildOS_CPP)\"
303 rts/RtsUtils_CC_OPTS += -DBuildVendor=\"$(BuildVendor_CPP)\"
304 #
305 rts/RtsUtils_CC_OPTS += -DTargetPlatform=\"$(TARGETPLATFORM)\"
306 rts/RtsUtils_CC_OPTS += -DTargetArch=\"$(TargetArch_CPP)\"
307 rts/RtsUtils_CC_OPTS += -DTargetOS=\"$(TargetOS_CPP)\"
308 rts/RtsUtils_CC_OPTS += -DTargetVendor=\"$(TargetVendor_CPP)\"
309 #
310 rts/RtsUtils_CC_OPTS += -DGhcUnregisterised=\"$(GhcUnregisterised)\"
311 rts/RtsUtils_CC_OPTS += -DGhcEnableTablesNextToCode=\"$(GhcEnableTablesNextToCode)\"
312
313 ifeq "$(GhcUnregisterised)" "YES"
314 rts/PrimOps_HC_OPTS += -DGhcUnregisterised=1
315 rts/Schedule_CC_OPTS += -DGhcUnregisterised=1
316 endif
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_HEADERS) $(DTRACEPROBES_H)
463
464 # -----------------------------------------------------------------------------
465 # compile dtrace probes if dtrace is supported
466
467 ifeq "$(USE_DTRACE)" "YES"
468
469 rts_CC_OPTS += -DDTRACE
470 rts_HC_OPTS += -DDTRACE
471
472 # Apple's dtrace (the only one supported by ghc at the moment) uses
473 # gcc as its preprocessor. If gcc isn't at /usr/bin/gcc, or we need
474 # to force it to use a different gcc, we need to give the path in
475 # the option cpppath.
476
477 ifeq "$(TargetOS_CPP)" "darwin"
478 # Darwin has a flag to tell dtrace which cpp to use.
479 # Unfortunately, this isn't supported on Solaris (See Solaris Dynamic Tracing
480 # Guide, Chapter 16, for the configuration variables available on Solaris)
481 DTRACE_FLAGS = -x cpppath=$(WhatGccIsCalled)
482 endif
483
484 DTRACEPROBES_SRC = rts/RtsProbes.d
485 $(DTRACEPROBES_H): $(DTRACEPROBES_SRC) includes/ghcplatform.h | $$(dir $$@)/.
486 "$(DTRACE)" $(filter -I%,$(rts_CC_OPTS)) -C $(DTRACE_FLAGS) -h -o $@ -s $<
487 endif
488
489 # -----------------------------------------------------------------------------
490 # The RTS package config
491
492 # If -DDEBUG is in effect, adjust package conf accordingly..
493 ifneq "$(strip $(filter -optc-DDEBUG,$(GhcRtsHcOpts)))" ""
494 rts_PACKAGE_CPP_OPTS += -DDEBUG
495 endif
496
497 ifeq "$(HaveLibMingwEx)" "YES"
498 rts_PACKAGE_CPP_OPTS += -DHAVE_LIBMINGWEX
499 endif
500
501 $(eval $(call manual-package-config,rts))
502
503 ifneq "$(BootingFromHc)" "YES"
504 rts/package.conf.inplace : $(includes_H_CONFIG) $(includes_H_PLATFORM)
505 endif
506
507 # -----------------------------------------------------------------------------
508 # installing
509
510 INSTALL_LIBS += $(ALL_RTS_LIBS)
511 INSTALL_LIBS += $(wildcard rts/dist/build/libffi$(soext)*)
512 INSTALL_LIBS += $(wildcard rts/dist/build/$(LIBFFI_DLL))
513
514 install: install_libffi_headers
515
516 .PHONY: install_libffi_headers
517 install_libffi_headers :
518 $(call INSTALL_DIR,"$(DESTDIR)$(ghcheaderdir)")
519 $(call INSTALL_HEADER,$(INSTALL_OPTS),$(libffi_HEADERS),"$(DESTDIR)$(ghcheaderdir)/")
520
521 # -----------------------------------------------------------------------------
522 # cleaning
523
524 $(eval $(call clean-target,rts,dist,rts/dist))
525
526 BINDIST_EXTRAS += rts/package.conf.in
527