# We build the RTS with stage 1
rts_dist_HC = $(GHC_STAGE1)
+rts_INSTALL_INFO = rts
+rts_VERSION = 1.0
+
# merge GhcLibWays and GhcRTSWays but strip out duplicates
rts_WAYS = $(GhcLibWays) $(filter-out $(GhcLibWays),$(GhcRTSWays))
rts_dist_WAYS = $(rts_WAYS)
rts_AUTO_APPLY_CMM = rts/dist/build/AutoApply.cmm
-$(rts_AUTO_APPLY_CMM): $(GENAPPLY_INPLACE)
- "$(GENAPPLY_INPLACE)" >$@
+$(rts_AUTO_APPLY_CMM): $$(genapply_INPLACE)
+ "$(genapply_INPLACE)" >$@
rts/dist/build/sm/Evac_thr.c : rts/sm/Evac.c | $$(dir $$@)/.
cp $< $@
endif
# collect the -l flags that we need to link the rts dyn lib.
-rts/libs.depend : $(GHC_PKG_INPLACE)
- "$(GHC_PKG_INPLACE)" field rts extra-libraries \
+rts/libs.depend : $$(ghc-pkg_INPLACE)
+ "$(ghc-pkg_INPLACE)" field rts extra-libraries \
| sed -e 's/^extra-libraries: //' -e 's/\([a-z0-9]*\)[ ]*/-l\1 /g' > $@
# These are made from rts/win32/libHS*.def which contain lists of
# all the symbols in those libraries used by the RTS.
#
-ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
+ifeq "$(HostOS_CPP)" "mingw32"
ALL_RTS_DEF_LIBNAMES = base ghc-prim
ALL_RTS_DEF_LIBS = \
rts/dist/build/win32/libHSbase.dll.a \
- rts/dist/build/win32/libHSghc-prim.dll.a \
- libffi/build/inst/lib/libffi.dll.a
+ rts/dist/build/win32/libHSghc-prim.dll.a
# -- import libs for the regular Haskell libraries
define make-importlib-def # args $1 = lib name
endif
ifneq "$(BINDIST)" "YES"
+ifneq "$(UseSystemLibFFI)" "YES"
rts_ffi_objs_stamp = rts/dist/ffi/stamp
rts_ffi_objs = rts/dist/ffi/*.o
+
$(rts_ffi_objs_stamp): $(libffi_STATIC_LIB) $(TOUCH_DEP) | $$(dir $$@)/.
cd rts/dist/ffi && $(AR) x ../../../$(libffi_STATIC_LIB)
"$(TOUCH_CMD)" $@
rts/dist/build/$(LIBFFI_DLL): libffi/build/inst/bin/$(LIBFFI_DLL)
cp $< $@
endif
+endif
#-----------------------------------------------------------------------------
# Building one way
ifneq "$$(BINDIST)" "YES"
+rts_dist_$1_HC_OPTS := $$(GhcRtsHcOpts)
+rts_dist_$1_CC_OPTS := $$(GhcRtsCcOpts)
+
# The per-way CC_OPTS
ifneq "$$(findstring debug, $1)" ""
-rts_dist_$1_HC_OPTS =
-rts_dist_$1_CC_OPTS = -g -O0
-else
-rts_dist_$1_HC_OPTS = $$(GhcRtsHcOpts)
-rts_dist_$1_CC_OPTS = $$(GhcRtsCcOpts)
+rts_dist_$1_HC_OPTS += -O0
+rts_dist_$1_CC_OPTS += -fno-omit-frame-pointer -g -O0
+endif
+
+ifneq "$$(findstring dyn, $1)" ""
+ifeq "$$(HostOS_CPP)" "mingw32"
+rts_dist_$1_CC_OPTS += -DCOMPILING_WINDOWS_DLL
+endif
endif
ifneq "$$(findstring thr, $1)" ""
$(call distdir-way-opts,rts,dist,$1)
$(call c-suffix-rules,rts,dist,$1,YES)
$(call cmm-suffix-rules,rts,dist,$1)
-$(call hs-suffix-rules-srcdir,rts,dist,$1,.)
-# hs-suffix-rules-srcdir is needed when BootingFromHc to get the .hc rules
rts_$1_LIB_NAME = libHSrts$$($1_libsuf)
rts_$1_LIB = rts/dist/build/$$(rts_$1_LIB_NAME)
rts_dist_$1_CC_OPTS += -DRtsWay=\"rts_$1\"
+ifneq "$(UseSystemLibFFI)" "YES"
+rts_dist_FFI_SO = rts/dist/build/libffi$(soext)
+else
+rts_dist_FFI_SO =
+endif
+
# Making a shared library for the RTS.
ifneq "$$(findstring dyn, $1)" ""
-ifeq "$$(HOSTPLATFORM)" "i386-unknown-mingw32"
+ifeq "$$(HostOS_CPP)" "mingw32"
$$(rts_$1_LIB) : $$(rts_$1_OBJS) $$(ALL_RTS_DEF_LIBS) rts/libs.depend rts/dist/build/$$(LIBFFI_DLL)
"$$(RM)" $$(RM_OPTS) $$@
"$$(rts_dist_HC)" -package-name rts -shared -dynamic -dynload deploy \
-no-auto-link-packages -Lrts/dist/build -l$(LIBFFI_WINDOWS_LIB) `cat rts/libs.depend` $$(rts_$1_OBJS) $$(ALL_RTS_DEF_LIBS) -o $$@
else
-$$(rts_$1_LIB) : $$(rts_$1_OBJS) $$(rts_$1_DTRACE_OBJS) rts/libs.depend rts/dist/build/libffi$$(soext)
+ifneq "$(UseSystemLibFFI)" "YES"
+LIBFFI_LIBS = -Lrts/dist/build -lffi
+ifeq "$$(TargetOS_CPP)" "linux"
+LIBFFI_LIBS += -optl-Wl,-rpath -optl-Wl,'$$$$ORIGIN'
+endif
+
+else
+# flags will be taken care of in rts/libs.depend
+LIBFFI_LIBS =
+endif
+$$(rts_$1_LIB) : $$(rts_$1_OBJS) $$(rts_$1_DTRACE_OBJS) rts/libs.depend $$(rts_dist_FFI_SO)
"$$(RM)" $$(RM_OPTS) $$@
"$$(rts_dist_HC)" -package-name rts -shared -dynamic -dynload deploy \
- -no-auto-link-packages -Lrts/dist/build -lffi `cat rts/libs.depend` $$(rts_$1_OBJS) \
+ -no-auto-link-packages $$(LIBFFI_LIBS) `cat rts/libs.depend` $$(rts_$1_OBJS) \
$$(rts_$1_DTRACE_OBJS) -o $$@
-ifeq "$$(darwin_HOST_OS)" "1"
- # Ensure library's install name is correct before anyone links with it.
- install_name_tool -id $$(ghclibdir)/$$(rts_$1_LIB_NAME) $$@
-endif
endif
else
$$(rts_$1_LIB) : $$(rts_$1_OBJS) $$(rts_$1_DTRACE_OBJS) $$(rts_ffi_objs_stamp)
# And expand the above for each way:
$(foreach way,$(rts_WAYS),$(eval $(call build-rts-way,$(way))))
+$(eval $(call distdir-opts,rts,dist))
+
#-----------------------------------------------------------------------------
# Flags for compiling every file
rts_CC_OPTS += -DUSE_LIBFFI_FOR_ADJUSTORS
endif
-# Mac OS X: make sure we compile for the right OS version
-rts_CC_OPTS += $(MACOSX_DEPLOYMENT_CC_OPTS)
-rts_HC_OPTS += $(addprefix -optc, $(MACOSX_DEPLOYMENT_CC_OPTS))
-rts_LD_OPTS += $(addprefix -optl, $(MACOSX_DEPLOYMENT_LD_OPTS))
-
# We *want* type-checking of hand-written cmm.
rts_HC_OPTS += -dcmm-lint
rts/RtsUtils_CC_OPTS += -DGhcUnregisterised=\"$(GhcUnregisterised)\"
rts/RtsUtils_CC_OPTS += -DGhcEnableTablesNextToCode=\"$(GhcEnableTablesNextToCode)\"
-ifeq "$(GhcUnregisterised)" "YES"
-rts/PrimOps_HC_OPTS += -DGhcUnregisterised=1
-rts/Schedule_CC_OPTS += -DGhcUnregisterised=1
+ifeq "$(DYNAMIC_BY_DEFAULT)" "YES"
+rts/Linker_CC_OPTS += -DDYNAMIC_BY_DEFAULT
endif
# Compile various performance-critical pieces *without* -fPIC -dynamic
endif
endif
+# add CFLAGS for libffi
# ffi.h triggers prototype warnings, so disable them here:
-rts/Interpreter_CC_OPTS += -Wno-strict-prototypes
-rts/Adjustor_CC_OPTS += -Wno-strict-prototypes
-rts/sm/Storage_CC_OPTS += -Wno-strict-prototypes
+ifeq "$(UseSystemLibFFI)" "YES"
+LIBFFI_CFLAGS = $(addprefix -I,$(FFIIncludeDir))
+else
+LIBFFI_CFLAGS =
+endif
+rts/Interpreter_CC_OPTS += -Wno-strict-prototypes $(LIBFFI_CFLAGS)
+rts/Adjustor_CC_OPTS += -Wno-strict-prototypes $(LIBFFI_CFLAGS)
+rts/sm/Storage_CC_OPTS += -Wno-strict-prototypes $(LIBFFI_CFLAGS)
# inlining warnings happen in Compact
rts/sm/Compact_CC_OPTS += -Wno-inline
endif
+#-----------------------------------------------------------------------------
+# Use system provided libffi
+
+ifeq "$(UseSystemLibFFI)" "YES"
+
+rts_PACKAGE_CPP_OPTS += -DFFI_INCLUDE_DIR=$(FFIIncludeDir)
+rts_PACKAGE_CPP_OPTS += -DFFI_LIB_DIR=$(FFILibDir)
+
+else # UseSystemLibFFI==YES
+
+rts_PACKAGE_CPP_OPTS += -DFFI_INCLUDE_DIR=""
+rts_PACKAGE_CPP_OPTS += -DFFI_LIB_DIR=""
+
+endif
+
# -----------------------------------------------------------------------------
# dependencies
$(eval $(call dependencies,rts,dist,1))
-$(rts_dist_depfile_c_asm) : $(libffi_HEADERS) $(DTRACEPROBES_H)
+$(rts_dist_depfile_c_asm) : $(DTRACEPROBES_H)
+ifneq "$(UseSystemLibFFI)" "YES"
+$(rts_dist_depfile_c_asm) : $(libffi_HEADERS)
+endif
# -----------------------------------------------------------------------------
# compile dtrace probes if dtrace is supported
$(eval $(call manual-package-config,rts))
-ifneq "$(BootingFromHc)" "YES"
rts/package.conf.inplace : $(includes_H_CONFIG) $(includes_H_PLATFORM)
-endif
# -----------------------------------------------------------------------------
# installing
-INSTALL_LIBS += $(ALL_RTS_LIBS)
-INSTALL_LIBS += $(wildcard rts/dist/build/libffi$(soext)*)
-INSTALL_LIBS += $(wildcard rts/dist/build/$(LIBFFI_DLL))
+RTS_INSTALL_LIBS += $(ALL_RTS_LIBS)
+RTS_INSTALL_LIBS += $(wildcard rts/dist/build/libffi$(soext)*)
+RTS_INSTALL_LIBS += $(wildcard rts/dist/build/$(LIBFFI_DLL))
+ifneq "$(UseSystemLibFFI)" "YES"
install: install_libffi_headers
+endif
.PHONY: install_libffi_headers
install_libffi_headers :