diff --git a/app/Main.hs b/app/Main.hs
new file mode 100644
index 0000000000000000000000000000000000000000..3624342be64cf28e0d4605ce1c3884590321e2e8
--- /dev/null
+++ b/app/Main.hs
@@ -0,0 +1,6 @@
+module Main where
+
+import qualified HpcMain as HPC
+
+main :: IO ()
+main = HPC.main
\ No newline at end of file
diff --git a/hpc-bin.cabal b/hpc-bin.cabal
index 2a168321d21be2c89bbd55675c188a16d6e322b2..df43362b3558130a5b395abf860e23e77cc80b37 100644
--- a/hpc-bin.cabal
+++ b/hpc-bin.cabal
@@ -22,11 +22,11 @@ Flag build-tool-depends
     Description: Use build-tool-depends
     Default: True
 
-executable hpc
-    Default-Language: Haskell2010
+library
+    default-language: Haskell2010
     hs-source-dirs: src
-    Main-Is: HpcMain.hs
-    Other-Modules: HpcParser
+    exposed-modules: 
+                   HpcParser
                    HpcCombine
                    HpcDraft
                    HpcFlags
@@ -36,11 +36,12 @@ executable hpc
                    HpcReport
                    HpcShowTix
                    HpcUtils
-                   Paths_hpc_bin
+                   HpcMain
 
+    other-modules: Paths_hpc_bin
     autogen-modules: Paths_hpc_bin
 
-    Build-Depends: base       >= 4   && < 5,
+    build-depends: base       >= 4   && < 5,
                    directory  >= 1   && < 1.4,
                    filepath   >= 1   && < 1.5,
                    containers >= 0.1 && < 0.7,
@@ -49,3 +50,11 @@ executable hpc
 
     if flag(build-tool-depends)
       build-tool-depends: happy:happy >= 1.20.0
+
+executable hpc
+    default-language: Haskell2010
+    hs-source-dirs: app
+    main-is: Main.hs
+
+    build-depends: base >= 4 && < 5,
+                   hpc-bin
diff --git a/src/HpcMain.hs b/src/HpcMain.hs
index f7617ec6775351cbc3c149a433c4cbe5b47fb4d2..13069ef6dbc3827195b17b73f7891cdbf7776a17 100644
--- a/src/HpcMain.hs
+++ b/src/HpcMain.hs
@@ -1,4 +1,5 @@
 {-# LANGUAGE ScopedTypeVariables, TupleSections #-}
+module HpcMain ( main ) where
 -- (c) 2007 Andy Gill
 
 -- Main driver for Hpc