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