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