diff --git a/ats-pkg.cabal b/ats-pkg.cabal
--- a/ats-pkg.cabal
+++ b/ats-pkg.cabal
@@ -1,5 +1,5 @@
 name:                ats-pkg
-version:             1.2.0.8
+version:             1.2.1.0
 synopsis:            Package manager for ATS
 description:         A collection of scripts to make building ATS projects easy.
 homepage:            https://github.com/vmchale/ats-pkg#readme
diff --git a/src/Language/ATS/Package/Dependency.hs b/src/Language/ATS/Package/Dependency.hs
--- a/src/Language/ATS/Package/Dependency.hs
+++ b/src/Language/ATS/Package/Dependency.hs
@@ -14,6 +14,7 @@
 import           Control.Concurrent.ParallelIO.Global
 import           Control.Lens
 import           Control.Monad
+import           Data.Maybe                           (fromMaybe)
 import           Data.Semigroup                       (Semigroup (..))
 import qualified Data.Text.Lazy                       as TL
 import           Dhall
@@ -26,12 +27,12 @@
 
 -- | Type for a dependency
 data Dependency = Dependency { libName :: Text -- ^ Library name, e.g.
-                             , _dir    :: Text -- ^ Directory we should unpack to
+                             , dir     :: Text -- ^ Directory we should unpack to
                              , url     :: Text -- ^ Url pointing to tarball
                              }
     deriving (Eq, Show, Generic, Interpret)
 
-makeLenses ''Dependency
+makeLensesFor [("dir", "dirLens"), ("libName", "libNameLens")] ''Dependency
 
 fetchDeps :: Bool -- ^ Set to 'False' if unsure.
           -> [Dependency] -- ^ ATS dependencies
@@ -40,27 +41,46 @@
 fetchDeps b deps cdeps =
     unless (null deps) $ do
         putStrLn "Checking ATS dependencies..."
-        d <- pkgHome
+        d <- (<> "lib/") <$> pkgHome
         let libs = fmap (buildHelper b) deps
-            unpacked = fmap (over dir (TL.pack d <>)) cdeps
-            clibs = fmap (buildHelper b) unpacked
+            unpacked = fmap (over dirLens (TL.pack d <>)) cdeps
+            clibs = fmap (buildHelper b . over libNameLens (const "")) unpacked
         parallel_ (libs ++ clibs) >> stopGlobalPool
         mapM_ setup unpacked
 
 pkgHome :: IO FilePath
-pkgHome = (++ "/.atspkg/lib/") <$> getEnv "HOME"
+pkgHome = (++ "/.atspkg/") <$> getEnv "HOME"
 
-clibSetup :: FilePath -> IO ()
-clibSetup p = do
-    let configurePath = p ++ "/configure"
+allSubdirs :: FilePath -> IO [FilePath]
+allSubdirs [] = pure mempty
+allSubdirs d = do
+    d' <- listDirectory d
+    let d'' = ((d <> "/") <>) <$> d'
+    ds <- filterM doesDirectoryExist d''
+    ds' <- mapM allSubdirs ds
+    pure $ join (ds : ds')
+
+clibSetup :: String -> FilePath -> IO ()
+clibSetup lib' p = do
+    subdirs <- allSubdirs p
+    configurePath <- fromMaybe (p <> "/configure") <$> findFile subdirs "configure"
     setFileMode configurePath ownerModes
-    void $ readCreateProcess ((proc p ["--prefix", p]) { cwd = Just p }) ""
-    void $ readCreateProcess ((proc "make" []) { cwd = Just p}) ""
-    void $ readCreateProcess ((proc "make" ["install"]) { cwd = Just p }) ""
+    h <- pkgHome
+    let procEnv = Just [("CFLAGS" :: String, "-I" <> h <> "include"), ("PATH", "/usr/bin:/bin")]
+    putStrLn $ "configuring " ++ lib' ++ "..."
+    void $ readCreateProcess ((proc configurePath ["--prefix", h]) { cwd = Just p, env = procEnv, std_err = CreatePipe }) ""
+    putStrLn $ "building " ++ lib' ++ "..."
+    void $ readCreateProcess ((proc "make" []) { cwd = Just p, std_err = CreatePipe }) ""
+    putStrLn $ "installing " ++ lib' ++ "..."
+    void $ readCreateProcess ((proc "make" ["install"]) { cwd = Just p, std_err = CreatePipe }) ""
 
 setup :: Dependency -> IO ()
-setup (Dependency _ dirName' _) =
-    clibSetup (TL.unpack dirName')
+setup (Dependency lib' dirName' _) = do
+    lib'' <- (<> TL.unpack lib') <$> pkgHome
+    b <- doesFileExist lib''
+    unless b $ do
+        clibSetup (TL.unpack lib') (TL.unpack dirName')
+        writeFile lib'' ""
 
 buildHelper :: Bool -> Dependency -> IO ()
 buildHelper b (Dependency lib' dirName' url'') = do
@@ -79,7 +99,6 @@
         putStrLn ("Unpacking library " ++ lib ++ "...")
         Tar.unpack dirName . Tar.read . decompress $ response
 
-        putStrLn ("Setting up library " ++ lib ++ "...")
         needsMove <- doesDirectoryExist (dirName ++ "/package")
         when needsMove $ do
             renameDirectory (dirName ++ "/package") "tempdir"
diff --git a/src/Language/ATS/Package/Type.hs b/src/Language/ATS/Package/Type.hs
--- a/src/Language/ATS/Package/Type.hs
+++ b/src/Language/ATS/Package/Type.hs
@@ -41,7 +41,6 @@
 pandoc :: (MonadIO m) => m Bool
 pandoc = isJust <$> liftIO (findExecutable "pandoc")
 
-
 mkManpage :: Rules ()
 mkManpage = do
     c <- getConfig
