From c7a4ad8bc3f92968dbda7aee4af2978d668e7b77 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 8 Dec 2012 12:29:09 -0400 Subject: [PATCH] move libs to try to fit within available path space --- Build/OSXMkLibs.hs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Build/OSXMkLibs.hs b/Build/OSXMkLibs.hs index fa5178988f..45a86000b6 100644 --- a/Build/OSXMkLibs.hs +++ b/Build/OSXMkLibs.hs @@ -36,15 +36,14 @@ installLibs :: FilePath -> IO [Maybe FilePath] installLibs appbase = do needlibs <- otool appbase forM needlibs $ \lib -> do - let libdir = parentDir lib - let dest = appbase ++ lib + let dest = appbase takeFileName lib ifM (doesFileExist dest) ( return Nothing , do - createDirectoryIfMissing True (appbase ++ libdir) - _ <- boolSystem "cp" [File lib, File dest] + createDirectoryIfMissing True appbase putStrLn $ "installing " ++ lib - return $ Just libdir + _ <- boolSystem "cp" [File lib, File dest] + return $ Just appbase ) {- Returns libraries to install. -} @@ -52,10 +51,13 @@ otool :: FilePath -> IO [FilePath] otool appbase = do files <- filterM doesFileExist =<< dirContentsRecursive appbase l <- forM files $ \file -> do - libs <- parseOtool <$> readProcess "otool" ["-L", file] + libs <- filter unprocessed . parseOtool + <$> readProcess "otool" ["-L", file] forM_ libs $ \lib -> install_name_tool file lib return libs return $ nub $ concat l + where + unprocessed s = not ("@executable_path" `isInfixOf` s) parseOtool :: String -> [FilePath] parseOtool = catMaybes . map parse . lines @@ -74,7 +76,7 @@ install_name_tool binary lib = do ok <- boolSystem "install_name_tool" [ Param "-change" , File lib - , Param $ "@executable_path" ++ lib + , Param $ "@executable_path" ++ (dropFileName lib) , File binary ] unless ok $