build: add target to run cppcheck.
[oweals/dinit.git] / src / Makefile
1 include ../mconfig
2
3 ifeq ($(BUILD_SHUTDOWN),yes)
4   SHUTDOWN=shutdown
5 endif
6
7 dinit_objects = dinit.o load-service.o service.o proc-service.o baseproc-service.o control.o dinit-log.o \
8                 dinit-main.o run-child-proc.o
9
10 objects = $(dinit_objects) dinitctl.o shutdown.o
11
12 all: dinit dinitctl $(SHUTDOWN)
13
14 includes/mconfig.h: mconfig-gen
15         ./mconfig-gen SBINDIR=$(SBINDIR) SYSCONTROLSOCKET=$(SYSCONTROLSOCKET) > includes/mconfig.h
16
17 mconfig-gen: mconfig-gen.cc ../mconfig
18         $(CXX) $(CXXOPTS) -o mconfig-gen mconfig-gen.cc $(LDFLAGS)
19
20 dinit: includes/mconfig.h $(dinit_objects)
21         $(CXX) -o dinit $(dinit_objects) $(LDFLAGS)
22
23 dinitctl: dinitctl.o
24         $(CXX) -o dinitctl dinitctl.o $(LDFLAGS)
25         
26 shutdown: shutdown.o
27         $(CXX) -o shutdown shutdown.o $(LDFLAGS)
28
29 $(objects): %.o: %.cc
30         $(CXX) $(CXXOPTS) -MMD -MP -Iincludes -Idasynq -c $< -o $@
31
32 check:
33         $(MAKE) -C tests check
34
35 run-cppcheck:
36         cppcheck --std=c++11 -Iincludes -Idasynq --force --enable=all *.cc 2>../cppcheck-report.txt
37
38 install: all
39         install -d $(DESTDIR)$(SBINDIR)
40         install -s dinit dinitctl $(SHUTDOWN) $(DESTDIR)$(SBINDIR)
41 ifeq ($(BUILD_SHUTDOWN),yes)
42         install halt reboot $(DESTDIR)$(SBINDIR)
43 endif
44
45 clean:
46         rm -f *.o *.d
47         rm -f dinit dinitctl shutdown mconfig-gen
48         rm -f includes/mconfig.h
49         $(MAKE) -C tests clean
50
51 -include $(objects:.o=.d)