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