2006-06-13 21:34:36 +02:00
|
|
|
# Toplevel Makefile
|
2012-12-09 12:26:51 +01:00
|
|
|
WITH_RRD?=yes
|
2006-06-13 21:34:36 +02:00
|
|
|
|
2009-01-11 23:14:50 +01:00
|
|
|
PLUGINS := ctstat diskstat hwmon load memory mount netdev random rtstat stat uptime vmstat
|
2012-12-11 22:08:13 +01:00
|
|
|
#PLUGINS += apache mysql conntrack alixusv ts2 diskstandby hddtemp
|
2006-10-08 18:05:47 +02:00
|
|
|
|
2009-01-11 23:09:00 +01:00
|
|
|
DESTDIR =
|
2009-01-11 22:49:02 +01:00
|
|
|
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
|
2009-05-01 22:57:15 +02:00
|
|
|
PID_DIR = /var/run
|
2009-01-11 22:49:02 +01:00
|
|
|
WWW_DIR = /var/www
|
|
|
|
WWW_CONFIG = $(WWW_DIR)/sammler_graph.conf
|
|
|
|
WWW_OWNER = www-data
|
|
|
|
|
2006-09-30 22:55:04 +02:00
|
|
|
# ############################
|
|
|
|
|
2012-12-09 12:26:51 +01:00
|
|
|
SRC := $(wildcard *.c)
|
|
|
|
BUILD_DIR = build
|
|
|
|
CFLAGS = -O2 -g -pipe -Wall -Wno-unused-result -I.
|
|
|
|
CFLAGS += -MMD -MF $(BUILD_DIR)/$(*D)/$(*F).d
|
|
|
|
LDFLAGS = -rdynamic -ldl
|
2006-09-30 22:55:04 +02:00
|
|
|
|
|
|
|
# ############################
|
|
|
|
|
|
|
|
ifeq ("$(WITH_RRD)", "yes")
|
2010-06-12 15:36:12 +02:00
|
|
|
CFLAGS += -DWITH_RRD
|
2010-06-12 13:41:50 +02:00
|
|
|
LDFLAGS_TARGET = -lrrd
|
2009-01-11 23:21:42 +01:00
|
|
|
TARGET = sammler
|
|
|
|
else
|
2010-06-12 13:41:50 +02:00
|
|
|
LDFLAGS_TARGET =
|
2009-01-11 23:21:42 +01:00
|
|
|
TARGET = sammler_norrd
|
2006-10-08 01:58:01 +02:00
|
|
|
endif
|
|
|
|
|
2010-06-12 15:36:12 +02:00
|
|
|
ifeq ($(strip $(wildcard $(DESTDIR)$(CONFIG_DIR)/sammler.conf)),)
|
|
|
|
NEWCONF=sammler.conf
|
|
|
|
else
|
|
|
|
NEWCONF=sammler.conf.dist
|
|
|
|
endif
|
|
|
|
|
2006-06-13 21:34:36 +02:00
|
|
|
# ############################
|
|
|
|
|
2009-01-11 23:21:42 +01:00
|
|
|
all: $(TARGET) plugins
|
2006-06-13 21:34:36 +02:00
|
|
|
|
2012-12-09 12:26:51 +01:00
|
|
|
$(TARGET): $(patsubst %,$(BUILD_DIR)/%, $(SRC:.c=.o))
|
2009-05-01 21:24:12 +02:00
|
|
|
@echo " Linking file: $@"
|
2012-12-09 12:26:51 +01:00
|
|
|
@$(CC) $^ $(LDFLAGS) $(LDFLAGS_TARGET) -o $@
|
2006-06-13 21:34:36 +02:00
|
|
|
|
2012-12-09 12:26:51 +01:00
|
|
|
$(BUILD_DIR)/%.o: %.c $(MAKEFILE_LIST)
|
2009-01-11 22:49:02 +01:00
|
|
|
@echo " Building file: $<"
|
2012-12-09 12:26:51 +01:00
|
|
|
@$(shell test -d $(BUILD_DIR)/$(*D) || mkdir -p $(BUILD_DIR)/$(*D))
|
2010-06-12 15:36:12 +02:00
|
|
|
@$(CC) $(CFLAGS) -o $@ -c $<
|
2009-01-11 22:49:02 +01:00
|
|
|
|
|
|
|
.PHONY: plugins
|
2012-12-09 12:26:51 +01:00
|
|
|
plugins: $(PLUGINS:%=plugins/%.so)
|
2009-01-11 22:49:02 +01:00
|
|
|
|
2012-12-09 12:26:51 +01:00
|
|
|
.SECONDARY: $(patsubst %,$(BUILD_DIR)/%, $(PLUGINS:%=plugins/%.o))
|
|
|
|
plugins/%.so: $(BUILD_DIR)/plugins/%.o
|
2009-05-01 21:24:12 +02:00
|
|
|
@echo " Linking file: $@"
|
2009-01-11 22:49:02 +01:00
|
|
|
@$(CC) $(LDFLAGS) -shared -o $@ $<
|
|
|
|
|
2012-12-09 12:26:51 +01:00
|
|
|
plugins/apache.so: $(BUILD_DIR)/plugins/apache.o
|
2009-05-01 21:24:12 +02:00
|
|
|
@echo " Linking file: $@"
|
2010-06-12 13:41:50 +02:00
|
|
|
@$(CC) $(LDFLAGS) -shared -lcurl -o $@ $<
|
2009-01-11 22:49:02 +01:00
|
|
|
|
2012-12-09 12:26:51 +01:00
|
|
|
plugins/conntrack.so: $(BUILD_DIR)/plugins/conntrack.o
|
2009-05-01 21:24:12 +02:00
|
|
|
@echo " Linking file: $@"
|
2010-06-12 13:41:50 +02:00
|
|
|
@$(CC) $(LDFLAGS) -shared -lnfnetlink -lnetfilter_conntrack -o $@ $<
|
2009-01-11 22:49:02 +01:00
|
|
|
|
2012-12-09 12:26:51 +01:00
|
|
|
plugins/mysql.so: $(BUILD_DIR)/plugins/mysql.o $(BUILD_DIR)/plugins/mysql_helper.o
|
2009-05-01 21:24:12 +02:00
|
|
|
@echo " Linking file: $@"
|
2010-06-12 13:41:50 +02:00
|
|
|
@$(CC) $(LDFLAGS) -shared -lmysqlclient -o $@ $^
|
|
|
|
|
2012-12-09 12:26:51 +01:00
|
|
|
plugins/diskstandby.so: $(BUILD_DIR)/plugins/diskstandby.o $(BUILD_DIR)/plugins/sgio.o
|
2010-06-12 13:41:50 +02:00
|
|
|
@echo " Linking file: $@"
|
|
|
|
@$(CC) $(LDFLAGS) -shared -o $@ $^
|
2009-01-11 22:49:02 +01:00
|
|
|
|
|
|
|
install: all
|
2009-01-11 23:21:42 +01:00
|
|
|
install -D -m 755 -s $(TARGET) $(DESTDIR)$(BINARY_DIR)/$(TARGET)
|
2010-06-12 15:36:12 +02:00
|
|
|
install -D -m 644 sammler.conf $(DESTDIR)$(CONFIG_DIR)/$(NEWCONF)
|
2009-01-11 22:49:02 +01:00
|
|
|
sed -i -e "s:^logfile .*$$:logfile $(LOG_DIR)/sammler.log:" \
|
2009-05-01 22:57:15 +02:00
|
|
|
-e "s:^pidfile .*$$:pidfile $(PID_DIR)/sammler.pid:" \
|
2009-01-11 22:49:02 +01:00
|
|
|
-e "s:^rrd_dir .*$$:rrd_dir $(DATA_DIR):" \
|
|
|
|
-e "s:^plugin_dir .*$$:plugin_dir $(PLUGIN_DIR):" \
|
2010-06-12 15:36:12 +02:00
|
|
|
$(DESTDIR)$(CONFIG_DIR)/$(NEWCONF)
|
2009-01-11 22:49:02 +01:00
|
|
|
install -d -m 755 $(DESTDIR)$(PLUGIN_DIR)
|
|
|
|
install -m 755 -s plugins/*.so $(DESTDIR)$(PLUGIN_DIR)
|
2009-04-02 15:48:11 +02:00
|
|
|
install -d -m 755 $(DESTDIR)$(LOG_DIR)
|
|
|
|
|
2009-01-11 22:49:02 +01:00
|
|
|
|
|
|
|
ifeq ("$(WITH_RRD)", "yes")
|
2009-04-02 15:48:11 +02:00
|
|
|
install -d -m 755 $(DESTDIR)$(DATA_DIR)
|
2009-01-11 22:49:02 +01:00
|
|
|
install -D -m 644 sammler.php $(DESTDIR)$(WWW_DIR)/sammler.php
|
|
|
|
sed -i -e "s:%%WWW_CONFIG%%:$(WWW_CONFIG):" \
|
2009-04-02 15:48:11 +02:00
|
|
|
-e "s:%%DATA_DIR%%:$(DATA_DIR)/:" \
|
2009-01-11 22:49:02 +01:00
|
|
|
$(DESTDIR)$(WWW_DIR)/sammler.php
|
2010-06-12 15:36:12 +02:00
|
|
|
ifeq ($(strip $(wildcard $(DESTDIR)$(WWW_CONFIG))),)
|
2009-01-11 22:49:02 +01:00
|
|
|
-install -D -m 644 -o $(WWW_OWNER) /dev/null $(DESTDIR)$(WWW_CONFIG)
|
2010-06-12 15:36:12 +02:00
|
|
|
endif
|
2009-01-11 22:49:02 +01:00
|
|
|
else
|
|
|
|
sed -i -e "s:^forward_only .*$$:forward_only true:" \
|
2010-06-12 15:36:12 +02:00
|
|
|
$(DESTDIR)$(CONFIG_DIR)/$(NEWCONF)
|
2009-01-11 22:49:02 +01:00
|
|
|
endif
|
2006-06-13 21:34:36 +02:00
|
|
|
|
|
|
|
clean:
|
2012-12-09 12:26:51 +01:00
|
|
|
rm -rf build plugins/*.so $(TARGET)
|
2006-06-13 21:34:36 +02:00
|
|
|
|
2012-12-09 12:26:51 +01:00
|
|
|
include $(shell find $(BUILD_DIR) -name \*.d 2> /dev/null)
|