Enable new warning for fragile/incorrect CPP #if usage
[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 ifeq "$(GccLT46)" "NO"
272 WARNING_OPTS += -Wundef
273 endif
274
275 # These ones are hard to avoid:
276 #WARNING_OPTS += -Wconversion
277 #WARNING_OPTS += -Wbad-function-cast
278 #WARNING_OPTS += -Wshadow
279 #WARNING_OPTS += -Wcast-qual
280
281 # This one seems buggy on GCC 4.1.2, which is the only GCC version we
282 # have that can bootstrap the SPARC build. We end up with lots of supurious
283 # warnings of the form "cast increases required alignment of target type".
284 # Some legitimate warnings can be fixed by adding an intermediate cast to
285 # (void*), but we get others in rts/sm/GCUtils.c concerning the gct var
286 # that look innocuous to me. We could enable this again once we deprecate
287 # support for registerised builds on this arch. -- BL 2010/02/03
288 # WARNING_OPTS += -Wcast-align
289
290 STANDARD_OPTS += $(addprefix -I,$(GHC_INCLUDE_DIRS)) -Irts -Irts/dist/build
291 # COMPILING_RTS is only used when building Win32 DLL support.
292 STANDARD_OPTS += -DCOMPILING_RTS
293
294 # HC_OPTS is included in both .c and .cmm compilations, whereas CC_OPTS is
295 # only included in .c compilations. HC_OPTS included the WAY_* opts, which
296 # must be included in both types of compilations.
297
298 rts_CC_OPTS += $(WARNING_OPTS)
299 rts_CC_OPTS += $(STANDARD_OPTS)
300
301 rts_HC_OPTS += $(STANDARD_OPTS) -this-unit-id rts
302
303 ifneq "$(GhcWithSMP)" "YES"
304 rts_CC_OPTS += -DNOSMP
305 rts_HC_OPTS += -optc-DNOSMP
306 endif
307
308 ifeq "$(UseLibFFIForAdjustors)" "YES"
309 rts_CC_OPTS += -DUSE_LIBFFI_FOR_ADJUSTORS
310 endif
311
312 # We *want* type-checking of hand-written cmm.
313 rts_HC_OPTS += -dcmm-lint
314
315 # -fno-strict-aliasing is required for the runtime, because we often
316 # use a variety of types to represent closure pointers (StgPtr,
317 # StgClosure, StgMVar, etc.), and without -fno-strict-aliasing gcc is
318 # allowed to assume that these pointers do not alias. eg. without
319 # this flag we get problems in sm/Evac.c:copy() with gcc 3.4.3, the
320 # upd_evacuee() assignments get moved before the object copy.
321 rts_CC_OPTS += -fno-strict-aliasing
322
323 rts_CC_OPTS += -fno-common
324
325 ifeq "$(BeConservative)" "YES"
326 rts_CC_OPTS += -DBE_CONSERVATIVE
327 endif
328
329 # Set Windows version
330 ifeq "$$(TargetOS_CPP)" "mingw32"
331 rts_CC_OPTS += -DWINVER=$(rts_WINVER)
332 endif
333
334 #-----------------------------------------------------------------------------
335 # Flags for compiling specific files
336 rts/RtsMessages_CC_OPTS += -DProjectVersion=\"$(ProjectVersion)\"
337 rts/RtsUtils_CC_OPTS += -DProjectVersion=\"$(ProjectVersion)\"
338 rts/Trace_CC_OPTS += -DProjectVersion=\"$(ProjectVersion)\"
339 #
340 rts/RtsUtils_CC_OPTS += -DHostPlatform=\"$(HOSTPLATFORM)\"
341 rts/RtsUtils_CC_OPTS += -DHostArch=\"$(HostArch_CPP)\"
342 rts/RtsUtils_CC_OPTS += -DHostOS=\"$(HostOS_CPP)\"
343 rts/RtsUtils_CC_OPTS += -DHostVendor=\"$(HostVendor_CPP)\"
344 #
345 rts/RtsUtils_CC_OPTS += -DBuildPlatform=\"$(BUILDPLATFORM)\"
346 rts/RtsUtils_CC_OPTS += -DBuildArch=\"$(BuildArch_CPP)\"
347 rts/RtsUtils_CC_OPTS += -DBuildOS=\"$(BuildOS_CPP)\"
348 rts/RtsUtils_CC_OPTS += -DBuildVendor=\"$(BuildVendor_CPP)\"
349 #
350 rts/RtsUtils_CC_OPTS += -DTargetPlatform=\"$(TARGETPLATFORM)\"
351 rts/RtsUtils_CC_OPTS += -DTargetArch=\"$(TargetArch_CPP)\"
352 rts/RtsUtils_CC_OPTS += -DTargetOS=\"$(TargetOS_CPP)\"
353 rts/RtsUtils_CC_OPTS += -DTargetVendor=\"$(TargetVendor_CPP)\"
354 #
355 rts/RtsUtils_CC_OPTS += -DGhcUnregisterised=\"$(GhcUnregisterised)\"
356 rts/RtsUtils_CC_OPTS += -DGhcEnableTablesNextToCode=\"$(GhcEnableTablesNextToCode)\"
357
358 # Compile various performance-critical pieces *without* -fPIC -dynamic
359 # even when building a shared library. If we don't do this, then the
360 # GC runs about 50% slower on x86 due to the overheads of PIC. The
361 # cost of doing this is a little runtime linking and less sharing, but
362 # not much.
363 #
364 # On x86_64 this doesn't work, because all objects in a shared library
365 # must be compiled with -fPIC (since the 32-bit relocations generated
366 # by the default small memory can't be resolved at runtime). So we
367 # only do this on i386.
368 #
369 # This apparently doesn't work on OS X (Darwin) nor on Solaris.
370 # On Darwin we get errors of the form
371 #
372 # 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
373 #
374 # and lots of these warnings:
375 #
376 # ld: warning codegen in _stg_ap_pppv_fast (offset 0x0000005E) prevents image from loading in dyld shared cache
377 #
378 # On Solaris we get errors like:
379 #
380 # Text relocation remains referenced
381 # against symbol offset in file
382 # .rodata (section) 0x11 rts/dist/build/Apply.dyn_o
383 # ...
384 # ld: fatal: relocations remain against allocatable but non-writable sections
385 # collect2: ld returned 1 exit status
386
387 ifeq "$(TargetArch_CPP)" "i386"
388 i386_SPEED_HACK := "YES"
389 ifeq "$(TargetOS_CPP)" "darwin"
390 i386_SPEED_HACK := "NO"
391 endif
392 ifeq "$(TargetOS_CPP)" "solaris2"
393 i386_SPEED_HACK := "NO"
394 endif
395 endif
396
397 ifeq "$(TargetArch_CPP)" "i386"
398 ifeq "$(i386_SPEED_HACK)" "YES"
399 rts/sm/Evac_HC_OPTS += -fno-PIC
400 rts/sm/Evac_thr_HC_OPTS += -fno-PIC
401 rts/sm/Scav_HC_OPTS += -fno-PIC
402 rts/sm/Scav_thr_HC_OPTS += -fno-PIC
403 rts/sm/Compact_HC_OPTS += -fno-PIC
404 rts/sm/GC_HC_OPTS += -fno-PIC
405
406 # -static is also necessary for these bits, otherwise the NCG
407 # -generates dynamic references:
408 rts/Updates_HC_OPTS += -fno-PIC -static
409 rts/StgMiscClosures_HC_OPTS += -fno-PIC -static
410 rts/PrimOps_HC_OPTS += -fno-PIC -static
411 rts/Apply_HC_OPTS += -fno-PIC -static
412 rts/dist/build/AutoApply_HC_OPTS += -fno-PIC -static
413 endif
414 endif
415
416 # add CFLAGS for libffi
417 # ffi.h triggers prototype warnings, so disable them here:
418 ifeq "$(UseSystemLibFFI)" "YES"
419 LIBFFI_CFLAGS = $(addprefix -I,$(FFIIncludeDir))
420 else
421 LIBFFI_CFLAGS =
422 endif
423 rts/Interpreter_CC_OPTS += -Wno-strict-prototypes $(LIBFFI_CFLAGS)
424 rts/Adjustor_CC_OPTS += -Wno-strict-prototypes $(LIBFFI_CFLAGS)
425 rts/sm/Storage_CC_OPTS += -Wno-strict-prototypes $(LIBFFI_CFLAGS)
426
427 # inlining warnings happen in Compact
428 rts/sm/Compact_CC_OPTS += -Wno-inline
429
430 # emits warnings about call-clobbered registers on x86_64
431 rts/StgCRun_CC_OPTS += -w
432
433 rts/RetainerProfile_CC_OPTS += -w
434 rts/RetainerSet_CC_OPTS += -Wno-format
435 # On Windows:
436 rts/win32/ConsoleHandler_CC_OPTS += -w
437 rts/win32/ThrIOManager_CC_OPTS += -w
438 # The above warning suppression flags are a temporary kludge.
439 # While working on this module you are encouraged to remove it and fix
440 # any warnings in the module. See
441 # http://ghc.haskell.org/trac/ghc/wiki/WorkingConventions#Warnings
442 # for details
443
444 # Without this, thread_obj will not be inlined (at least on x86 with GCC 4.1.0)
445 ifneq "$(CC_CLANG_BACKEND)" "1"
446 rts/sm/Compact_CC_OPTS += -finline-limit=2500
447 endif
448
449 # -O3 helps unroll some loops (especially in copy() with a constant argument).
450 rts/sm/Evac_CC_OPTS += -funroll-loops
451 rts/sm/Evac_thr_HC_OPTS += -optc-funroll-loops
452
453
454 #-----------------------------------------------------------------------------
455 # Use system provided libffi
456
457 ifeq "$(UseSystemLibFFI)" "YES"
458
459 rts_PACKAGE_CPP_OPTS += -DFFI_INCLUDE_DIR=$(FFIIncludeDir)
460 rts_PACKAGE_CPP_OPTS += -DFFI_LIB_DIR=$(FFILibDir)
461 rts_PACKAGE_CPP_OPTS += '-DFFI_LIB='
462
463 else # UseSystemLibFFI==YES
464
465 rts_PACKAGE_CPP_OPTS += -DFFI_INCLUDE_DIR=
466 rts_PACKAGE_CPP_OPTS += -DFFI_LIB_DIR=
467 rts_PACKAGE_CPP_OPTS += '-DFFI_LIB="C$(LIBFFI_NAME)"'
468
469 endif
470
471 # -----------------------------------------------------------------------------
472 # dependencies
473
474 rts_WAYS_DASHED = $(subst $(space),,$(patsubst %,-%,$(strip $(rts_WAYS))))
475 rts_dist_depfile_base = rts/dist/build/.depend$(rts_WAYS_DASHED)
476
477 rts_dist_C_SRCS = $(rts_C_SRCS) $(rts_thr_EXTRA_C_SRCS)
478 rts_dist_S_SRCS = $(rts_S_SRCS)
479 rts_dist_CMM_SRCS = $(rts_CMM_SRCS)
480 rts_dist_C_FILES = $(rts_dist_C_SRCS)
481 rts_dist_S_FILES = $(rts_dist_S_SRCS)
482 rts_dist_CMM_FILES = $(rts_dist_CMM_SRCS)
483
484 # Hack: we define every way-related option here, so that we get (hopefully)
485 # a superset of the dependencies. To do this properly, we should generate
486 # a different set of dependencies for each way. Further hack: PROFILING an
487
488 # TICKY_TICKY can't be used together, so we omit TICKY_TICKY for now.
489 rts_dist_MKDEPENDC_OPTS += -DPROFILING -DTHREADED_RTS -DDEBUG
490
491 ifeq "$(USE_DTRACE)" "YES"
492
493 rts_dist_MKDEPENDC_OPTS += -Irts/dist/build
494
495 endif
496
497 $(eval $(call dependencies,rts,dist,1))
498
499 $(rts_dist_depfile_c_asm) : $(DTRACEPROBES_H)
500 ifneq "$(UseSystemLibFFI)" "YES"
501 $(rts_dist_depfile_c_asm) : $(libffi_HEADERS)
502 endif
503
504 # -----------------------------------------------------------------------------
505 # compile dtrace probes if dtrace is supported
506
507 ifeq "$(USE_DTRACE)" "YES"
508
509 rts_CC_OPTS += -DDTRACE
510 rts_HC_OPTS += -DDTRACE
511
512 # Apple's dtrace (the only one supported by ghc at the moment) uses
513 # gcc as its preprocessor. If gcc isn't at /usr/bin/gcc, or we need
514 # to force it to use a different gcc, we need to give the path in
515 # the option cpppath.
516
517 ifeq "$(TargetOS_CPP)" "darwin"
518 # Darwin has a flag to tell dtrace which cpp to use.
519 # Unfortunately, this isn't supported on Solaris (See Solaris Dynamic Tracing
520 # Guide, Chapter 16, for the configuration variables available on Solaris)
521 DTRACE_FLAGS = -x cpppath=$(CC)
522 endif
523
524 DTRACEPROBES_SRC = rts/RtsProbes.d
525 $(DTRACEPROBES_H): $(DTRACEPROBES_SRC) includes/ghcplatform.h | $$(dir $$@)/.
526 "$(DTRACE)" $(filter -I%,$(rts_CC_OPTS)) -C $(DTRACE_FLAGS) -h -o $@ -s $<
527 endif
528
529 # -----------------------------------------------------------------------------
530 # The RTS package config
531
532 # If -DDEBUG is in effect, adjust package conf accordingly..
533 ifneq "$(strip $(filter -optc-DDEBUG,$(GhcRtsHcOpts)))" ""
534 rts_PACKAGE_CPP_OPTS += -DDEBUG
535 endif
536
537 ifeq "$(HaveLibMingwEx)" "YES"
538 rts_PACKAGE_CPP_OPTS += -DHAVE_LIBMINGWEX
539 endif
540
541 $(eval $(call manual-package-config,rts))
542
543 rts/package.conf.inplace : $(includes_H_CONFIG) $(includes_H_PLATFORM)
544
545 # -----------------------------------------------------------------------------
546 # installing
547
548 RTS_INSTALL_LIBS += $(ALL_RTS_LIBS)
549 ifneq "$(UseSystemLibFFI)" "YES"
550 RTS_INSTALL_LIBS += $(wildcard rts/dist/build/lib$(LIBFFI_NAME)*$(soext)*)
551 RTS_INSTALL_LIBS += $(foreach w,$(filter-out %dyn,$(rts_WAYS)),rts/dist/build/libC$(LIBFFI_NAME)$($w_libsuf))
552 endif
553
554 ifneq "$(UseSystemLibFFI)" "YES"
555 install: install_libffi_headers
556 endif
557
558 .PHONY: install_libffi_headers
559 install_libffi_headers :
560 $(INSTALL_DIR) "$(DESTDIR)$(ghcheaderdir)"
561 $(INSTALL_HEADER) $(INSTALL_OPTS) $(libffi_HEADERS) "$(DESTDIR)$(ghcheaderdir)/"
562
563 # -----------------------------------------------------------------------------
564 # cleaning
565
566 $(eval $(call clean-target,rts,dist,rts/dist))
567
568 BINDIST_EXTRAS += rts/package.conf.in
569