# This file is used to build ninja itself, but it also serves as a # documented example. builddir = build # Most other variables, like cflags, aren't magic at all; it's up to # the rules to make use of them. cxx = g++ #cxx = /home/evanm/projects/src/llvm/Release+Asserts/bin/clang++ cflags = -g -Wall -Wno-deprecated # needed for backtrace() ldflags = -g -rdynamic # Here we declare a "rule" named "cxx", which knows how to compile # C++ code. The variables indented below the rule are scoped to the # rule itself. The "command" and "depfile" variables in rule scope # are special; see the documentation. rule cxx depfile = $out.d command = $cxx -MMD -MF $out.d $cflags -c $in -o $out rule ar command = ar crsT $out $in rule link command = $cxx $ldflags -o $out $in # These build rules build the ".o" files from the ".cc" files, # build "ninja.a" by linking the builddir's "ninja.o", # and build that "ninja.o" by compiling "ninja.cc". build $builddir/build.o: cxx src/build.cc build $builddir/parsers.o: cxx src/parsers.cc build $builddir/subprocess.o: cxx src/subprocess.cc build $builddir/util.o: cxx src/util.cc build $builddir/ninja_jumble.o: cxx src/ninja_jumble.cc build $builddir/ninja.a: ar $builddir/build.o $builddir/parsers.o \ $builddir/subprocess.o $builddir/util.o $builddir/ninja_jumble.o build $builddir/ninja.o: cxx src/ninja.cc build ninja: link $builddir/ninja.o $builddir/ninja.a build $builddir/build_test.o: cxx src/build_test.cc build $builddir/ninja_test.o: cxx src/ninja_test.cc build $builddir/parsers_test.o: cxx src/parsers_test.cc build $builddir/subprocess_test.o: cxx src/subprocess_test.cc build ninja_test: link $builddir/build_test.o $builddir/ninja_test.o \ $builddir/parsers_test.o $builddir/subprocess_test.o $builddir/ninja.a ldflags = -g -rdynamic -lgtest -lgtest_main -lpthread # Generate a graph of the dependency tree (including the # graph generation itself in the resulting tree). rule gendot command = ./ninja -g all > $out rule gengraph command = dot -Tpng $in > $out build $builddir/graph.dot: gendot ninja build.ninja build graph.png: gengraph $builddir/graph.dot rule asciidoc command = asciidoc -a toc $in build manual.html: asciidoc manual.asciidoc build doc: phony | manual.html # Use the built-in phony rule and an order-only dependency # to make building "all" build all targets. build all: phony | ninja ninja_test graph.png doc