Break out more similarities between showlog.c and import.c
[nagios-reports-module.git] / Makefile
blobd7c1198a8e15199a8cb6c75d41e3cb42726bbb9d
1 CC = gcc
2 CPPFLAGS = -I.
3 CFLAGS = $(OPTFLAGS) -Wall -ggdb3 -fPIC
4 #OPTFLAGS = -O2 -pipe
5 DSOLDFLAGS = -shared $(SQL_LDFLAGS) -fPIC -ggdb3
6 SQL_LDFLAGS = -L/usr/lib/mysql -L/usr/lib64/mysql -lmysqlclient
7 TESTLDFLAGS = -ldl -rdynamic -Wl,-export-dynamic
8 OBJS = module.o hooks.o cfgfile.o logging.o sql.o utils.o hash.o mm.o
9 TEST_OBJS = test_utils.o utils.o hash.o mm.o
10 DEPS = Makefile module.h cfgfile.h utils.h
11 LOGDEPS = lparse.o logutils.o
12 DSO = ndbneb.so
13 TESTPROG = nebtest
14 CONFIG_FILE = db.conf
15 DESTDIR = /tmp/ndbneb
16 ALL_CFLAGS = $(CPPFLAGS) $(CFLAGS)
18 ifndef V
19 QUIET_CC = @echo ' ' CC $@;
20 QUIET_LINK = @echo ' ' LINK $@;
21 endif
23 all: $(DSO) $(TESTPROG) import showlog test__lparse
25 install: all
26 @echo "Installing to $(DESTDIR)"
27 @test -d $(DESTDIR) || mkdir -m 755 -p $(DESTDIR)
28 @cp -a scripts import $(DSO) $(TESTPROG) $(DESTDIR)
29 @cp -a db.conf $(DESTDIR)/ndbneb.conf
30 @cp -a *.php $(DESTDIR)
31 @chmod 755 $(DESTDIR)/*
32 @chmod 644 $(DESTDIR)/ndbneb.conf $(DESTDIR)/scripts/*
34 test__lparse: test-lparse
35 @./test-lparse
37 test-lparse: test-lparse.o $(LOGDEPS)
38 $(QUIET_LINK)$(CC) $(TESTLDFLAGS) $^ -o $@
40 $(DSO): $(OBJS)
41 $(QUIET_LINK)$(CC) $(DSOLDFLAGS) $^ -o $@
43 $(TESTPROG): $(TESTPROG).o $(TEST_OBJS)
44 $(QUIET_LINK)$(CC) $(TESTLDFLAGS) $^ -o $@
46 showlog: showlog.o $(TEST_OBJS) $(LOGDEPS)
47 $(QUIET_LINK)$(CC) $(SQL_LDFLAGS) -ggdb3 $^ -o $@
49 import: import.o $(TEST_OBJS) $(LOGDEPS) sql.o hooks.o logging.o
50 $(QUIET_LINK)$(CC) $(SQL_LDFLAGS) -ggdb3 $^ -o $@
52 test: mod $(TESTPROG) $(CONFIG_FILE)
53 ./$(TESTPROG) -f $(CONFIG_FILE) $(DSO)
55 mod: $(DSO)
57 %.o: %.c
58 $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) $<
60 %.so: %.c
61 @echo "CC $@"
62 @$(CC) $(CFLAGS) $(DSOLDFLAGS) $^ -o $@
64 clean:
65 rm -f core core.* *.{o,so,out,log}
66 rm -f $(TESTPROG) import showlog test-lparse
68 #'^[^.%][A-Za-z0-9_]*:'
69 help:
70 @echo Available make targets:
71 @echo -----------------------
72 @$(MAKE) --print-data-base --question | sed -n -e '/^Makefile/d' -e 's/^\([A-Za-z0-9_]*\):.*/\1/p'
74 ## PHONY targets
75 .PHONY: clean help
77 # dependencies
78 $(TESTPROG).o: $(TESTPROG).c $(DEPS)
79 showlog.o: lparse.h logutils.h showlog.c Makefile
80 lparse.o: lparse.c lparse.h Makefile
81 import.o: lparse.h import.c hooks.h sql.h logging.h Makefile
82 logging.o: logging.c logging.h $(DEPS)
83 cfgfile.o: cfgfile.c cfgfile.h
84 sql.o: sql.c sql.h $(DEPS)
85 hash.o: hash.c hash.h
86 hooks.o: hooks.c sql.h hooks.h $(DEPS)
87 module.o: module.c hooks.h $(DEPS)
88 utils.o: utils.c utils.h