# Yes, include the interepreter, readline, and Template Haskell extensions
SRC_HC_OPTS += -DGHCI -package template-haskell
-PKG_DEPENDS += template_haskell
+PKG_DEPENDS += template-haskell
ALL_DIRS += ghci
+# If we are going to use dynamic libraries instead of .o files for ghci,
+# we will need to always retain CAFs in the compiler.
+# ghci/keepCAFsForGHCi contains a GNU C __attribute__((constructor))
+# function which sets the keepCAFs flag for the RTS before any Haskell
+# code is run.
+ifeq "$(GhcBuildDylibs)" "YES"
+else
+EXCLUDED_SRCS += ghci/keepCAFsForGHCi.c
+endif
+
# Enable readline if either:
# - we're building stage 1 and $(GhcHasReadline)="YES"
# - we're building stage 2/3, and we have built the readline package
# set GhcCompilerWays instead.
GhcLibWays = $(GhcCompilerWays)
+# override $(GhcLibHcOpts): we want GhcStage2HcOpts to take precedence
+GhcLibHcOpts =
+
# override default definition of HS_IFACES so we can add $(odir)
HS_IFACES = $(addsuffix .$(way_)hi,$(basename $(HS_OBJS)))
endif