#! /usr/bin/runghc \begin{code} import System.Exit(ExitCode(..)) import System.Cmd(rawSystem) import System.IO(hPutStrLn,stderr) import Distribution.Simple import Distribution.Simple.LocalBuildInfo import Distribution.PackageDescription import Distribution.Setup main = defaultMainWithHooks defaultUserHooks{postBuild=mkVSHaskellDll} \end{code} \begin{code} mkVSHaskellDll args verbose pkg_descr localbuildinfo = do hPutStrLn stderr "Building vs_haskell.dll" let ghcPath = compilerPath (compiler localbuildinfo) dlltoolPath = take (length ghcPath-11) ghcPath ++ "gcc-lib\\dlltool" r <- rawSystem dlltoolPath ["--input-def", "src/vs_haskell_babel.def", "--dllname", "vs_haskell_babel.dll", "--output-lib", "dist\\build\\libbabel.a", "-k"] if r /= ExitSuccess then putStrLn (dlltoolPath ++ " failed") else return () rawSystem ghcPath ["dist/build/ComDllMain.o", "-lHS"++showPackageId (package pkg_descr), "-lbabel", "-Ldist/build", "--mk-dll", "-o", "dist/build/vs_haskell.dll", "-optdll--def", "-optdllsrc/ComServer.def", "-package", "Cabal", "-package", "base", "-package", "comlib", "-package", "ghc", "-package", "haskell98", "-lcomctl32", "-threaded", "-optdll-s"] \end{code}