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