main Makefile
 1.POSIX:
 2PREFIX = /usr
 3DESTDIR =
 4BINDIR = $(DESTDIR)$(PREFIX)/bin
 5MANDIR = $(DESTDIR)$(PREFIX)/share/man/man1
 6
 7BIN = shin
 8RUNNERBIN = tests/runner/runner
 9HELPERBIN = tests/runner/testhelper
10SRCS =  cli/main.c \
11	src/parse.c \
12	src/eval/eval.c \
13	src/eval/dollar.c \
14	src/graph/graph.c \
15	src/graph/subgraph.c \
16	src/sufrule.c \
17	src/defaults.c \
18	src/targets.c \
19	src/gnu/pattern.c \
20	backends/ninja.c \
21	backends/graphviz.c \
22	backends/compdb.c \
23	src/util.c \
24	src/submake.c \
25	src/gnu/functions.c 
26
27FMTSRCS = $(SRCS) \
28	  src/shinobi.h \
29	  src/internal.h \
30	  src/posix.h \
31	  src/gnu/pattern.h \
32	  backends/ninja.h \
33	  backends/graphviz.h \
34	  backends/compdb.h
35
36OBJS = $(SRCS:.c=.o)
37RUNNERSRCS = tests/runner/case.go \
38	tests/runner/discover.go \
39	tests/runner/main.go \
40	tests/runner/preserve.go \
41	tests/runner/suite.go \
42	tests/runner/types.go \
43	tests/runner/go.mod
44HELPERSRCS = tests/runner/testhelp/main.go
45
46CC = cc
47CFLAGS = -O2 -Wall -Wextra -pedantic
48CPPFLAGS = -Isrc -Ibackends -DSHIN_WITH_GNU=$(SHIN_WITH_GNU)
49LDFLAGS = -static
50
51# set to 0 to exclude gnu mode from the runtime -M flag
52SHIN_WITH_GNU = 1
53
54.PHONY: all fmt test runner helper install clean
55
56all: $(BIN)
57
58.SUFFIXES: .c .o
59
60.c.o:
61	$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
62
63$(BIN): $(OBJS)
64	$(CC) $(LDFLAGS) -o $(BIN) $(OBJS) $(LDLIBS)
65
66fmt:
67	clang-format -i $(FMTSRCS)
68
69runner: $(RUNNERBIN)
70
71helper: $(HELPERBIN)
72
73$(RUNNERBIN): $(RUNNERSRCS)
74	cd tests/runner && go build -o runner
75
76$(HELPERBIN): $(HELPERSRCS) tests/runner/go.mod
77	cd tests/runner && go build -o testhelper ./testhelp
78
79test: $(BIN) runner helper
80	tests/shintest.sh
81
82install: $(BIN)
83	install -d $(BINDIR)
84	install -m 755 $(BIN) $(BINDIR)/$(BIN)
85	install -d $(MANDIR)
86	install -m 644 doc/shin.1 $(MANDIR)/shin.1
87
88clean:
89	rm -f $(BIN) $(OBJS) $(RUNNERBIN) $(HELPERBIN)