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