diff --git a/shake-ats.cabal b/shake-ats.cabal
--- a/shake-ats.cabal
+++ b/shake-ats.cabal
@@ -1,5 +1,5 @@
 name:                shake-ats
-version:             1.2.0.0
+version:             1.3.0.0
 synopsis:            Utilities for building ATS projects with shake
 description:         Various helper functions for building [ATS](http://www.ats-lang.org/) with the [shake](http://shakebuild.com/) library
 homepage:            https://github.com/vmchale/shake-ats#readme
@@ -24,6 +24,7 @@
   exposed-modules:     Development.Shake.ATS
   other-modules:       Development.Shake.ATS.Type
                      , Development.Shake.ATS.Rules
+                     , Development.Shake.ATS.Environment
   build-depends:       base >= 4.7 && < 5
                      , language-ats
                      , shake-ext >= 2.1.0.0
diff --git a/src/Development/Shake/ATS.hs b/src/Development/Shake/ATS.hs
--- a/src/Development/Shake/ATS.hs
+++ b/src/Development/Shake/ATS.hs
@@ -19,53 +19,34 @@
                              , Version (..)
                              , ForeignCabal (..)
                              , BinaryTarget (..)
+                             , ATSToolConfig (..)
                              ) where
 
 import           Control.Monad
 import           Control.Monad.IO.Class
-import           Data.Bool                   (bool)
-import           Data.Either                 (fromRight)
-import           Data.List                   (intercalate)
-import           Data.Maybe                  (fromMaybe)
-import           Data.Semigroup              (Semigroup (..))
-import qualified Data.Text.Lazy              as TL
+import           Data.Bool                         (bool)
+import           Data.Either                       (fromRight)
+import           Data.List                         (intercalate)
+import           Data.Maybe                        (fromMaybe)
+import           Data.Semigroup                    (Semigroup (..))
+import qualified Data.Text.Lazy                    as TL
 import           Development.Shake
+import           Development.Shake.ATS.Environment
 import           Development.Shake.ATS.Rules
 import           Development.Shake.ATS.Type
 import           Development.Shake.FilePath
 import           Language.ATS
-import           Language.ATS.Generate
-import           System.Directory            (copyFile, createDirectoryIfMissing)
-import           System.Exit                 (ExitCode (ExitSuccess))
-
--- | Given a plain Haskell source file, generate a @.sats@ file containing
--- analogous types.
-genATS :: FilePath -- ^ Haskell source
-       -> FilePath -- ^ @.sats@ file to generate
-       -> Rules ()
-genATS src target =
-    target %> \out -> liftIO $ do
-        createDirectoryIfMissing True (takeDirectory out)
-        genATSTypes src target
-
--- | The directory @~/.atspkg@
-pkgHome :: Action String
-pkgHome = fromMaybe "/usr/local/" <$> mh
-    where mh = fmap (++ "/.atspkg/") <$> getEnv "HOME"
-
--- | The directory that will be @PATSHOME@.
-patsHome :: Version -> Action String
-patsHome v = fmap (++ (show v ++ "/")) pkgHome
+import           System.Directory                  (copyFile, createDirectoryIfMissing)
+import           System.Exit                       (ExitCode (ExitSuccess))
 
 -- | Run @patsopt@ given information about
-atsCommand :: CmdResult r => Version -- ^ Compiler version
-                          -> Version -- ^ Standard library version
+atsCommand :: CmdResult r => ATSToolConfig
                           -> String -- ^ Source file
                           -> String -- ^ C code to be generated
                           -> Action r
-atsCommand v v' sourceFile out = do
-    h <- patsHome v'
-    let home = h ++ "lib/ats2-postiats-" ++ show v
+atsCommand tc sourceFile out = do
+    h <- patsHome (compilerVer tc)
+    let home = h ++ "lib/ats2-postiats-" ++ show (libVersion tc)
     let atsArgs = [EchoStderr False, AddEnv "PATSHOME" home]
         patsc = home ++ "/bin/patsopt"
     command atsArgs patsc ["--output", out, "-dd", sourceFile, "-cc"]
@@ -76,8 +57,8 @@
 
 -- Copy source files to the appropriate place. This is necessary because
 -- @#include@s in ATS are weird.
-copySources :: Version -> Version -> [FilePath] -> Action ()
-copySources v v' sources =
+copySources :: ATSToolConfig -> [FilePath] -> Action ()
+copySources (ATSToolConfig v v') sources =
     forM_ sources $ \dep -> do
         h <- patsHome v'
         let home = h ++ "lib/ats2-postiats-" ++ show v
@@ -92,11 +73,12 @@
 -- TODO depend on GHC version?
 makeCFlags :: [String] -- ^ Inputs
            -> [ForeignCabal] -- ^ Haskell libraries
+           -> String -- ^ GHC version
            -> Bool -- ^ Whether to use the Garbage collector
            -> [String]
-makeCFlags ss fc b = gcFlag' : (hsExtra <> ss) where
+makeCFlags ss fc ghcVersion b = gcFlag' : (hsExtra <> ss) where
     gcFlag' = bool ("-optc" <>) id noHs $ gcFlag b
-    hsExtra = bool ["--make", "-odir", ".atspkg", "-no-hs-main", "-package-db", "~/.cabal/store/ghc-8.2.2/package.db/"] mempty noHs
+    hsExtra = bool ["--make", "-odir", ".atspkg", "-no-hs-main", "-package-db", "~/.cabal/store/ghc-" ++ ghcVersion ++ "/package.db/"] mempty noHs
     noHs = null fc
 
 -- TODO ideally cache C files and use `gcc` on them?
@@ -110,12 +92,12 @@
         mapM_ cabalExport hsLibs
 
     binTarget %> \_ -> do
-        h <- patsHome compilerVer
+        h <- patsHome (compilerVer toolConfig)
         h' <- pkgHome
-        let home = h ++ "lib/ats2-postiats-" ++ show libVersion
+        let home = h ++ "lib/ats2-postiats-" ++ show (libVersion toolConfig)
         sources <- transitiveDeps (snd <$> genTargets) [src]
         need (sources ++ (TL.unpack . objectFile <$> hsLibs))
-        copySources libVersion compilerVer sources
+        copySources toolConfig sources
 
         cmd_ ["mkdir", "-p", dropDirectory1 binTarget]
         path <- fromMaybe "" <$> getEnv "PATH"
@@ -126,36 +108,28 @@
             (home ++ "/bin/patscc")
             (mconcat
                 [ [src, "-atsccomp", cc ++ " -I" ++ h ++ "/ccomp/runtime/ -I" ++ h ++ " -L" ++ h' ++ "/lib" ++ " -L" ++ home ++ "/ccomp/atslib/lib", "-o", binTarget, "-cleanaft"]
-                , makeCFlags cFlags hsLibs gc
+                , makeCFlags cFlags hsLibs "8.2.2" gc
                 , toLibs libs'
                 ])
 
-handleSource :: Version -> Version -> FilePath -> Action ()
-handleSource v v' sourceFile = do
-        sources <- transitiveDeps [] [sourceFile]
-        need sources
-        copySources v v' sources
-
--- | This provides rules for generating C code from ATS source files in the
--- @ats-src@ directory.
-cgen :: Version -- ^ Library version
-     -> Version -- ^ Compiler version
+-- given directory.
+cgen :: ATSToolConfig
      -> FilePath -- ^ Directory containing ATS source code
      -> Rules ()
-cgen v v' dir =
+cgen tc dir =
 
     "//*.c" %> \out -> do
         let sourceFile = dir ++ "/" ++ (takeBaseName out -<.> "dats")
-        handleSource v v' sourceFile
-        atsCommand v v' sourceFile out
+        handleSource tc sourceFile
+        atsCommand tc sourceFile out
 
-fixDir :: FilePath -> String -> String
-fixDir p =
-      TL.unpack
-    . TL.replace (TL.pack "./") (TL.pack $ p ++ "/")
-    . TL.replace (TL.pack "../") (TL.pack $ joinPath (init $ splitPath p) ++ "/")
-    . TL.pack
+handleSource :: ATSToolConfig -> FilePath -> Action ()
+handleSource tc sourceFile = do
+    sources <- transitiveDeps [] [sourceFile]
+    need sources
+    copySources tc sources
 
+-- | This provides rules for generating C code from ATS source files in the
 trim :: String -> String
 trim = init . drop 1
 
@@ -170,17 +144,16 @@
     pure $ (p:deps) ++ deps'
 
 -- | This uses @pats-filter@ to prettify the errors.
-cgenPretty :: Version -- ^ Library version
-           -> Version -- ^ Compiler version
+cgenPretty :: ATSToolConfig
            -> FilePath
            -> Rules ()
-cgenPretty v v' dir =
+cgenPretty tc dir =
 
     "//*.c" %> \out -> do
 
         let sourceFile = dir ++ "/" ++ (takeBaseName out -<.> "dats")
-        handleSource v v' sourceFile
-        (Exit c, Stderr err) :: (Exit, Stderr String) <- atsCommand v v' sourceFile out
+        handleSource tc sourceFile
+        (Exit c, Stderr err) :: (Exit, Stderr String) <- atsCommand tc sourceFile out
         cmd_ [Stdin err] Shell "pats-filter"
         if c /= ExitSuccess
             then error "patscc failure"
diff --git a/src/Development/Shake/ATS/Environment.hs b/src/Development/Shake/ATS/Environment.hs
new file mode 100644
--- /dev/null
+++ b/src/Development/Shake/ATS/Environment.hs
@@ -0,0 +1,26 @@
+module Development.Shake.ATS.Environment ( fixDir
+                                         , pkgHome
+                                         , patsHome
+                                         ) where
+
+import           Data.Maybe                  (fromMaybe)
+import qualified Data.Text.Lazy              as TL
+import           Development.Shake
+import           Development.Shake.ATS.Type
+import           Development.Shake.FilePath
+
+-- | The directory @~/.atspkg@
+pkgHome :: Action String
+pkgHome = fromMaybe "/usr/local/" <$> mh
+    where mh = fmap (++ "/.atspkg/") <$> getEnv "HOME"
+
+-- | The directory that will be @PATSHOME@.
+patsHome :: Version -> Action String
+patsHome v = fmap (++ (show v ++ "/")) pkgHome
+
+fixDir :: FilePath -> String -> String
+fixDir p =
+      TL.unpack
+    . TL.replace (TL.pack "./") (TL.pack $ p ++ "/")
+    . TL.replace (TL.pack "../") (TL.pack $ joinPath (init $ splitPath p) ++ "/")
+    . TL.pack
diff --git a/src/Development/Shake/ATS/Rules.hs b/src/Development/Shake/ATS/Rules.hs
--- a/src/Development/Shake/ATS/Rules.hs
+++ b/src/Development/Shake/ATS/Rules.hs
@@ -2,6 +2,7 @@
                                    , cleanATS
                                    , cabalExport
                                    , getSubdirs
+                                   , genATS
                                    ) where
 
 import           Control.Monad
@@ -11,7 +12,18 @@
 import           Development.Shake.ATS.Type hiding (BinaryTarget (..))
 import           Development.Shake.Cabal
 import           Development.Shake.FilePath
-import           System.Directory           (copyFile, doesDirectoryExist, listDirectory)
+import           System.Directory           (copyFile, createDirectoryIfMissing, doesDirectoryExist, listDirectory)
+import           Language.ATS.Generate
+
+-- | Given a plain Haskell source file, generate a @.sats@ file containing
+-- analogous types.
+genATS :: FilePath -- ^ Haskell source
+       -> FilePath -- ^ @.sats@ file to generate
+       -> Rules ()
+genATS src target =
+    target %> \out -> liftIO $ do
+        createDirectoryIfMissing True (takeDirectory out)
+        genATSTypes src target
 
 getSubdirs :: FilePath -> IO [FilePath]
 getSubdirs p = do
diff --git a/src/Development/Shake/ATS/Type.hs b/src/Development/Shake/ATS/Type.hs
--- a/src/Development/Shake/ATS/Type.hs
+++ b/src/Development/Shake/ATS/Type.hs
@@ -1,12 +1,17 @@
 {-# LANGUAGE DeriveAnyClass #-}
 {-# LANGUAGE DeriveGeneric  #-}
 
+
+-- gcc -c -o lib1.o lib1.c
+-- ar rcs libout.a out1.o out2.o
 -- gcc ats-src/libnumbertheory.o -shared -o ats-src/libnumbertheory.so
 -- gcc number-theory-ffi_dats.c -c -fPIC -o ats-src/libnumbertheory.o -IATS2-Postiats-include-0.3.8/ -IATS2-Postiats-include-0.3.8/ccomp/runtime/
 
 module Development.Shake.ATS.Type ( ForeignCabal (..)
                                   , Version (..)
                                   , BinaryTarget (..)
+                                  , ArtifactType (..)
+                                  , ATSToolConfig (..)
                                   ) where
 
 import           Data.Binary    (Binary (..))
@@ -26,17 +31,41 @@
 --
 -- AND variations on these where a Haskell library is to be built
 -- Or a C library.
+--
+-- Also they should account for whatever `atspkg` installs.
 
-data BinaryTarget = BinaryTarget { cc          :: String -- ^ C compiler to be used.
-                                 , cFlags      :: [String] -- ^ Flags to be passed to the C compiler
-                                 , libVersion  :: Version
-                                 , compilerVer :: Version
-                                 , gc          :: Bool -- ^ Whether to configure build for use with the garbage collector.
-                                 , libs        :: [String] -- ^ Libraries against which to link
-                                 , src         :: String -- ^ Source file for binary.
-                                 , hsLibs      :: [ForeignCabal] -- ^ Cabal-based Haskell libraries
-                                 , genTargets  :: [(String, String)] -- ^ Files to be run through @hs2ats@.
-                                 , binTarget   :: String -- ^ Binary target
+-- Package management idea:
+--
+-- * One big index
+--
+-- * Versions resolved from that
+--
+-- * Then we temporarily set the dependencies
+--
+-- * Ideally something with C dependencies included.
+--
+-- * Also binary caches are good.
+
+data ArtifactType = StaticLibrary
+                  | DynamicLibrary
+                  | Binary Bool
+
+-- | Information about where to find @patscc@ and @patsopt@.
+data ATSToolConfig = ATSToolConfig { libVersion  :: Version
+                                   , compilerVer :: Version
+                                   -- , hasPretty   :: Bool -- ^ Whether to display errors via @pats-filter@
+                                   }
+
+data BinaryTarget = BinaryTarget { cc         :: String -- ^ C compiler to be used.
+                                 , cFlags     :: [String] -- ^ Flags to be passed to the C compiler
+                                 , toolConfig :: ATSToolConfig
+                                 , gc         :: Bool -- ^ Whether to configure build for use with the garbage collector.
+                                 , libs       :: [String] -- ^ Libraries against which to link
+                                 , src        :: String -- ^ Source file for binary.
+                                 , hsLibs     :: [ForeignCabal] -- ^ Cabal-based Haskell libraries
+                                 , genTargets :: [(String, String)] -- ^ Files to be run through @hs2ats@.
+                                 , binTarget  :: String -- ^ Binary target
+                                 , cDeps      :: [String] -- ^ Any C files necessary to compile the target
                                  }
 
 -- | Data type containing information about Haskell components of a build.
