Commit 8277b95d authored by Michael Hanus's avatar Michael Hanus
Browse files

CreateMakefile moved

parent 01a04841
......@@ -8,5 +8,6 @@ browser/BrowserGUI
browser/SourceProgGUI
currydoc/CurryDoc
currytest/CurryTest
createmakefile/CreateMakefile
genint/GenInt
importcalls/ImportCalls
......@@ -6,17 +6,19 @@
.PHONY: all
all:
@cd browser && $(MAKE)
@cd currydoc && $(MAKE)
@cd currytest && $(MAKE)
@cd genint && $(MAKE)
@cd importcalls && $(MAKE)
@cd browser && $(MAKE)
@cd currydoc && $(MAKE)
@cd createmakefile && $(MAKE)
@cd currytest && $(MAKE)
@cd genint && $(MAKE)
@cd importcalls && $(MAKE)
.PHONY: clean
clean:
cd analysis && $(ROOT)/bin/cleancurry
cd browser && $(MAKE) clean
cd currydoc && $(MAKE) clean
cd currytest && $(MAKE) clean
cd genint && $(MAKE) clean
cd importcalls && $(MAKE) clean
cd analysis && $(ROOT)/bin/cleancurry
cd browser && $(MAKE) clean
cd currydoc && $(MAKE) clean
cd createmakefile && $(MAKE) clean
cd currytest && $(MAKE) clean
cd genint && $(MAKE) clean
cd importcalls && $(MAKE) clean
-----------------------------------------------------------------
--- A tool to create a simple makefile for a Curry application.
---
--- @author Michael Hanus
--- @version October 2012
-----------------------------------------------------------------
module CreateMakefile where
import FlatCurry
import FlatCurryRead
import List
import System
import Distribution
import FileGoodies
main = do
args <- getArgs
case args of
[mainmod] -> createMake (stripSuffix mainmod) Nothing
[mainmod,target] -> createMake (stripSuffix mainmod) (Just target)
_ -> putStrLn $
"ERROR: Illegal arguments: " ++
concat (intersperse " " args) ++ "\n" ++
"Usage: currycreatemake <main_module_name>\n" ++
" or: currycreatemake <main_module_name> <makefile>"
-- Create a simple makefile for a main module:
createMake :: String -> Maybe String -> IO ()
createMake mainmod target = do
allints <- readFlatCurryIntWithImports mainmod
let allmods = (foldl union [mainmod]
(map (\ (Prog _ imps _ _ _) -> imps) allints))
allsources <- mapIO findSourceFileInLoadPath (filter (/="Prelude") allmods)
(maybe putStr writeFile target)
(showMake mainmod (map replacePakcsLib allsources))
showMake mainmod sourcefiles =
"# Makefile for main module \""++mainmod++"\":\n\n"++
"CURRYHOME="++installDir++"\n"++
"CURRYLIB=$(CURRYHOME)/lib\n\n"++
".PHONY: all\n"++
"all: "++mainmod++"\n\n"++
mainmod++": " ++ concat (intersperse " \\\n\t " sourcefiles) ++"\n"++
"\t# create saved state for top-level function \"main\":\n"++
"\t$(CURRYHOME)/bin/"++curryCompiler++" :l "++mainmod++" :save :q\n\n"++
".PHONY: clean\n"++
"clean:\n\t$(CURRYHOME)/bin/cleancurry\n"
-- add a directory name for a Curry source file by looking up the
-- current load path (CURRYPATH):
findSourceFileInLoadPath modname = do
loadpath <- getLoadPathForFile modname
mbfname <- lookupFileInPath (baseName modname) [".lcurry",".curry"] loadpath
maybe (error ("Curry file for module \""++modname++"\" not found!"))
(return . dropLocal)
mbfname
where
dropLocal f = if take 2 f == "./" then drop 2 f else f
-- replace CURRY lib directory prefix in a filename by $(CURRYLIB):
replacePakcsLib filename =
let pakcslib = installDir++"/lib"
pllength = length pakcslib
in if take pllength filename == pakcslib
then "$(CURRYLIB)" ++ drop pllength filename
else filename
# Makefile for tool "CreateMakefile":
# Required:
# - installed Curry System (PAKCS or KiCS2) specified by variable CURRYSYSTEM
# - root location of the Curry System specified by variable ROOT
LIB=$(ROOT)/lib
META=$(LIB)/meta
# generate executable for CreateMakefile program:
CreateMakefile: CreateMakefile.curry \
$(META)/FlatCurryRead.curry \
$(LIB)/FilePath.curry \
$(LIB)/PropertyFile.curry \
$(LIB)/ReadShowTerm.curry \
$(LIB)/Distribution.curry \
$(LIB)/FileGoodies.curry \
$(META)/FlatCurry.curry \
$(LIB)/Global.curry \
$(LIB)/List.curry \
$(LIB)/Maybe.curry \
$(LIB)/Directory.curry \
$(LIB)/IOExts.curry \
$(LIB)/Time.curry \
$(LIB)/Char.curry \
$(LIB)/IO.curry \
$(LIB)/System.curry
# create saved state for top-level function "main":
$(ROOT)/bin/$(CURRYSYSTEM) $(REPL_OPTS) :l CreateMakefile :save :q
(cd $(ROOT)/bin ; rm -f currycreatemake ; \
ln -s ../currytools/createmakefile/CreateMakefile currycreatemake)
.PHONY: clean
clean:
$(ROOT)/bin/cleancurry
rm -f $(ROOT)/bin/currycreatemake
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment