diff --git a/Setup.lhs b/Setup.lhs
new file mode 100644
--- /dev/null
+++ b/Setup.lhs
@@ -0,0 +1,44 @@
+#!/usr/bin/env runhaskell
+\begin{code}
+{-# OPTIONS_GHC -Wall #-}
+module Main (main) where
+
+import Data.List ( nub )
+import Data.Version ( showVersion )
+import Distribution.Package ( PackageName(PackageName), PackageId, InstalledPackageId, packageVersion, packageName )
+import Distribution.PackageDescription ( PackageDescription(), TestSuite(..) )
+import Distribution.Simple ( defaultMainWithHooks, UserHooks(..), simpleUserHooks )
+import Distribution.Simple.Utils ( rewriteFile, createDirectoryIfMissingVerbose )
+import Distribution.Simple.BuildPaths ( autogenModulesDir )
+import Distribution.Simple.Setup ( BuildFlags(buildVerbosity), fromFlag )
+import Distribution.Simple.LocalBuildInfo ( withLibLBI, withTestLBI, LocalBuildInfo(), ComponentLocalBuildInfo(componentPackageDeps) )
+import Distribution.Verbosity ( Verbosity )
+import System.FilePath ( (</>) )
+
+main :: IO ()
+main = defaultMainWithHooks simpleUserHooks
+  { buildHook = \pkg lbi hooks flags -> do
+     generateBuildModule (fromFlag (buildVerbosity flags)) pkg lbi
+     buildHook simpleUserHooks pkg lbi hooks flags
+  }
+
+generateBuildModule :: Verbosity -> PackageDescription -> LocalBuildInfo -> IO ()
+generateBuildModule verbosity pkg lbi = do
+  let dir = autogenModulesDir lbi
+  createDirectoryIfMissingVerbose verbosity True dir
+  withLibLBI pkg lbi $ \_ libcfg -> do
+    withTestLBI pkg lbi $ \suite suitecfg -> do
+      rewriteFile (dir </> "Build_" ++ testName suite ++ ".hs") $ unlines
+        [ "module Build_" ++ testName suite ++ " where"
+        , "deps :: [String]"
+        , "deps = " ++ (show $ formatdeps (testDeps libcfg suitecfg))
+        ]
+  where
+    formatdeps = map (formatone . snd)
+    formatone p = case packageName p of
+      PackageName n -> n ++ "-" ++ showVersion (packageVersion p)
+
+testDeps :: ComponentLocalBuildInfo -> ComponentLocalBuildInfo -> [(InstalledPackageId, PackageId)]
+testDeps xs ys = nub $ componentPackageDeps xs ++ componentPackageDeps ys
+
+\end{code}
diff --git a/etc/LICENCE b/etc/LICENCE
new file mode 100644
--- /dev/null
+++ b/etc/LICENCE
@@ -0,0 +1,27 @@
+Copyright 2009-2014 Tony Morris
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+3. Neither the name of the author nor the names of his contributors
+   may be used to endorse or promote products derived from this software
+   without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
diff --git a/javasf.cabal b/javasf.cabal
new file mode 100644
--- /dev/null
+++ b/javasf.cabal
@@ -0,0 +1,86 @@
+name:               javasf
+version:            0.1.0
+license:            BSD3
+license-file:       etc/LICENCE
+author:             Tony Morris <ʇǝu˙sıɹɹoɯʇ@ןןǝʞsɐɥ>
+maintainer:         Tony Morris
+copyright:          Copyright (C) 2009-2014 Tony Morris
+synopsis:           A utility to print the SourceFile attribute of one or more Java class files.
+category:           Development
+homepage:           https://github.com/tonymorris/javasf
+bug-reports:        https://github.com/tonymorris/javasf/issues
+cabal-version:      >= 1.10
+build-type:         Custom
+description:
+  Installs a javasf executable to print the @SourceFile@ attribute of one or more Java class files.
+  .
+  For example:
+  .
+  @
+    \> javasf ThisClass.class ThatClass.class
+
+    ThisClass.java
+
+    ThatClass.java
+  @
+  .
+  Java VM Specification 4.7.7 The @SourceFile@ Attribute
+  .
+  <http://java.sun.com/docs/books/jvms/second_edition/html/ClassFile.doc.html#79868>
+
+source-repository   head
+  type:             git
+  location:         git@github.com:tonymorris/javasf.git
+
+flag                small_base
+  description:      Choose the new, split-up base package.
+
+
+executable javasf
+  default-language:
+                    Haskell2010
+
+  hs-source-dirs:
+                    src
+
+  main-is:
+                    Main.hs
+
+  build-depends:
+                    base < 5 && >= 3
+                    , language-java-classfile >= 0.1
+                    , binary >= 0.5 
+                    , bytestring >= 0.9 
+
+  ghc-options:
+                    -Wall
+
+  default-extensions:
+                    NoImplicitPrelude
+
+  other-modules:
+                    Language.Java.Javasf
+
+test-suite doctests
+  type:
+                    exitcode-stdio-1.0
+
+  main-is:
+                    doctests.hs
+
+  default-language:
+                    Haskell2010
+
+  build-depends:
+                    base < 5 && >= 3,
+                    doctest >= 0.9.7,
+                    filepath >= 1.3,
+                    directory >= 1.1,
+                    QuickCheck >= 2.0
+
+  ghc-options:
+                    -Wall
+                    -threaded
+
+  hs-source-dirs:
+                    test
diff --git a/src/Language/Java/Javasf.hs b/src/Language/Java/Javasf.hs
new file mode 100644
--- /dev/null
+++ b/src/Language/Java/Javasf.hs
@@ -0,0 +1,31 @@
+module Language.Java.Javasf where
+
+import Prelude(FilePath)
+import Data.Binary.Get
+import qualified Data.ByteString.Lazy as B
+import Data.Maybe
+import Data.String(String)
+import Control.Monad((<=<))
+import Data.Foldable(mapM_)
+import Data.Function((.))
+import Data.Tuple(snd)
+import Language.Java.ClassFile
+import System.IO(IO, putStrLn)
+
+sourceFile ::
+  B.ByteString
+  -> Maybe String
+sourceFile =
+  sourcePath . snd . runGet getClass
+
+showSourceFile ::
+  B.ByteString
+  -> String
+showSourceFile x =
+  "?Unknown?" `fromMaybe` sourceFile x
+
+javasf ::
+  [FilePath]
+  -> IO ()
+javasf =
+  mapM_ ((putStrLn . showSourceFile) <=< B.readFile)
diff --git a/src/Main.hs b/src/Main.hs
new file mode 100644
--- /dev/null
+++ b/src/Main.hs
@@ -0,0 +1,23 @@
+module Main where
+
+import Data.List(null)
+import Data.Foldable(mapM_)
+import Language.Java.Javasf(javasf)
+import System.Environment(getArgs)
+import System.IO(IO, putStrLn)
+
+main ::
+  IO ()
+main =
+  do a <- getArgs
+     if null a
+        then mapM_ putStrLn
+                     [
+                       "<javasf> Copyright 2009-2014 Tony Morris"
+                     , "This software is made available under a BSD3 open source license"
+                     , []
+                     , "Prints the SourceFile attribute of one or more Java class files."
+                     , []
+                     , "javasf FILE1 [FILE2...]"
+                     ]
+        else javasf a
diff --git a/test/doctests.hs b/test/doctests.hs
new file mode 100644
--- /dev/null
+++ b/test/doctests.hs
@@ -0,0 +1,32 @@
+module Main where
+
+import Build_doctests (deps)
+import Control.Applicative
+import Control.Monad
+import Data.List
+import System.Directory
+import System.FilePath
+import Test.DocTest
+
+main ::
+  IO ()
+main =
+  getSources >>= \sources -> doctest $
+      "-isrc"
+    : "-idist/build/autogen"
+    : "-optP-include"
+    : "-optPdist/build/autogen/cabal_macros.h"
+    : "-hide-all-packages"
+    : map ("-package="++) deps ++ sources
+
+getSources :: IO [FilePath]
+getSources = filter (isSuffixOf ".hs") <$> go "src"
+  where
+    go dir = do
+      (dirs, files) <- getFilesAndDirectories dir
+      (files ++) . concat <$> mapM go dirs
+
+getFilesAndDirectories :: FilePath -> IO ([FilePath], [FilePath])
+getFilesAndDirectories dir = do
+  c <- map (dir </>) . filter (`notElem` ["..", "."]) <$> getDirectoryContents dir
+  (,) <$> filterM doesDirectoryExist c <*> filterM doesFileExist c
