definition:
|
modToMakeFile :: String -> String -> String -> String -> [String] -> String
-> MakeFile
modToMakeFile args root tool mainmod sourcefiles currypath =
[ Comment $ "Makefile for main module \""++mainmod++"\""
, Comment $ "Created by: curry-genmake " ++ args
, Empty
, Comment "The root directory of the Curry system:"
, DefineVariable "CURRYHOME" [root]
, Empty
, Comment "The executable of the Curry system:"
, DefineVariable "REPL" ["$(CURRYHOME)/bin/curry"]
, Empty
, Comment "Default options for the Curry system:"
, DefineVariable "REPL_OPTS" [":set -time"]
, Empty
, Comment "The directory of the Curry system libraries:"
, DefineVariable "CURRYLIB" ["$(CURRYHOME)/lib"]
, Empty ] ++
ifNotNull tool
[ Comment "The tool name of the application:"
, DefineVariable "TOOL" [tool], Empty] ++
ifNotNull currypath
[ Comment "The load path of the application:"
, DefineVariable "LOADPATH" [currypath], Empty] ++
[ Comment "Source modules:"
, DefineVariable "DEPS" sourcefiles
, Empty
, Rule [PHONY] "all" ["install"] []
, Rule [PHONY] "install" ["compile"]
(ifNotNull tool
[ "mkdir -p $(dir $(TOOL))", "rm -f $(TOOL)"
, "cd $(dir $(TOOL)) && ln -s $(CURDIR)/"++mainmod++" $(notdir $(TOOL))"
, "@echo Tool installed into: $(TOOL)"])
, Rule [PHONY] "compile" [mainmod] []
, Comment "Load the application into the interactive Curry system:"
, Rule [PHONY] "load" []
["$(REPL) $(REPL_OPTS) " ++ setpath ++ ":l "++mainmod]
, Comment "Compile and create an executable of the application:"
, Rule [] mainmod ["$(DEPS)"]
["# create executable for top-level function \"main\":"
,"$(REPL) $(REPL_OPTS) " ++ setpath ++ ":l "++mainmod++" :save :q"]
, Comment "Clean intermediate files:"
, Rule [PHONY] "clean" [] ["$(CURRYHOME)/bin/cleancurry"]
, Rule [PHONY] "uninstall" ["clean"]
["rm -f " ++ mainmod ++ if null tool then "" else " $(TOOL)"]
]
where
setpath = if null currypath then "" else ":set path $(LOADPATH) "
ifNotNull s xs = if null s then [] else xs
|