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