Makefile: Add target to run sql-dependant tests
[nagios-reports-module.git] / Makefile
blob5ca979164600fe72a59b187e797b52c080bbfec8
1 CC = gcc
2 CFLAGS = $(OPTFLAGS) -Wall -ggdb3
3 OPTFLAGS = -O2
4 LDFLAGS = -O2 -ggdb3
5 SQL_LDFLAGS = -L/usr/lib/mysql -L/usr/lib64/mysql -lmysqlclient
6 TESTLDFLAGS = -ldl -rdynamic -Wl,-export-dynamic
7 COMMON_OBJS = state.o mm.o hash.o cfgfile.o utils.o
8 DSO_OBJS = $(COMMON_OBJS) module.o hooks.o logging.o sql.o
9 DSO_LDFLAGS = -shared $(SQL_LDFLAGS) -fPIC -ggdb3
10 TEST_OBJS = test_utils.o
11 APP_OBJS = $(COMMON_OBJS) $(TEST_OBJS) lparse.o logutils.o
12 IMPORT_OBJS = import.o $(APP_OBJS) hooks.o sql.o logging.o
13 SHOWLOG_OBJS = showlog.o $(APP_OBJS) auth.o
14 DEPS = Makefile module.h cfgfile.h utils.h
15 DSO = ndbneb.so
16 TESTPROG = nebtest
17 CONFIG_FILE = db.conf
18 DESTDIR = /tmp/ndbneb
19 ALL_CFLAGS = $(CPPFLAGS) $(CFLAGS) -fPIC
21 ifndef V
22 QUIET_CC = @echo ' ' CC $@;
23 QUIET_LINK = @echo ' ' LINK $@;
24 endif
26 all: $(DSO) test import showlog
28 install: all
29 @echo "Installing to $(DESTDIR)"
30 @test -d $(DESTDIR) || mkdir -m 755 -p $(DESTDIR)
31 @cp -a scripts import showlog $(DSO) $(TESTPROG) $(DESTDIR)
32 @cp -a db.conf $(DESTDIR)/ndbneb.conf
33 @cp -a *.php $(DESTDIR)
34 @chmod 755 $(DESTDIR)/*
35 @chmod 644 $(DESTDIR)/ndbneb.conf $(DESTDIR)/scripts/*
37 test__lparse: test-lparse
38 @./test-lparse
40 test-lparse: test-lparse.o lparse.o logutils.o hash.o test_utils.o
41 $(QUIET_LINK)$(CC) $(LDFLAGS) $^ -o $@
43 $(DSO): $(DSO_OBJS)
44 $(QUIET_LINK)$(CC) $(LDFLAGS) $(DSO_LDFLAGS) $^ -o $@
46 $(TESTPROG): $(TESTPROG).o $(TEST_OBJS)
47 $(QUIET_LINK)$(CC) $(LDFLAGS) $(TESTLDFLAGS) $^ -o $@
49 showlog: $(SHOWLOG_OBJS)
50 $(QUIET_LINK)$(CC) $(LDFLAGS) $^ -o $@
52 import: $(IMPORT_OBJS)
53 $(QUIET_LINK)$(CC) $(LDFLAGS) $(SQL_LDFLAGS) $^ -o $@
55 test: test__lparse test__hash mod $(TESTPROG) $(CONFIG_FILE)
56 @./$(TESTPROG) -f $(CONFIG_FILE) $(DSO)
58 test-sql: test
59 @./$(TESTPROG) --test-sql -f $(CONFIG_FILE) $(DSO)
61 test__hash: test-hash
62 @./test-hash
64 test-hash: test-hash.o hash.o test_utils.o
65 $(QUIET_LINK)$(CC) $(LDFLAGS) $(TESTLDFLAGS) $^ -o $@
67 mod: $(DSO)
69 %.o: %.c
70 $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) $<
72 %.so: %.c
73 @echo "CC $@"
74 @$(CC) $(ALL_CFLAGS) $^ -o $@
76 clean:
77 rm -f core core.* *.{o,so,out,log}
78 rm -f $(TESTPROG) import showlog test-lparse test-hash
80 #'^[^.%][A-Za-z0-9_]*:'
81 help:
82 @echo Available make targets:
83 @echo -----------------------
84 @$(MAKE) --print-data-base --question | sed -n -e '/^Makefile/d' -e 's/^\([A-Za-z0-9_]*\):.*/\1/p'
86 ## PHONY targets
87 .PHONY: clean help
89 # dependencies
90 $(TESTPROG).o: $(TESTPROG).c $(DEPS)
91 test-lparse.o: test-lparse.c logutils.h
92 showlog.o: lparse.h logutils.h showlog.c Makefile
93 logutils.o: logutils.h Makefile
94 lparse.o: lparse.c lparse.h Makefile
95 import.o: lparse.h import.c hooks.h sql.h logging.h Makefile logutils.h
96 logging.o: logging.c logging.h $(DEPS)
97 cfgfile.o: cfgfile.c cfgfile.h
98 sql.o: sql.c sql.h $(DEPS)
99 hash.o: hash.c hash.h
100 hooks.o: hooks.c sql.h hooks.h $(DEPS)
101 module.o: module.c hooks.h $(DEPS)
102 utils.o: utils.c utils.h