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