sammler/Makefile

89 lines
2.5 KiB
Makefile
Raw Normal View History

2006-06-13 21:34:36 +02:00
# Toplevel Makefile
2007-04-01 14:56:14 +02:00
WITH_RRD=yes
2006-06-13 21:34:36 +02:00
2007-04-03 17:12:53 +02:00
PLUGINS := ctstat diskstat load memory mount netdev random rtstat stat uptime vmstat
2007-04-03 18:49:39 +02:00
PLUGINS += apache mysql conntrack
2006-10-08 18:05:47 +02:00
2009-01-11 22:49:02 +01:00
DESTDIR = /tmp
BINARY_DIR = /usr/local/bin
CONFIG_DIR = /usr/local/etc
PLUGIN_DIR = /usr/local/lib/sammler
DATA_DIR = /var/lib/sammler
LOG_DIR = /var/log
WWW_DIR = /var/www
WWW_CONFIG = $(WWW_DIR)/sammler_graph.conf
WWW_OWNER = www-data
2006-09-30 22:55:04 +02:00
# ############################
2007-04-01 14:30:05 +02:00
SAMMLER_SRC := sammler.c configfile.c event.c helper.c logging.c network.c plugins.c probe.c
2009-01-11 22:49:02 +01:00
CFLAGS := -O2 -Wall -MMD -fno-stack-protector -Iinclude
2006-09-30 22:55:04 +02:00
LDFLAGS := -ldl -rdynamic
# ############################
ifeq ("$(WITH_RRD)", "yes")
2006-10-08 01:58:01 +02:00
SAMMLER_SRC += rrdtool.c
CFLAGS += -DWITH_RRD
LDFLAGS += -lrrd
endif
2006-06-13 21:34:36 +02:00
# ############################
2009-01-11 22:49:02 +01:00
all: sammler plugins
2006-06-13 21:34:36 +02:00
sammler: $(SAMMLER_SRC:%.c=%.o)
2009-01-11 22:49:02 +01:00
@echo " Linking file: $@"
@$(CC) $(LDFLAGS) $^ -o $@
2006-06-13 21:34:36 +02:00
%.o: %.c
2009-01-11 22:49:02 +01:00
@echo " Building file: $<"
@$(CC) $(CFLAGS) -o $@ -c $<
.PHONY: plugins
plugins: $(PLUGINS:%=plugins/%.o) $(PLUGINS:%=plugins/%.so)
plugins/%.so: plugins/%.o
@echo " Linking file: $@"
@$(CC) $(LDFLAGS) -shared -o $@ $<
plugins/apache.so: plugins/apache.o
@echo " Linking file: $@"
@$(CC) $(LDFLAGS) -shared -o -lcurl -o $@ $<
plugins/conntrack.so: plugins/conntrack.o
@echo " Linking file: $@"
@$(CC) $(LDFLAGS) -shared -o -lnfnetlink -lnetfilter_conntrack -o $@ $<
plugins/mysql.so: plugins/mysql.o plugins/mysql_helper.o
@echo " Linking file: $@"
@$(CC) $(LDFLAGS) -shared -o -lmysqlclient -o $@ $<
install: all
install -D -m 755 -s sammler $(DESTDIR)$(BINARY_DIR)/sammler
install -D -m 644 sammler.conf $(DESTDIR)$(CONFIG_DIR)/sammler.conf
sed -i -e "s:^logfile .*$$:logfile $(LOG_DIR)/sammler.log:" \
-e "s:^rrd_dir .*$$:rrd_dir $(DATA_DIR):" \
-e "s:^plugin_dir .*$$:plugin_dir $(PLUGIN_DIR):" \
$(DESTDIR)$(CONFIG_DIR)/sammler.conf
install -d -m 755 $(DESTDIR)$(PLUGIN_DIR)
install -m 755 -s plugins/*.so $(DESTDIR)$(PLUGIN_DIR)
install -d -m 755 $(DESTDIR)$(DATA_DIR) $(DESTDIR)$(LOG_DIR)
ifeq ("$(WITH_RRD)", "yes")
install -D -m 644 sammler.php $(DESTDIR)$(WWW_DIR)/sammler.php
sed -i -e "s:%%WWW_CONFIG%%:$(WWW_CONFIG):" \
-e "s:%%DATA_DIR%%:$(DATA_DIR):" \
$(DESTDIR)$(WWW_DIR)/sammler.php
-install -D -m 644 -o $(WWW_OWNER) /dev/null $(DESTDIR)$(WWW_CONFIG)
else
sed -i -e "s:^forward_only .*$$:forward_only true:" \
$(DESTDIR)$(CONFIG_DIR)/sammler.conf
endif
2006-06-13 21:34:36 +02:00
clean:
2009-01-11 22:49:02 +01:00
rm -rf *.d plugins/*.d *.o plugins/*.o plugins/*.so sammler
2006-06-13 21:34:36 +02:00
2009-01-11 22:49:02 +01:00
include $(shell find . -name \*.d 2> /dev/null)