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