diff --git a/Changelog.md b/Changelog.md
--- a/Changelog.md
+++ b/Changelog.md
@@ -1,3 +1,10 @@
+### 0.5.3.1
+
+- *nhm-tool*: pass option *--builddir="&dollar;(BUILDDIR)"* to command *cabal
+  list-bin* in generated *Makefile*. This fixes builds when package
+  *ngx-export-distribution* is being built inplace and *nhm-tool* hasn't been
+  explicitly installed.
+
 ### 0.5.3.0
 
 - *nhm-tool*: command *deps* now accepts option *-d* which expects the
diff --git a/ngx-export-distribution.cabal b/ngx-export-distribution.cabal
--- a/ngx-export-distribution.cabal
+++ b/ngx-export-distribution.cabal
@@ -1,5 +1,5 @@
 name:                       ngx-export-distribution
-version:                    0.5.3.0
+version:                    0.5.3.1
 synopsis:                   Build custom libraries for Nginx Haskell module
 description:                Build custom libraries for
         <https://github.com/lyokha/nginx-haskell-module Nginx Haskell module>.
diff --git a/nhm-tool.hs b/nhm-tool.hs
--- a/nhm-tool.hs
+++ b/nhm-tool.hs
@@ -191,17 +191,17 @@
         Nothing ->
             let (opt, value) = splitAt 2 arg
             in if | "-d" == opt ->
-                        if null value
-                            then Just dist { distDataWaitArg = Just opt }
-                            else Just dist' { distDataDir = value }
+                        Just $ if null value
+                                   then dist { distDataWaitArg = Just opt }
+                                   else dist' { distDataDir = value }
                   | "-t" == opt ->
-                        if null value
-                            then Just dist { distDataWaitArg = Just opt }
-                            else Just dist' { distDataTargetDir = value }
+                        Just $ if null value
+                                   then dist { distDataWaitArg = Just opt }
+                                   else dist' { distDataTargetDir = value }
                   | "-a" == opt ->
-                        if null value
-                            then Just dist { distDataWaitArg = Just opt }
-                            else Just dist' { distDataArchive = value }
+                        Just $ if null value
+                                   then dist { distDataWaitArg = Just opt }
+                                   else dist' { distDataArchive = value }
                   | "-p" == arg ->
                         Just dist' { distDataPatchOnly = True }
                   | "-v" == arg ->
@@ -210,12 +210,14 @@
                         Just dist' { distDataOwnVerbosity = verbose
                                    , distDataOtherVerbosity = verbose
                                    }
-                  | "-h" == arg || "-help" == arg || "--help" == arg ->
+                  | (`elem` ["-h", "-help", "--help"]) arg ->
                         Just dist' { distDataHelp = True }
-                  | "-" `isPrefixOf` arg -> Nothing
+                  | Just '-' == (fst <$> uncons arg) ->
+                        Nothing
                   | null distDataTargetLib ->
                         Just dist' { distDataTargetLib = arg }
-                  | otherwise -> Nothing
+                  | otherwise ->
+                        Nothing
         Just "-d" -> Just dist' { distDataDir = arg }
         Just "-t" -> Just dist' { distDataTargetDir = arg }
         Just "-a" -> Just dist' { distDataArchive = arg }
@@ -229,15 +231,17 @@
         Nothing ->
             let (opt, value) = splitAt 2 arg
             in if | "-d" == opt ->
-                        if null value
-                            then Just deps { depsDataWaitArg = Just opt }
-                            else Just deps' { depsDataBuilddir = value }
-                  | "-h" == arg || "-help" == arg || "--help" == arg ->
+                        Just $ if null value
+                                   then deps { depsDataWaitArg = Just opt }
+                                   else deps' { depsDataBuilddir = value }
+                  | (`elem` ["-h", "-help", "--help"]) arg ->
                         Just deps' { depsDataHelp = True }
-                  | "-" `isPrefixOf` arg -> Nothing
+                  | Just '-' == (fst <$> uncons arg) ->
+                        Nothing
                   | null depsDataProject ->
                         Just deps' { depsDataProject = arg }
-                  | otherwise -> Nothing
+                  | otherwise ->
+                        Nothing
         Just "-d" -> Just deps' { depsDataBuilddir = arg }
         Just _ -> undefined
         where deps' = deps { depsDataWaitArg = Nothing }
@@ -249,21 +253,23 @@
         Nothing ->
             let (opt, value) = splitAt 2 arg
             in if | "-p" == opt ->
-                        if null value
-                            then Just init' { initDataWaitArg = Just opt }
-                            else Just init'' { initDataPrefix = value }
+                        Just $ if null value
+                                   then init' { initDataWaitArg = Just opt }
+                                   else init'' { initDataPrefix = value }
                   | "-no-threaded" == arg ->
                         Just init'' { initDataNoThreaded = True }
                   | "-f" == arg ->
                         Just init'' { initDataForce = True }
                   | "-to-stdout" == arg ->
                         Just init'' { initDataToStdout = True }
-                  | "-h" == arg || "-help" == arg || "--help" == arg ->
+                  | (`elem` ["-h", "-help", "--help"]) arg ->
                         Just init'' { initDataHelp = True }
-                  | "-" `isPrefixOf` arg -> Nothing
+                  | Just '-' == (fst <$> uncons arg) ->
+                        Nothing
                   | null initDataProject ->
                         Just init'' { initDataProject = arg }
-                  | otherwise -> Nothing
+                  | otherwise ->
+                        Nothing
         Just "-p" -> Just init'' { initDataPrefix = arg }
         Just _ -> undefined
         where init'' = init' { initDataWaitArg = Nothing }
@@ -272,11 +278,11 @@
 cmdDist DistData {..} = do
     let pdb = emptyProgramDb
         patchelf = simpleProgram "patchelf"
-        ldd = simpleProgram "ldd"
     (patchelf', pdb') <- requireProgram distDataOtherVerbosity patchelf pdb
     if distDataPatchOnly
         then patchTargetLib patchelf'
         else do
+            let ldd = simpleProgram "ldd"
             (ldd', pdb'') <- requireProgram distDataOtherVerbosity ldd pdb'
             putStrLn' "---> Collecting libraries"
             lddOut <- getProgramOutput distDataOtherVerbosity
@@ -289,12 +295,13 @@
                     (tar', _) <- requireProgram distDataOtherVerbosity
                         tarProgram pdb''
                     collectLibs recs lddOut
-                    unless (null distDataTargetDir) $ putStrLn' ""
-                    patchTargetLib patchelf'
-                    putStrLn' ""
-                    archiveLibs tar'
-    where patchTargetLib patchelf' =
-              unless (null distDataTargetDir) $ do
+                    unless (null distDataTargetDir) $
+                        putStrLn' "" >> patchTargetLib patchelf'
+                    unless (null distDataArchive) $
+                        putStrLn' "" >> archiveLibs tar'
+    where patchTargetLib patchelf'
+              | null distDataTargetDir = return ()
+              | otherwise = do
                   putStrLn' $ "---> Patching " ++ distDataTargetLib
                   patchelfOut <- getProgramOutput distDataOtherVerbosity
                       patchelf' ["--print-rpath", distDataTargetLib]
@@ -343,8 +350,9 @@
                                      show (M.keys recsLibHSNotFound) ++
                                          " were not found in\n" ++ lddOut
                               exitFailure
-          archiveLibs tar' =
-              unless (null distDataArchive) $ do
+          archiveLibs tar'
+              | null distDataArchive = return ()
+              | otherwise = do
                   putStrLn' "---> Archiving artifacts"
                   tarOut <- getProgramOutput distDataOtherVerbosity tar'
                       ["czvf"
