{-# LANGUAGE OverloadedStrings #-}
module BNFC.Backend.CPP.Makefile (makefile) where
import BNFC.Backend.Common.Makefile
import BNFC.PrettyPrint
makefile :: String -> String -> String -> Doc
makefile :: [Char] -> [Char] -> [Char] -> Doc
makefile [Char]
prefix [Char]
name [Char]
basename = [Doc] -> Doc
vcat
[ [Char] -> [Char] -> Doc
mkVar [Char]
"CC" [Char]
"g++ -g"
, [Char] -> [Char] -> Doc
mkVar [Char]
"CCFLAGS" [Char]
"--ansi -W -Wall -Wsign-conversion -Wno-unused-parameter -Wno-unused-function -Wno-unneeded-internal-declaration"
, Doc
""
, [Char] -> [Char] -> Doc
mkVar [Char]
"FLEX" [Char]
"flex"
, [Char] -> [Char] -> Doc
mkVar [Char]
"FLEX_OPTS" ([Char]
"-P" [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
prefix)
, Doc
""
, [Char] -> [Char] -> Doc
mkVar [Char]
"BISON" [Char]
"bison"
, [Char] -> [Char] -> Doc
mkVar [Char]
"BISON_OPTS" ([Char]
"-t -p" [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
prefix)
, Doc
""
, [Char] -> [Char] -> Doc
mkVar [Char]
"OBJS" [Char]
"Absyn.o Buffer.o Lexer.o Parser.o Printer.o"
, Doc
""
, [Char] -> [[Char]] -> [[Char]] -> Doc
mkRule [Char]
".PHONY" [[Char]
"clean", [Char]
"distclean"]
[]
, [Char] -> [[Char]] -> [[Char]] -> Doc
mkRule [Char]
"all" [[Char]
testName]
[]
, [Char] -> [[Char]] -> [[Char]] -> Doc
mkRule [Char]
"clean" []
[ [Char]
"rm -f *.o " [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
testName [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
" " [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [[Char]] -> [Char]
unwords
[ [Char]
name [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
e | [Char]
e <- [[Char]
".aux", [Char]
".log", [Char]
".pdf",[Char]
".dvi", [Char]
".ps", [Char]
""]] ]
, [Char] -> [[Char]] -> [[Char]] -> Doc
mkRule [Char]
"distclean" [[Char]
"clean"]
[ [Char]
"rm -f " [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [[Char]] -> [Char]
unwords
[ [Char]
"Absyn.C", [Char]
"Absyn.H"
, [Char]
"Buffer.C", [Char]
"Buffer.H"
, [Char]
"Test.C"
, [Char]
"Bison.H", [Char]
"Parser.C", [Char]
"Parser.H", [Char]
"ParserError.H", [Char]
name [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
".y"
, [Char]
"Lexer.C", [Char]
name [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
".l"
, [Char]
"Skeleton.C", [Char]
"Skeleton.H"
, [Char]
"Printer.C", [Char]
"Printer.H"
, [Char]
basename
, [Char]
name [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
".tex"
]
]
, [Char] -> [[Char]] -> [[Char]] -> Doc
mkRule [Char]
testName [ [Char]
"${OBJS}", [Char]
"Test.o" ]
[ [Char]
"@echo \"Linking " [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
testName [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
"...\""
, [Char]
"${CC} ${OBJS} Test.o -o " [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
testName ]
, [Char] -> [[Char]] -> [[Char]] -> Doc
mkRule [Char]
"Absyn.o" [ [Char]
"Absyn.C", [Char]
"Absyn.H" ]
[ [Char]
"${CC} ${CCFLAGS} -c Absyn.C" ]
, [Char] -> [[Char]] -> [[Char]] -> Doc
mkRule [Char]
"Buffer.o" [ [Char]
"Buffer.C", [Char]
"Buffer.H" ]
[ [Char]
"${CC} ${CCFLAGS} -c Buffer.C " ]
, [Char] -> [[Char]] -> [[Char]] -> Doc
mkRule [Char]
"Lexer.C" [ [Char]
name [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
".l" ]
[ [Char]
"${FLEX} ${FLEX_OPTS} -oLexer.C " [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
name [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
".l" ]
, [Char] -> [[Char]] -> [[Char]] -> Doc
mkRule [Char]
"Parser.C Bison.H" [ [Char]
name [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
".y" ]
[ [Char]
"${BISON} ${BISON_OPTS} " [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
name [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
".y -o Parser.C" ]
, [Char] -> [[Char]] -> [[Char]] -> Doc
mkRule [Char]
"Lexer.o" [ [Char]
"CCFLAGS+=-Wno-sign-conversion" ]
[]
, [Char] -> [[Char]] -> [[Char]] -> Doc
mkRule [Char]
"Lexer.o" [ [Char]
"Lexer.C", [Char]
"Bison.H" ]
[ [Char]
"${CC} ${CCFLAGS} -c Lexer.C " ]
, [Char] -> [[Char]] -> [[Char]] -> Doc
mkRule [Char]
"Parser.o" [ [Char]
"Parser.C", [Char]
"Absyn.H", [Char]
"Bison.H" ]
[ [Char]
"${CC} ${CCFLAGS} -c Parser.C" ]
, [Char] -> [[Char]] -> [[Char]] -> Doc
mkRule [Char]
"Printer.o" [ [Char]
"Printer.C", [Char]
"Printer.H", [Char]
"Absyn.H" ]
[ [Char]
"${CC} ${CCFLAGS} -c Printer.C" ]
, [Char] -> [[Char]] -> [[Char]] -> Doc
mkRule [Char]
"Skeleton.o" [ [Char]
"Skeleton.C", [Char]
"Skeleton.H", [Char]
"Absyn.H" ]
[ [Char]
"${CC} ${CCFLAGS} -Wno-unused-parameter -c Skeleton.C" ]
, [Char] -> [[Char]] -> [[Char]] -> Doc
mkRule [Char]
"Test.o" [ [Char]
"Test.C", [Char]
"Parser.H", [Char]
"Printer.H", [Char]
"Absyn.H" ]
[ [Char]
"${CC} ${CCFLAGS} -c Test.C" ]
]
where testName :: [Char]
testName = [Char]
"Test" [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
name