+#
+# Building DLLs is only supported on mingw32 at the moment.
+#
+DLL_NAME = HSrts.dll
+ifeq "$(way)" "dll"
+DLL_IMPLIB_NAME = libHSrts_imp.a
+SRC_BLD_DLL_OPTS += --export-all -lwinmm -lHS_imp_stub -lgmp -L. -Lgmp
+
+#
+# Need an import library containing the symbols the RTS uses from the Prelude.
+# So, to avoid bootstrapping trouble, we build one containing just the syms
+# we need. Weirdly named to avoid clashing later on when compiling the contents
+# of ghc/lib/..
+#
+# Note: if you do change the name of the Prelude DLL, the "--dllname <nm>.dll"
+# below will need to be updated as well.
+
+$(DLL_NAME) :: libHS_imp_stub.a
+
+libHS_imp_stub.a :
+ dlltool --output-lib libHS_imp_stub.a --def HSprel.def --dllname HSstd.dll
+
+# It's not included in the DLL, but we need to compile it up separately.
+all :: Main.dll_o
+
+endif
+
+# -----------------------------------------------------------------------------