+ | not opt_Static =
+ case (dynLibLoader dflags) of
+ Wrapped wrapmode ->
+ do
+ let (o_base, o_ext) = splitExtension input_fn
+ let wrapped_executable | o_ext == "exe" = (o_base ++ "_real") <.> o_ext
+ | otherwise = input_fn ++ "_real"
+ behaviour <- wrapper_behaviour dflags wrapmode dep_packages
+
+ -- THINKME isn't this possible to do a bit nicer?
+ let behaviour' = concatMap (\x -> if x=='\\' then "\\\\" else [x]) behaviour
+ renameFile input_fn wrapped_executable
+ let rtsDetails = (getPackageDetails (pkgState dflags) rtsPackageId);
+ SysTools.runCc dflags
+ ([ SysTools.FileOption "" ((head (libraryDirs rtsDetails)) ++ "/dyn-wrapper.c")
+ , SysTools.Option ("-DBEHAVIOUR=\"" ++ behaviour' ++ "\"")
+ , SysTools.Option "-o"
+ , SysTools.FileOption "" input_fn
+ ] ++ map (SysTools.FileOption "-I") (includeDirs rtsDetails))
+ return True
+ _ -> return True
+ | otherwise = return True
+
+wrapper_behaviour :: DynFlags -> Maybe [Char] -> [PackageId] -> IO [Char]
+wrapper_behaviour dflags mode dep_packages =
+ let seperateBySemiColon strs = tail $ concatMap (';':) strs
+ in case mode of
+ Nothing -> do
+ pkg_lib_paths <- getPackageLibraryPath dflags dep_packages
+ return ('H' : (seperateBySemiColon pkg_lib_paths))
+ Just s -> do
+ allpkg <- getPreloadPackagesAnd dflags dep_packages
+ putStrLn (unwords (map (packageIdString . packageConfigId) allpkg))
+ return $ 'F':s ++ ';':(seperateBySemiColon (map (packageIdString . packageConfigId) allpkg))