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