// // Really, variables here should default to something that's platform dependant, // but for now, we use linux, I'll default them to gnu/linux // if CXX == null then { CXX = "g++"; } if AR == null then { AR = "ar"; } if CC == null then { CC = "cc"; } if BISON == null then { BISON = "bison"; } if FLEX == null then { FLEX = "flex"; } function cppToObj() { if OBJ_DIR == null then { DIR = INPUT.dirName(); } else { DIR = OBJ_DIR; } return DIR + "/" + INPUT.fileName().replace(".cpp", ".o"); } function cToObj() { if OBJ_DIR == null then { DIR = INPUT.dirName(); } else { DIR = OBJ_DIR; } return DIR + "/" + INPUT.fileName().replace(".c", ".o"); } rule "exe" { input "*.o"; profile "build" { execute("${CXX} -o ${OUTPUT} ${INPUT} ${LDFLAGS}"); } } rule "lib" { input "*.o"; profile "build" { execute("${AR} cr ${OUTPUT} ${INPUT}"); } } rule "cpp" { input "*.cpp"; output INPUT.cppToObj(); // output replace(".cpp", ".o"); requires getMakeDeps("${CXX} ${CXXFLAGS} -M ${INPUT}"); profile "build" { execute("${CXX} ${CXXFLAGS} -c -o ${OUTPUT} ${INPUT}", "g++"); } } // Heh, we're not going to use this one. rule "c" { input "*.c"; output INPUT.cToObj(); // output replace(".c", ".o"); requires getMakeDeps("${CC} ${CFLAGS} -M ${INPUT}"); profile "build" { execute("${CC} ${CFLAGS} -c -o ${OUTPUT} ${INPUT}"); } } rule "bison" { input "*.y"; output [INPUT.replace(".y", ".tab.c"), INPUT.replace(".y", ".tab.h")]; profile "build" { BASE = INPUT.replace(".y", ""); execute("${BISON} -b${BASE} ${INPUT}"); // if you add a -v bison will produce a .output file } } rule "flex" { input "*.l"; output INPUT.replace(".l", ".yy.c"); output INPUT.replace(".l", ".yy.h"); profile "build" { execute("${FLEX} ${FLEXFLAGS} ${INPUT}"); } }