packages feed

ajhc-0.8.0.5: Setup.hs

{-# LANGUAGE CPP #-}
import Distribution.Simple
import Distribution.Simple.InstallDirs as I
import Distribution.Simple.LocalBuildInfo as L
import qualified Distribution.Simple.Setup as S
import qualified Distribution.Simple.Program as P
import System.FilePath ((</>), splitDirectories)
import qualified System.FilePath.Posix as Px
import Distribution.Package

make verbosity = P.runProgramInvocation verbosity . P.simpleProgramInvocation "make"

pName :: String
pName = "ajhc"

#ifdef mingw32_HOST_OS
(<//>) = (Px.</>)
jhcCmd local  = Px.joinPath $ splitDirectories $
                buildDir local <//> pName <//> pName
jahmCmd local = Px.joinPath $ splitDirectories $
                buildDir local <//> "jahm" <//> "jahm"
#else
jhcCmd local  = buildDir local </>  pName </>  pName
jahmCmd local = buildDir local </> "jahm" </> "jahm"
#endif

buildStdLib pkg local verbosity copy
    = do let dirs = L.absoluteInstallDirs pkg local copy
             idir = datadir dirs
             bdir = bindir dirs
             icmd = jhcCmd local
             jcmd = jahmCmd local
#ifdef mingw32_HOST_OS
             exeExt = ".exe"
#else
             exeExt = ""
#endif
         putStrLn $ "Installing libraries in " ++ idir
         make verbosity
               [ "-f", "Makefile.cabalinst", "build"
               , "TARGET=" ++ idir
               , "JHCPROG=" ++ icmd
               , "JAHMPROG=" ++ jcmd
               , "BINDIR=" ++ bdir
               , "EXEEXT=" ++ exeExt
               ]

installStdLib pkg local verbosity copy
    = do let dirs = L.absoluteInstallDirs pkg local copy
             idir = datadir dirs
             bdir = bindir dirs
             icmd = jhcCmd local
             jcmd = jahmCmd local
#ifdef mingw32_HOST_OS
             exeExt = ".exe"
#else
             exeExt = ""
#endif
         putStrLn $ "Installing libraries in " ++ idir
         make verbosity
               [ "-f", "Makefile.cabalinst", "install"
               , "TARGET=" ++ idir
               , "JHCPROG=" ++ icmd
               , "JAHMPROG=" ++ jcmd
               , "BINDIR=" ++ bdir
               , "EXEEXT=" ++ exeExt
               ]

main :: IO ()
main = defaultMainWithHooks $ simpleUserHooks {
  postBuild = \ _ flags pkg lbi -> do
     let verb = (S.fromFlag $ S.buildVerbosity flags)
     buildStdLib pkg lbi verb NoCopyDest ,
  postInst = \ _ flags pkg lbi -> do
     let verb = (S.fromFlag $ S.installVerbosity flags)
     installStdLib pkg lbi verb NoCopyDest
  }