@@ -19,7 +19,9 @@ import Control.Monad (when)
1919import Data.FileEmbed (embedFile)
2020import System.Environment (getExecutablePath)
2121import System.Directory (doesFileExist)
22+import System.FilePath (takeDirectory)
2223
24+import qualified Data.Text as T
2325import qualified Data.ByteString.Char8 as B
2426
2527generateMakefile :: IO ()
@@ -30,7 +32,11 @@ generateMakefile = do
3032 exePath <- getExecutablePath
3133 putStrLn ""
3234 putStrLn $ "Generating Makefile... " ++ "pcc executable location " ++ exePath
33− writeFile "Makefile" $ replace makefile pccPath exePath
35+ writeFile "Makefile" . T.unpack $
36+ T.replace
37+ pathPlaceholder
38+ (T.pack $ takeDirectory exePath)
39+ (T.pack $ B.unpack makefile)
3440 putStrLn "Done"
3541 putStrLn ""
3642 putStrLn "Run 'make' or 'make release' to build an optimized release build."
@@ -51,14 +57,5 @@ generatePackagefile = do
5157 putStrLn "Done"
5258 putStrLn "Use the 'psc-package' utility to install or update packages."
5359
54−replace :: B.ByteString -> B.ByteString -> String -> String
55−replace s orig repl = replace'
56− where
57− replace'
58− | (p1, p2) <- B.breakSubstring orig s,
59− not (B.null p2) = B.unpack p1 ++ repl ++ trim (B.unpack p2)
60− | otherwise = B.unpack s
61− trim = drop (B.length orig)
62−
63−pccPath :: B.ByteString
64−pccPath = "{bin/pcc}"
60+pathPlaceholder :: T.Text
61+pathPlaceholder = "{{path}}"