main
build.ninja
1# i know this is a ninja file, but you're allowed to edit it.
2# you can also pass things on the command line if you like, eg
3#
4# CC=clang ninja
5
6bin = shin
7cc = $${CC:-cc}
8cflags = $${CFLAGS:--O2 -std=c99 -Wall -Wextra -pedantic -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 -Isrc -Ibackends -DSHIN_WITH_GNU=$${SHIN_WITH_GNU:-1}}
9ldflags = $${LDFLAGS:-}
10libs = $${LIBS:-}
11prefix = $${PREFIX:-/usr}
12destdir = $${DESTDIR:-}
13bindir = $${BINDIR:-$${DESTDIR:-}$${PREFIX:-/usr}/bin}
14mandir = $${MANDIR:-$${DESTDIR:-}$${PREFIX:-/usr}/share/man/man1}
15
16rule cc
17 command = $cc $cflags -MMD -MF $out.d -c -o $out $in
18 deps = gcc
19 depfile = $out.d
20 description = cc $out
21
22rule link
23 command = $cc $ldflags -o $out $in $libs
24 description = link $out
25
26rule install
27 command = mkdir -p $bindir $mandir && cp $in $bindir/ && cp doc/shin.1 $mandir/
28 description = install $bin
29
30rule go
31 command = cd $dir && go build -o $outfile $pkg
32 description = go build $out
33
34rule test
35 command = tests/shintest.sh
36 description = test
37
38rule fmt
39 command = clang-format -i cli/main.c src/parse.c src/eval/eval.c src/eval/dollar.c src/graph/graph.c src/graph/subgraph.c src/sufrule.c src/defaults.c src/targets.c src/gnu/pattern.c backends/ninja.c backends/graphviz.c backends/compdb.c src/util.c src/submake.c src/gnu/functions.c src/shinobi.h src/internal.h src/posix.h src/gnu/pattern.h backends/ninja.h backends/graphviz.h backends/compdb.h
40 description = fmt
41
42build cli/main.o: cc cli/main.c
43build src/parse.o: cc src/parse.c
44build src/eval/eval.o: cc src/eval/eval.c
45build src/eval/dollar.o: cc src/eval/dollar.c
46build src/graph/graph.o: cc src/graph/graph.c
47build src/graph/subgraph.o: cc src/graph/subgraph.c
48build src/sufrule.o: cc src/sufrule.c
49build src/defaults.o: cc src/defaults.c
50build src/targets.o: cc src/targets.c
51build src/gnu/pattern.o: cc src/gnu/pattern.c
52build backends/ninja.o: cc backends/ninja.c
53build backends/graphviz.o: cc backends/graphviz.c
54build backends/compdb.o: cc backends/compdb.c
55build src/util.o: cc src/util.c
56build src/submake.o: cc src/submake.c
57build src/gnu/functions.o: cc src/gnu/functions.c
58
59build $bin: link cli/main.o src/parse.o src/eval/eval.o src/eval/dollar.o src/graph/graph.o src/graph/subgraph.o src/sufrule.o src/defaults.o src/targets.o src/gnu/pattern.o backends/ninja.o backends/graphviz.o backends/compdb.o src/util.o src/submake.o src/gnu/functions.o
60build all: phony $bin
61build install: install $bin
62build tests/runner/runner: go tests/runner/case.go tests/runner/discover.go tests/runner/main.go tests/runner/preserve.go tests/runner/suite.go tests/runner/types.go tests/runner/go.mod
63 dir = tests/runner
64 outfile = runner
65 pkg = .
66build tests/runner/testhelper: go tests/runner/testhelp/main.go tests/runner/go.mod
67 dir = tests/runner
68 outfile = testhelper
69 pkg = ./testhelp
70build runner: phony tests/runner/runner
71build helper: phony tests/runner/testhelper
72build test: test $bin runner helper
73build fmt: fmt
74
75default all