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