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.4.1.0
+version:             1.4.1.1
 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
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
@@ -86,7 +86,7 @@
 -- This is the @$PATSHOMELOCS@ variable to be passed to the shell.
 patsHomeLocs :: Int -> String
 patsHomeLocs n = intercalate ":" $ (<> ".atspkg/contrib") . ("./" <>) <$> g
-    where g = [ join $ replicate i "../" | i <- [1..n] ]
+    where g = [ join $ replicate i "../" | i <- [0..n] ]
 
 makeCFlags :: [String] -- ^ Inputs
            -> [ForeignCabal] -- ^ Haskell libraries
@@ -196,11 +196,13 @@
         atsCommand tc atsSrc out
 
 cgen :: ATSToolConfig
+     -> [String] -- ^ Additional source files
      -> FilePath -- ^ Directory containing ATS source code
      -> Rules ()
-cgen tc dir =
+cgen tc extras dir =
 
     "//*.c" %> \out -> do
+        need extras
         let sourceFile = dir ++ "/" ++ (takeBaseName out -<.> "dats")
         handleSource tc sourceFile
         atsCommand tc sourceFile out
diff --git a/src/Development/Shake/ATS/Environment.hs b/src/Development/Shake/ATS/Environment.hs
--- a/src/Development/Shake/ATS/Environment.hs
+++ b/src/Development/Shake/ATS/Environment.hs
@@ -28,4 +28,5 @@
       TL.unpack
     . TL.replace (TL.pack "./") (TL.pack $ p ++ "/")
     . TL.replace (TL.pack "../") (TL.pack $ joinPath (init $ splitPath p) ++ "/")
+    . TL.replace (TL.pack "$PATSHOMELOCS") (TL.pack ".atspkg/contrib")
     . TL.pack
