import: Fix progress output ETA when skipping files
[nagios-reports-module.git] / Makefile
blob0aea0262d904f55a328d45fa24d99dad617a65a8
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__hash: test-hash
59 @./test-hash
61 test-hash: test-hash.o hash.o test_utils.o
62 $(QUIET_LINK)$(CC) $(LDFLAGS) $(TESTLDFLAGS) $^ -o $@
64 mod: $(DSO)
66 %.o: %.c
67 $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) $<
69 %.so: %.c
70 @echo "CC $@"
71 @$(CC) $(ALL_CFLAGS) $^ -o $@
73 clean:
74 rm -f core core.* *.{o,so,out,log}
75 rm -f $(TESTPROG) import showlog test-lparse test-hash
77 #'^[^.%][A-Za-z0-9_]*:'
78 help:
79 @echo Available make targets:
80 @echo -----------------------
81 @$(MAKE) --print-data-base --question | sed -n -e '/^Makefile/d' -e 's/^\([A-Za-z0-9_]*\):.*/\1/p'
83 ## PHONY targets
84 .PHONY: clean help
86 # dependencies
87 $(TESTPROG).o: $(TESTPROG).c $(DEPS)
88 test-lparse.o: test-lparse.c logutils.h
89 showlog.o: lparse.h logutils.h showlog.c Makefile
90 logutils.o: logutils.h Makefile
91 lparse.o: lparse.c lparse.h Makefile
92 import.o: lparse.h import.c hooks.h sql.h logging.h Makefile logutils.h
93 logging.o: logging.c logging.h $(DEPS)
94 cfgfile.o: cfgfile.c cfgfile.h
95 sql.o: sql.c sql.h $(DEPS)
96 hash.o: hash.c hash.h
97 hooks.o: hooks.c sql.h hooks.h $(DEPS)
98 module.o: module.c hooks.h $(DEPS)
99 utils.o: utils.c utils.h