+# Link a dynamic library
+# On windows we have to supply the extra libs this one links to when building it.
+ifeq "$$(HOSTPLATFORM)" "i386-unknown-mingw32"
+$$($1_$2_$3_LIB) : $$($1_$2_$3_ALL_OBJS) $$(ALL_RTS_LIBS) $$($1_$2_$3_DEPS_LIBS)
+ "$$($1_$2_HC)" $$($1_$2_$3_ALL_OBJS) \
+ `$$($1_$2_$3_MKSTUBOBJS)` \
+ -shared -dynamic -dynload deploy \
+ $$(addprefix -l,$$($1_$2_EXTRA_LIBRARIES)) \
+ -no-auto-link-packages $$(addprefix -package ,$$($1_$2_DEPS)) \
+ -o $$@
+else
+$$($1_$2_$3_LIB) : $$($1_$2_$3_ALL_OBJS) $$(ALL_RTS_LIBS) $$($1_$2_$3_DEPS_LIBS)
+ "$$($1_$2_HC)" $$($1_$2_$3_ALL_OBJS) \
+ `$$($1_$2_$3_MKSTUBOBJS)` \
+ -shared -dynamic -dynload deploy \
+ -dylib-install-name $(ghclibdir)/`basename "$$@" | sed 's/^libHS//;s/[-]ghc.*//'`/`basename "$$@"` \
+ -no-auto-link-packages $$(addprefix -package ,$$($1_$2_DEPS)) \
+ -o $$@
+endif
+else